javamavenmaven-scm

What's the difference between dependency:copy mojo used in command line and configured same pulgin in pom file as build plugin


I want to find all dependencies of io.airlift:node:0.112, with downloading minimum files:

  1. Using command %M2_HOME%/bin/mvn dependency:copy -Dmdep.outputScope=true -DincludeScope=compile -DincludeParents=true -DoutputFile="F:\temp\mytemp5" -DexcludeTransitive=true -f "F:\maven-plugins\node-0.112.pom", it is downloading org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1.

  2. If I create a dummy pom and have dependency to node-0.112, and then run the same command on dummy pom, it doesn't download org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1. Below is my pom file:

    <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>dummy</groupId>
      <artifactId>dummy</artifactId>
      <version>1.0</version>
      <packaging>pom</packaging>
      <dependencies>
        <dependency>
         <groupId>io.airlift</groupId>
         <artifactId>node</artifactId>
         <version>0.112</version>
         <type>pom</type>
        </dependency>
       </dependencies>
       <build>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-dependency-plugin</artifactId>
              <version>2.8</version>
              <executions>
                <execution>
                  <id>copy-dependencies</id>
                  <phase>package</phase>
                  <goals>
                    <goal>copy-dependencies</goal>
                  </goals>
                  <configuration>
                    <addParentPoms>true</addParentPoms>
                    <copyPom>true</copyPom>
                    <outputDirectory>.</outputDirectory>
                    <excludeTransitive>false</excludeTransitive>
                    <useRepositoryLayout>true</useRepositoryLayout>
                    <includeScope>compile</includeScope>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </build>
      </project>
    

Also org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1 is not even returned as dependencies for both methods.

Why is maven trying to download this extra plugin? What is the best way to find dependencies without downloading extra plugins?


Solution

  • The io.airlift:node:0.112 pom has the following lines in it:

    <scm>
      <connection>scm:git:git://github.com/airlift/airlift.git</connection>
      <developerConnection>scm:git:git@github.com:airlift/airlift.git</developerConnection>
      <url>https://github.com/airlift/airlift/tree/master</url>
      <tag>0.112</tag>
    </scm>
    

    SCM stands for Software Configuration Management, which is basically the part of the pom that defines how the authors maintain their source. See link for more information

    So, the executable is this; there's not much at that link but you can take a look. This causes the org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1 to be downloaded to facilitate the project's connection to it's git repository. It's not a dependency on the project itself, but it is a dependency on how the project is maintained - by using git for version control.

    Therefore, if you execute mvn dependency:copy, it will download the gitexe, but if you create a new project that doesn't define the git scm (and, in fact, defines no SCM at all), then it won't download the executable.