gpt4 book ai didi

maven - Tycho 中如何使用同一个目标平台多个子项目

转载 作者:行者123 更新时间:2023-12-04 17:24:32 30 4
gpt4 key购买 nike

是否可以为每个 Maven 子项目使用相同的 .target 文件?

来自父 .pom 文件的片段

<groupId>root.server</groupId>
<artifactId>root.server</artifactId>

来自子 .pom 文件的片段
<groupId>child.project</groupId>
<artifactId>child.project.parent</artifactId>

<target>
<artifact>
<groupId>root.server</groupId>
<artifactId>root.server</artifactId>
<version>${project.version}</version>
<classifier>targetfile</classifier>
</artifact>
</target>

当我在子项目中尝试“mvn clean install”时出现异常: Could not resolve target platform specification artifact .当我在子项目的父项中尝试“mvn clean install”时,一切正常。

有没有办法为所有项目(父项目+子项目)重用一个 .target 文件?

最佳答案

这是可能的,并且是首选方法。

您应该专门为您的.target 创建一个子模块。文件(例如,称为目标定义)。这应该是一个 pom 打包类型的项目。您还应该包括以下片段 - 这是允许其他模块访问 .target 文件的片段:

  <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>targetFilename.target</file>
<type>target</type>
<classifier>targetFilename</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>

现在在你的父 pom 中你可以在 target-platform-configuration 中引用这个模块。并且您的子模块也将使用它:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<target>
<artifact>
<groupId>org.example</groupId>
<artifactId>target-definition</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>targetFilename</classifier>
</artifact>
</target>
</configuration>
</plugin>

还有一个 enhancement request为 .target 文件创建包装类型以帮助将来的事情。

关于maven - Tycho 中如何使用同一个目标平台多个子项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12101847/

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