我有一个包含.txt文件的文件夹,用于保存数据。此数据已加载到我的游戏中,然后在游戏中使用。
我也有其他3个不在maven上的库。因此,我使用此插件将它们加载到.m2文件夹中:maven-install-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-everythingrs-api-jar</id>
<phase>validate</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>everythingrs-api</groupId>
<artifactId>everythingrs-api</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<file>${project.basedir}/lib/everythingrs-api.jar</file>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
...
</execution>
<execution>
...
</execution>
<executions>
</plugin>
然后,我使用此插件:maven-assembly-plugin将项目编译为一个包含其内部库的jar。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>${main-class-path}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
现在,如果我运行mvn clean validate install,它将把我拥有的3个库复制到.m2中,那么第二个插件将编译成一个可执行jar,其中包含从maven repo导入的库以及添加到.m2中的3个库。放进罐子里
但是,我在项目./中也有一个文件夹,但是在src之外,我如何才能使Maven插件在jar中也包含此目录/文件夹?
尝试使用Maven资源插件。它允许您添加不属于/src/main/resources
Maven资源的文件夹。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句