0
我想創建一個基於maven的工具,當我添加一個依賴到pom.xml時,我想從下載jar文件中自動提取一些文件並將它們複製到另一個文件夾。有可能擴展Maven依賴插件嗎?任何建議表示讚賞。如何自動從Maven依賴關係中提取內容?
我想創建一個基於maven的工具,當我添加一個依賴到pom.xml時,我想從下載jar文件中自動提取一些文件並將它們複製到另一個文件夾。有可能擴展Maven依賴插件嗎?任何建議表示讚賞。如何自動從Maven依賴關係中提取內容?
您可以創建文件夾包含Maven Dependency Plugin和簡單的示例如下
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- configure the plugin here -->
</configuration>
</execution>
</executions>
</plugin>
添加所有的依賴,你可以複製的jar文件渴望文件夾下的插件
http://evgeny-goldin.com/wiki/Copy-maven-plugin
這是一個簡單的示例,您可以用於將文件從目標中的依賴項文件夾複製到另一個文件夾中
<plugin>
<!-- download from here
http://evgeny-goldin.org/artifactory/repo/com/goldin/plugins/maven-copy-plugin/0.2.3.8-beta-9/
-->
<groupId>com.goldin.plugins</groupId>
<artifactId>maven-copy-plugin</artifactId>
<version>0.2.3.8-beta-9</version>
<executions>
<execution>
<id>create-archive</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<resources>
<!-- ~~~~~~~~~~~~~~ -->
<!-- Copy resources -->
<!-- ~~~~~~~~~~~~~~ -->
<resource>
<targetPath>c:/YOUR_NEW_FOLDER/</targetPath>
<directory>${project.basedir}/target/dependency/</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
第一個插件在包階段執行,第二個插件在安裝階段執行,您可以根據您的要求更改這些階段 – Ashkan
謝謝,但我需要從依賴關係jar文件中提取一些文件。像/ meta-info/xxx。不要複製jar文件。 – Chi
爲此,您可以使用第一個插件,請按照以下鏈接http://maven.apache.org/plugins/maven-dependency-plugin/和http://stackoverflow.com/questions/5559519/maven-extract-files-從-JAR – Ashkan