The only Maven experience I have is including other libraries so I need a very basic explanation about how I can achieve things in Maven with Eclipse.
I want to create my jar regulary. Then I want to take 3 further files and put all files together in 1 zip file. The content of my zip should look like this:
A.jar
B.txt
C.txt
D.bat
I know I have to insert certain goals in my pom.xml
file. I already saw posts on Stack Overflow (i.e. here) regarding similar topics. I also tried the Maven documentation like here. Do I already need any Maven plugins or is still already Maven-core stuff?
But my skills are not enough yet to transfer this information for my case.
bin.xml
poml.xml
Output : mvn clean package
You need to use the
maven-assembly-plugin
when you need to create custom artifacts. I strongly suggest that you read Chapter 8. Maven Assemblies of the Maven book to get you started with using assemblies. This chapter contains in-depth explanations on the creation of Maven assemblies, and it is easy to read.Basically, an assembly is created with the help of an assembly descriptor. The following assembly descriptor will include the project main artifact at the root of a zip archive. You can add more
<file>
or<fileSets>
declaration here to add your custom files in your archive (the logic is the same)Then you just need to declare this plugin in your POM. In this case, the plugin is bound to the
package
phase and configured with the descriptor above. By default, the assembly id is appended to the name of the archive: I removed it here.When running
mvn clean package
, you will see that a zip archive will have been created in thetarget
directory.