Java – use Maven to add another project’s jar as a resource
•
Java
In my project, I have a subproject automatic update program It is basically a jar file extracted and run when the update is available
Can I compile the subproject and place the output jar as a build resource for Updater. Exe Jar is included in the final jar, for example:
Project-1.0.jar
|-updater.jar
|-Main.class
|-B.class
Thank you for your help (I'm a novice of Maven)
Solution
This task calls Maven assembly plugin or Maven dependency plugin
(I hope the updater is also a maven project) this shoudl is the correct configuration of Maven dependency plugin [I didn't test this, you may need to put the updater into the project depndencies]
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>company.com.project</groupId>
<artifactId>Updater</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<outputDirectory>${project.build.outputDirectory}/classes</outputDirectory>
<destFileName>updater.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
