2013-04-18 35 views
1

我使用複製依賴關係目標來複制當前工件的依賴關係。 但它不會複製範圍'provided'的依賴關係。 如何解決它?強制Maven 3複製「提供」依賴關係

XML配置爲標準配置:

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.0.2</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>copy-dependencies</id> 
        <phase>install</phase> 
        <goals> 
         <goal>copy-dependencies</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>lib</outputDirectory> 
         <overWriteReleases>true</overWriteReleases> 
         <overWriteSnapshots>true</overWriteSnapshots> 
         <overWriteIfNewer>true</overWriteIfNewer> 
         <excludeArtifactIds>project-services</excludeArtifactIds> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
    <finalName>project-web</finalName> 
</build> 

我爲什麼要這麼做? 因爲我必須同時支持ant和maven構建工作。 因此,我想通過運行mvn install -o將所有依賴項複製到單獨的目錄中。在Ant build.xml中,我將路徑作爲類路徑包含到該目錄中。在那之後,Ant會建立ear文件幷包含整個lib目錄,包括音頻系統tools.jar和其他「提供」的jar文件。 的Apache Maven的版本是3.0.3

+0

Maven的命令是否運行? – orique

+4

你爲什麼想這樣做?使用範圍=提供的依賴關係是這樣標記的,因爲它們已經存在於目標環境中。你爲什麼要複製它們? – OldCurmudgeon

+3

爲什麼要標記他們提供,如果你需要複製它們? –

回答

1

如記錄由插件使用includeScope:

http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html#includeScope

編輯

我爲什麼要這麼做?因爲我必須同時支持ant和maven 構建工作。

考慮使用常春藤使用Ant來管理你的依賴: http://ant.apache.org/ivy/

這裏後如何配置常春藤連接的Nexus:

https://support.sonatype.com/entries/21627528-how-do-i-configure-my-ivy-build-to-download-artifacts-from-nexus

+0

但該文檔還說*要包含的範圍。一個空字符串表示所有範圍(默認)。*因此不需要使用'includeScope'。 – maba

+0

是的,我剛剛看到了。 – Puce