Rajeshwar Rajeshwar - 5 months ago 14
Java Question

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?

Answer
    <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.

Comments