我有多项目项目。模块之一是汇编,具有描述符将核心(库)和示例放在一个zip中。
<assembly>
<id>assembly</id>
<formats>
<format>zip</format>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputDirectory>/</outputDirectory>
</dependencySet>
</dependencySets>
这是我的组合,这是插件配置
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>package-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
我在我的.m2文件夹中安装了zip,但名称是assembly-ccp -....我需要将它重命名为my-project,它可以在插件中用2行完成:
<finalName>my-project</finalName>
<appendAssemblyId>false</appendAssemblyId>
在目标文件夹中很好(我可以看到my-project.zip),但是现在生成的zip没有安装在我的.m2文件夹中。那么,问题是如何将它安装在我的.m2文件夹中? (从父项目运行:clean install)
找到输出:
[INFO] Building Assebly
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory /home/dmitry/mbus/trunk/assembly/target
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] Preparing source:jar
[WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation.
[INFO] No goals needed for project - skipping
[INFO] [source:jar {execution: default}]
[INFO] [assembly:single {execution: package-assembly}]
[INFO] Reading assembly descriptor: assembly.xml
[INFO] Processing DependencySet (output=/)
[WARNING] Cannot include project artifact: com.comcast.xcal.mbus:assembly:pom:CCP-LATEST-SNAPSHOT; it doesn't have an associated file or directory.
[INFO] Building zip: /home/dmitry/mbus/trunk/assembly/target/my-project.zip
[WARNING] Configuration options: 'appendAssemblyId' is set to false, and 'classifier' is missing.
Instead of attaching the assembly file: /home/dmitry/mbus/trunk/assembly/target/my-project.zip, 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-deterministic!
[INFO] Processing DependencySet (output=/)
[INFO] Copying files to /home/dmitry/mbus/trunk/assembly/target/my-project.dir
[WARNING] Assembly file: /home/dmitry/mbus/trunk/assembly/target/my-project.dir is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.
[INFO] [install:install {execution: default-install}]
[INFO] Installing /home/dmitry/mbus/trunk/assembly/pom.xml to /home/dmitry/.m2/repository/com/mbus/assembly/CCP-LATEST-SNAPSHOT/assembly-CCP-LATEST-SNAPSHOT.pom
[INFO] [javadoc:jar {execution: default}]
[INFO] Not executing Javadoc as the project is not a Java classpath-capable package
[INFO]
[INFO]
答案 0 :(得分:0)
.m2存储库中发布的名称始终为${module.artifactId}-${module.version}.${module.extension}
,即使设置了finalName
,并且在target
文件夹中正确地重命名了包。
我找到了两种方法来改变它:
不是真正的解决方案:更改artifactId(但这是我最终为我的项目选择的解决方案)
在程序集XML中设置id
:
在assembly / resources.xml中
- &GT; <id>
=所需的后缀(例如<id>myappid</id>
)
在pom.xml maven-assembly-plugin build部分中,将appendAssemblyId
设置为true
结果将是:
${artifactId}-${version}-${assemblyId}.zip