I received a source code bundle. Inside the src directory tree there are some properties files(.properties) which I want to keep in the output jar in the same place. e.g: I want
我收到了一个源代码包。在src目录树里面有一些属性文件(.properties),我想把它们保存在同一个地方的输出jar中。例如:我想要
src/main/java/com.mycompany/utils/Myclass.java
src/main/java/com.mycompany/utils/Myclass.properties
to stay the same in the jar:
在罐子里保持不变:
com.mycompany/utils/Myclass.class
com.mycompany/utils/Myclass.properties
without needing to add the properties file it to separate resources folder. Is there a way to I tell this to maven?
无需将属性文件添加到单独的资源文件夹中。有没有办法让我告诉maven?
2 个解决方案
#1
60
You could add the following in your pom indicating that the resources are available in src/main/java
and including
the type of resources.
您可以在pom中添加以下内容,指示资源在src / main / java中可用,并包括资源类型。
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
#2
8
With this pom fragment you include anything that is not a java file for both main and test artifact:
使用这个pom片段,您可以包含任何不是main文件和测试工件的java文件:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
</build>
#1
60
You could add the following in your pom indicating that the resources are available in src/main/java
and including
the type of resources.
您可以在pom中添加以下内容,指示资源在src / main / java中可用,并包括资源类型。
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
#2
8
With this pom fragment you include anything that is not a java file for both main and test artifact:
使用这个pom片段,您可以包含任何不是main文件和测试工件的java文件:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
</build>