您可以使用maven-jar-plugin來完成此操作。
例:
<plugin> <!-- jar plugin -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>jar-with-var</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive>
<index>true</index>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
<classifier>jar-with-var</classifier>
<includes>
<include>path/to/your/files/*</include>
</includes>
</configuration>
</execution>
<executions>
</plugin>
以上將創建一個罐子追加到它的結束,命名爲您的工件ID分級-jar-with-var.jar
,包含的所有文件包括塊。 同樣,您也可以創建一個明確排除文件的jar文件。鏈接的引用應該告訴你如何做到這一點。
一旦我有了jar,我該如何將jar安裝到本地m2 repo中?
使用maven安裝,插件設置額外的安裝目標
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>jar-with-var</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>your group id</groupId>
<artifactId>the desired artifact id</artifactId>
<version>your version</version>
<file>your created jar file</file>
</configuration>
</execution>
</executions>
</plugin
當你與這個POM運行mvn install
,它會打包你的罐子,創建你的文物,並將其安裝到您當地的.m2回購
這是標記爲Maven ...您是否使用Maven構建您的項目? – 2014-09-23 00:48:16
是的。我需要配置pom文件來做到這一點.... – user800799 2014-09-23 00:50:48