I am very new to Maven and would like to see an example of how one uses the maven jar plugin. I already visited here but did not find any examples. On the documentation page, there were some parameters listed for this goal but what I was looking for is how one places them in the 'goal' or 'executions' tag. Thanks.
Maven JAR Plugin is used to build JARs. It contains two goals: jar:jar create a jar file for your project classes inclusive resources. jar:test-jar create a jar file for your project test classes.
NOTE: Once you have added a plugin to a pom. xml you can use the shorthand notation to execute the plugin: mvn <prefix>:<goal> , commonly the “prefix” is the artifact ID minus the “-maven-plugin”. For example mvn example:version .
plug-in is a software component that adds a specific feature to any computer program.It specially use to customize any computer program. But . jar file is a java executable file which can only run on an environment which Java installed.
You usually don't use the jar plugin. If you set the packaging to jar, the goal jar:jar gets executed automatically.
If you want to configure the jar plugin, do it like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<excludes>
<exclude>**/*.xml</exclude>
</excludes>
</configuration>
</plugin>
(Example: exclude all xml files from the jar)
There is no need to add any goal or execution blocks, a global configuration block is valid for all executions.
Reference:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With