1

我有多个项目。模块之一是程序集,具有将核心(库)和示例放在一个 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 文件夹中?(从父项目运行:全新安装)

找到的输出:

[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] 
4

1 回答 1

1

在 .m2 存储库中发布的名称始终${module.artifactId}-${module.version}.${module.extension}是已设置的,并且在文件夹finalName中正确重命名了包。target

我找到了两种方法来改变它:

  1. 不是真正的解决方案:更改 artifactId(但这是我最终为我的项目选择的解决方案)

  2. id在程序集 XML 中设置一个:

    在 assembly/resources.xml -> <id>= 所需的后缀(例如<id>myappid</id>

    在 pom.xml maven-assembly-plugin 构建部分,设置appendAssemblyId为 true

    结果将是:

    • 目标文件夹中的文件名 =${artifactId}-${version}-${assemblyId}.zip
    • .m2 repo 文件夹中的文件 = 与目标中的相同
于 2013-10-16T08:04:10.947 回答