在使用Tycho编译Eclips plugin项目时,需要制定Eclipse IDE的相关依赖配置,通常使用的都是配置一个repository在pom.xml中,如下:
<properties>
<eclipse-repo.url>http://download.eclipse.org/releases/latest</eclipse-repo.url>
</properties>
<repositories>
<repository>
<id>eclipse-release</id>
<url>${eclipse-repo.url}</url>
<layout>p2</layout>
</repository>
</repositories>
下面为大家介绍另一种使用target platform作为编译配置的设置方法。
1. 创建target platform文件
参考https://blog.csdn.net/devin_xin/article/details/104898574
这里需要注意的是:target 文件的名字一定要和其所在的项目的artifact id相同且以.target结尾。
2.为target文件所在的项目创建pom.xml文件
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.devinxin.example.tycho</groupId>
<artifactId>target-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-target-definition</packaging>
</project>
3.更显aggregator pom和configuration相关内容
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.devinxin.example.tycho</groupId>
<artifactId>com.devinxin.example.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
...
<module>target-platform</module>
</modules>
...
<!-- 注释掉以前的方式
<properties>
<eclipse-repo.url>http://download.eclipse.org/releases/latest</eclipse-repo.url>
</properties>
<repositories>
<repository>
<id>eclipse-release</id>
<url>${eclipse-repo.url}</url>
<layout>p2</layout>
</repository>
</repositories>
</project>
-->
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<!--enable to use target platform -->
<target>
<artifact>
<groupId>com.devinxin.example.tycho</groupId>
<artifactId>target-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
</artifact>
</target>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>