gpt4 book ai didi

java - 如何重命名结果程序集以安装在 .m2 中

转载 作者:行者123 更新时间:2023-12-01 05:03:10 26 4
gpt4 key购买 nike

我有多模块项目。模块之一是程序集,具有将核心(库)和示例放在一个 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>

我已经将生成的 zip 安装在我的 .m2 文件夹中,但名称是 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]

最佳答案

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

我找到了两种方法来改变这一点:

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

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

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

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

    结果将是:

    • 目标文件夹中的文件名 = ${artifactId}-${version}-${assemblyId}.zip
    • .m2 存储库文件夹中的文件 = 与目标中的文件相同

关于java - 如何重命名结果程序集以安装在 .m2 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13119521/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com