4
我試圖使用Maven創建包含在單獨的目錄的依賴可執行的JAR文件的依賴性。我已經看到很多關於創建「超級巨人」的問題 - 我不想那麼做。我想是有複製到像這樣一個「lib」目錄的depenedencies(和JAR MANIFEST.MF
文件與ClassPath
條目指向它們):如何建立與Maven運行的JAR包含在一個單獨的「LIB」文件夾(不是超級JAR)
/myApp
myApp.SNAPSHOT-1.0.jar
/lib
hibernate.jar
log4j.jar
...
作爲額外的獎勵,如果我這將是很好可以複製/src/main/resources/*
爲/myApp/conf
,然後拉上拉鍊,整個/myApp
目錄到myApp.zip
爲好。
編輯:我使用maven的依賴,插件和Maven的資源,插件和Maven的罐子的插件。這是我包括我的pom.xml(其複製運行時依賴於/目標/ release/lib目錄,這樣我可以拉上/目標/釋放,它已經準備好去):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>
${project.build.directory}/release/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/release</outputDirectory>
<resources>
<resource>
<directory>src/main/config</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/release/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
嗯,好我不知道那根本。但是,我將如何更新我的jar的清單文件來爲類路徑使用該位置? – 2012-02-11 23:08:18
什麼[清單定製(http://maven.apache.org/plugins/maven-jar-plugin/examples/manifest-customization.html)?當然,使用屬性或maven變量。 – 2012-02-12 22:02:00
@dma_k,嗯,可能的工作,我會考慮這樣做。 – 2012-02-14 06:50:29