Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

are there any examples of how to use maven-jar-plugin?

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.

like image 328
John Avatar asked Oct 29 '10 13:10

John


People also ask

What is Maven jar plugin used for?

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.

How do I run a Maven plugin?

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 .

What is the difference between jar and plugin?

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.


1 Answers

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:

  • jar:jar goal
  • Built-in lifecycle bindings
like image 114
Sean Patrick Floyd Avatar answered Nov 15 '22 12:11

Sean Patrick Floyd