1
我有一個項目對其他Jars有一些依賴關係。我目前使用JavaDoc插件和Assembly插件來生成我的項目的.zip,其中包含我的Jar,依賴項Jars以及javadoc。Maven:jar -with-dependencies + JavaDoc
但是,我想將事情弄糟,以便在.zip中只有一個Jar以及相關的JavaDoc。我知道程序集插件+ jar -with-dependencies是我的朋友,但我該如何解決這個問題,以便我可以打包一個包含此jar的.zip以及我的JavaDoc? DIST-jwd.xml的
<properties>
<assemblyJar>${project.build.finalName}.jar</assemblyJar>
<assemblyJwd>${project.build.finalName}-jar-with-dependencies.jar</assemblyJwd>
<java.code.version>1.4</java.code.version>
</properties>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version> <!-- 2.3 might be needed -->
<configuration>
<descriptors>
<descriptor>src/assembly/dist-jwd.xml</descriptor>
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-jwd</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version> <!-- 2.3 might be needed -->
<configuration>
<descriptors>
<descriptor>src/assembly/dist.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
相關部分:dist.xml的
<id>dist-jwd</id>
<includeBaseDirectory>true</includeBaseDirectory>
<files>
<file>
<fileMode>444</fileMode>
<source>target/${assemblyJar}</source>
<outputDirectory></outputDirectory>
</file>
</files>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<scope>compile</scope>
<excludes>
<exclude>javax.servlet:servlet-api</exclude>
</excludes>
<useProjectArtifact>false</useProjectArtifact>
</dependencySet>
</dependencySets>
及相關零部件:
<id>dist-zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<fileMode>444</fileMode>
<directory>target/site/apidocs</directory>
<outputDirectory>javadoc</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<fileMode>444</fileMode>
<source>target/${assemblyJwd}</source>
<outputDirectory></outputDirectory>
</file>
</files>
目前
我下面的聚甲醛的相關部分我收到錯誤:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:single (make-jwd) on project deviceinsight-api-java: Failed to create assembly: Error adding file to archive: /Users/barmistead/Mercurial/deviceinsight-print/target/deviceinsight-api-java-3.1.16-1-SNAPSHOT-jar-with-dependencies.jar isn't a file. -> [Help 1]
我猜這是一個可能的雞與雞蛋問題,所以如果maven沒有優雅的解決方案,那麼我將不得不手動做一些事情。不過,我認爲我想做的事很常見,所以我會認爲會有一個簡單的方法。