简体   繁体   English

如何在Tycho中使用相同的目标平台多个子项目

[英]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.

相关问题 如何使用本地目录作为Tycho构建的目标平台? - How can I use a local directory as target platform for a Tycho build? 如何使用IntelliJ,maven和spring-data-rest处理多个子项目? - How to work with multiple sub-projects using IntelliJ, maven and spring-data-rest? 如何在Tycho构建中将另一个项目的目标文件夹用作目标平台存储库? - How to use the target folder of another project as target platform repository in a Tycho build? Eclipse Tycho目标平台“设置为目标平台” - Eclipse Tycho Target Platform “Set as Target Platform” 第谷| 如何使用tycho构建同一插件的多个版本 - Tycho | How to build multiple version of same plugin using tycho maven多模块项目如何包括gradle子项目? - How can a maven multi-module project include gradle sub-projects? 如何设置具有相互依赖关系的maven子项目? - How do I setup maven sub-projects with inter-dependencies? 多线程Maven子项目是否可能? - Is it possible to multi-thread maven sub-projects? 如果使用 Tycho 从子项目构建,则找不到目标平台 - Target platform not found if building from child project with Tycho 使用目标平台处理用Tycho构建的Eclipse插件的依赖关系 - Handling dependencies of an Eclipse plugin built with Tycho, using a Target Platform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM