2010-04-01 113 views

回答

6

你並不需要使用過濾爲,使用Maven Dependency plugin和一個dependency:tree目標顯示依賴關係樹爲這個項目。使用... outputFile可選參數設置輸出文件。所以配置可能類似於:

<project> 
    ... 
    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-dependency-plugin</artifactId> 
     <executions> 
      <execution> 
      <id>tree</id> 
      <phase>prepare-package</phase> 
      <goals> 
       <goal>tree</goal> 
      </goals> 
      <configuration> 
       <outputFile>${project.build.outputDirectory}/dep.txt</outputFile> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 
    ... 
</project> 

運行package階段會產生依賴關係樹在target/classes/dep.txt和神器打包。適應它以適應您的需求。

0

mvn dependency:resolve似乎是你在找什麼。把下面的插件配置到您的POM文件:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <executions> 
     <execution> 
     <id>list-dependencies</id> 
     <phase>prepare-package</phase> 
     <goals> 
      <goal>resolve</goal> 
     </goals> 
     <configuration> 
      <outputFile>dependencies.txt</outputFile> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

它會產生文件dependencies.txt與內容類似於:

The following files have been resolved: 
    am:amagent:jar:1.0:system 
    am:amclientsdk:jar:1.0:system 
    aopalliance:aopalliance:jar:1.0:compile 
    asm:asm:jar:2.2.3:compile 
    com.sun.jdmk:jmxtools:jar:1.2.1:compile 
    com.sun.jmx:jmxri:jar:1.2.1:compile 
    com.sun.xml.bind:jaxb-impl:jar:2.1.12:compile 
    com.sun.xml.fastinfoset:FastInfoset:jar:1.2.2:compile 
    com.sun.xml.messaging.saaj:saaj-impl:jar:1.3.2:compile 
    commons-lang:commons-lang:jar:2.3:compile 
    commons-logging:commons-logging:jar:1.1:compile 
    dom4j:dom4j:jar:1.6.1:compile 
    javax.activation:activation:jar:1.1:provided 
    javax.jms:jms:jar:1.1:compile 
    javax.mail:mail:jar:1.4:compile 
    javax.xml.bind:jaxb-api:jar:2.1:compile 
    javax.xml.soap:saaj-api:jar:1.3:compile 
    junit:junit:jar:4.4:test 
    log4j:log4j:jar:1.2.15:compile 
相關問題