3

谁能解释为什么我会在 maven-dependency-plugin 上的树和构建类路径之间获得不同的输出顺序?

我在跑

mvn -pl releases org.apache.maven.plugins:maven-dependency-plugin:2.6:tree -Dtokens=whitespace -outputFile=tree.txt -DexcludeTransitive=true

在命令行上生成输出。tree 的输出反映了 pom 文件中定义的顺序,而 build-classpath 的输出则没有。

http://pastebin.com/J2Q6iTK6的输出

构建类路径http://pastebin.com/k2SdrHP7的输出

任何见解将不胜感激。

Maven 配置

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>generate-classpath-windows</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>build-classpath</goal>
                    </goals>
                    <configuration>
                        <pathSeparator>,</pathSeparator>
                        <prefix>..\jars</prefix>
                        <fileSeparator>\</fileSeparator>
                        <outputFile>${project.build.directory}/deployment/bin/classpath.windows</outputFile>
                    </configuration>
                </execution>
                <execution>
                    <id>generate-classpath-unix</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>build-classpath</goal>
                    </goals>
                    <configuration>
                        <pathSeparator>:</pathSeparator>
                        <prefix>../jars</prefix>
                        <fileSeparator>/</fileSeparator>
                        <outputFile>${project.build.directory}/deployment/bin/classpath.unix</outputFile>
                    </configuration>
                </execution>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/deployment/jars</outputDirectory>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <overWriteReleases>false</overWriteReleases>
                <overWriteSnapshots>true</overWriteSnapshots>
                <overWriteIfNewer>true</overWriteIfNewer>
                <excludeTransitive>true</excludeTransitive>
                <includeScope>runtime</includeScope>
                <regenerateFile>true</regenerateFile>
            </configuration>
        </plugin>

信息

Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
Maven home: C:\apps\apache-maven-3.0.4
Java version: 1.6.0_37, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_37\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
4

1 回答 1

1

类路径是线性表示,树是嵌套的。Maven 应该尝试将根级别依赖项首先保留在类路径中,因为它们最接近,因此应该首先解决。

从您的输出来看,虽然这看起来很奇怪,但我没有看到我期望的正常逻辑重新类路径构造。

此外,直到 2.6 版本的依赖插件,在 Maven 3.x 上,dependency:tree输出是不正确的。我想知道是否存在build-classpath来自同一根本原因的错误。我会将这个问题发送给 users@maven.apache.org 以查看是否有人(修复了 Hervédependency:tree的人)知道答案......

于 2013-01-15T15:09:53.573 回答