tar gz文件包含Maven构建后损坏的jar文件



我有一个pom.xml和单独的assembly-descriptor.xml文件。最终的结果是一个tar.gz文件,其中包含我的tomcat网络应用程序和一些jar文件。当我在我的本地开发盒(Mac OS 10.7和Maven 3.0.3)上构建它时,生成的tar.gz包含一个有效的jar文件。当构建在我们的构建盒(Jenkins on linux server/Maven 3.0.3)上运行并部署到生产服务器时,jar文件的大小几乎是它应该大小的两倍,并且已损坏。当我将maven汇编插件的版本更改为2.3或2.4时,我可以在本地重现加倍/损坏问题。当我将其设置为2.1或2.2或没有版本(默认为2.2 beta 5)时,它在本地工作。但是,无论我选择什么版本,在构建框上的tar-gz步骤中,构建都会失败。(本地java版本=1.6.0_37,构建系统为1.6.0_34,但我不认为这种差异是罪魁祸首。)
这是我的pom.xml:

<plugin>
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<encoding>UTF-8</encoding>
<finalName>${project.build.finalName}_${project.version}</finalName>
<descriptors>
<descriptor>src/main/assembly/assembly-descriptor.xml</descriptor>
</descriptors>
<attach>true</attach>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>package-tar-gz</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>...

`这里是汇编描述符(assemblydescriptor.xml):

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0     http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/tomcat</directory>
<filtered>true</filtered>
<excludes>
<exclude>**/*.war</exclude>
</excludes>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>

最后,本地构建和生产构建之间的另一个区别是,生产构建使用本地存储库,而我的本地构建不使用。我没有给予这么多关注,因为我能够在本地重现jar文件加倍/损坏问题(即无本地repo问题)。

尝试删除true,这可能是的罪魁祸首

最新更新