Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plugins in Maven and POM.xml

I just started using Maven and I read that plugins are additional components that can be used.
A typical structure of pom.xml file is

<project>   <groupId>org.koshik.javabrains</groupId>   <artifactId>JarName</artifactId> (A fldernamed JarName was created)    <version>1.0-SNAPSHOT</version>   <packaging>jar</packaging>    <name>JarName</name>   <url>http://maven.apache.org</url>    <properties>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>   </properties>    <dependencies>     <dependency>       <groupId>junit</groupId>       <artifactId>junit</artifactId>       <version>3.8.1</version>       <scope>test</scope>     </dependency>   </dependencies> </project> 

Question: Where should I insert a plugin tag? such as the following:

<plugin>   <groupId>org.jibx</groupId>   <artifactId>jibx-maven-plugin</artifactId>   <version>1.2.4</version>   <executions>     <execution>       <goals>         <goal>bind</goal>       </goals>     </execution>   </executions> </plugin> 

Before the dependency or after the dependency tag? Does it matter?

like image 796
Rajeshwar Avatar asked May 11 '12 07:05

Rajeshwar


People also ask

What is plugin Management in POM XML?

From Maven documentation: pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.

How many Maven plugins are there?

In Maven, there are two kinds of plugins, build and reporting: Build plugins are executed during the build and configured in the <build/> element. Reporting plugins are executed during the site generation and configured in the <reporting/> element.


1 Answers

<project>     <groupId>org.koshik.javabrains</groupId>     <artifactId>JarName</artifactId> (A fldernamed JarName was created)      <version>1.0-SNAPSHOT</version>     <packaging>jar</packaging>      <name>JarName</name>     <url>http://maven.apache.org</url>      <properties>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>     </properties>      <build>         <plugins>             <plugin>                 <groupId>org.jibx</groupId>                 <artifactId>jibx-maven-plugin</artifactId>                 <version>1.2.4</version>                 <executions>                     <execution>                         <goals>                             <goal>bind</goal>                         </goals>                     </execution>                 </executions>             </plugin>         </plugins>     </build>      <dependencies>         <dependency>             <groupId>junit</groupId>             <artifactId>junit</artifactId>             <version>3.8.1</version>             <scope>test</scope>         </dependency>     </dependencies> </project> 

You can also place plugins in the <build> section of <profile> if you use maven profiles. The order doesn't matter.

like image 72
omnomnom Avatar answered Sep 17 '22 18:09

omnomnom