Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there difference between dependencies and dependencies in plugin tags?

I have a question.

In pom.xml, dependency is included in two places. one place can be in <project> tag and the other place can be in <plugin> tag.

I think the dependencies in tags is just related with the plugin? is it correct?

thanks in advance :)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <artifactId>clustered-queue</artifactId>
   <packaging>jar</packaging>
   <name>HornetQ JMS Clustered Queue Example</name>

   <dependencies>

      <dependency>
         <groupId>org.hornetq.examples.jms</groupId>
         <artifactId>hornetq-jms-examples-common</artifactId>
         <version>${project.version}</version>
      </dependency>
      <dependency>
         <groupId>org.jboss.spec.javax.jms</groupId>
         <artifactId>jboss-jms-api_1.1_spec</artifactId>
      </dependency>

   </dependencies>

   <build>
      <plugins>
         <plugin>
            <groupId>org.hornetq</groupId>
            <artifactId>hornetq-maven-plugin</artifactId>
            <executions>
               <execution>
                  <id>start1</id>
                  <goals>
                     <goal>start</goal>
                  </goals>
                  <configuration>
                     <jndiPort>1199</jndiPort>
                     <jndiRmiPort>1198</jndiRmiPort>
                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server1</hornetqConfigurationDir>
                     <fork>true</fork>
                     <systemProperties>
                        <property>
                           <name>udp-address</name>
                           <value>${udp-address}</value>
                        </property>
                     </systemProperties>
                  </configuration>
               </execution>
            </executions>
            <dependencies>

               <dependency>
                  <groupId>org.hornetq</groupId>
                  <artifactId>hornetq-core-client</artifactId>
                  <version>${project.version}</version>
               </dependency>
               <dependency>
                  <groupId>org.hornetq</groupId>
                  <artifactId>hornetq-server</artifactId>
                  <version>${project.version}</version>
               </dependency>

            </dependencies>
            <configuration>
               <waitOnStart>false</waitOnStart>
            </configuration>
         </plugin>
      </plugins>
   </build>

</project>
like image 966
verystrongjoe Avatar asked Mar 24 '23 09:03

verystrongjoe


1 Answers

The <dependencies> which is under the <project> is a dependency list for our artifacts which Maven will download and link the dependencies for us on compilation. Please see POM Reference: Dependencies and Introduction to the Dependency Mechanism for further information.

The <dependencies> which is under the <plugin> is to apply as dependencies of the plugin that they are under. The power of this is to alter the dependency list of a plugin, perhaps by removing an unused runtime dependency via exclusions, or by altering the version of a required dependency. Please see POM Reference: Plugins and Guide to Configuring Plug-ins for further information.

I hope this may help.

like image 198
Charlee Chitsuk Avatar answered Mar 31 '23 03:03

Charlee Chitsuk