在我的项目中,我创建了许多程序集(4-5)并将它们输出到target.1/2这些程序集中没有采用它们的最终名称(或程序集ID),而是按照artifactID-version.jar格式.这非常令人困惑为什么会这样?
我的pom.xml提取 -
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.apple</groupId>
<artifactId>maven</artifactId>
<name>maven_XX</name>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<!-- Added to avoid the compilation issue wrt Annotations -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>
<executions>
<execution>
<id>clientjar</id>
<phase>compile</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>XX_client</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>
${basedir}/src/main/resources/assemblies/clientjar.xml
</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>11***</id>
<phase>compile</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>11server</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>
${basedir}/src/main/resources/assemblies/11server.xml
</descriptor>
</descriptors>
<outputDirectory>assemblies-target</outputDirectory>
</configuration>
</execution>
<execution>
<id>cache</id>
<phase>compile</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>cache</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>
${basedir}/src/main/resources/assemblies/cache.xml
</descriptor>
</descriptors>
<outputDirectory>assemblies-target</outputDirectory>
</configuration>
</execution>
Run Code Online (Sandbox Code Playgroud)
Pet*_*ahn 14
将莱尔的评论拉到问题级别以提供可见性.
虽然之前的答案有效,但莱尔指出:
如果我理解正确的话,它似乎是一个有点侵入性的解决方法,相当于程序集插件中的错误.相反,请尝试在配置中设置false.见:MASSEMBLY-352
对于未附加到存储库分发的工件,这是一个很好的解决方案,对我来说效果很好.
...
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
...
Run Code Online (Sandbox Code Playgroud)
当你运行程序集时,Maven会看到这个输出到控制台吗?:
[INFO] [assembly:single {execution: 11***}]
[INFO] Reading assembly descriptor: C:\test\test-parent2/src/main/resources/assemblies/11server.xml
[INFO] Building jar: C:\test\test-parent2\assemblies-target\11server.jar
[WARNING] Configuration options: 'appendAssemblyId' is set to false, and 'classifier' is missing.
Instead of attaching the assembly file: C:\test\test-parent2\assemblies-target\11server.jar, it will become the file for
main project artifact.
NOTE: If multiple descriptors or descriptor-formats are provided for this project, the value of this file will be non-de
terministic!
Run Code Online (Sandbox Code Playgroud)
发生这种情况是因为所有程序集都指定<appendAssemblyId>false</appendAssemblyId>并且未指定分类器.分类器在2.2-beta-4版本中已弃用,因此无论如何都会被忽略,这是插件中的错误/功能.
因此,Maven将始终将其中一个程序集作为jar包装的"主要"工件,并且您不会在target-assemblies目录中看到它.
要解决此问题,您可以指定项目具有pom打包,然后将jar生命周期的目标绑定到pom.
要启用process-resources和compile目标,您需要更改包装pom,将以下配置添加到您的pom,并运行标准生命周期目标.例如mvn package或mvn install.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>process-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
绑定到jar生命周期的完整目标列表可以在Build Lifecycle Introduction简介的Built in Lifecycle Bindings部分中找到.他们都遵循与目标类似的模式.在您的情况下,您可能想要省略目标.process-resourcescompilejar
| 归档时间: |
|
| 查看次数: |
10200 次 |
| 最近记录: |