[英]How to use the same target platform multiple sub-projects in Tycho
Is it possible to use the same .target file for every maven subproject? 是否可以为每个maven子项目使用相同的.target文件?
Snippet from the parent .pom file 来自父.pom文件的代码段
<groupId>root.server</groupId>
<artifactId>root.server</artifactId>
Snippet from child .pom file 来自子.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>
When I try a "mvn clean install" in the child project I get an exception: Could not resolve target platform specification artifact
. 当我在子项目中尝试“mvn clean install”时,我得到一个异常: Could not resolve target platform specification artifact
。 When I try a "mvn clean install" in the parent of the child project everything works fine. 当我在子项目的父项中尝试“mvn clean install”时,一切正常。
Is there a way to reuse one .target file for all projects (parent + subprojects) ? 有没有办法为所有项目(父+子项目)重用一个.target文件?
It is possible and it is the preferred method. 它是可能的,它是首选的方法。
You should create a child module specifically for your .target
file (eg called target-definition). 您应该专门为.target
文件创建一个子模块(例如,称为目标定义)。 This should be a project with the pom packaging type. 这应该是具有pom包装类型的项目。 You should also include the following snippet - this is the piece which permits other modules to access the .target file: 您还应该包含以下代码段 - 这是允许其他模块访问.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>
Now in your parent pom you can reference this module in the target-platform-configuration and your child modules will also use it: 现在在您的父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>
There is also an enhancement request to create packaging type for .target files to help things in future. 还有一个增强请求 ,可以为.target文件创建包装类型,以便将来提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.