How to use the same target platform multiple sub-projects in Tycho

旧时模样 提交于 2019-12-05 08:55:54
Simon

It is possible and it is the preferred method.

You should create a child module specifically for your .target file (e.g. called target-definition). This should be a project with the pom packaging type. You should also include the following snippet - this is the piece which permits other modules to access the .target file:

  <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:

<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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!