【发布时间】:2025-11-25 23:45:02
【问题描述】:
我的 Eclipse 产品需要使用 tycho maven 插件为三个操作系统(win、linux、mac)打包(zip、tar.gz、app)。
我的父 pom 包含 tycho 用于在打包阶段生成不同版本产品的 env 过滤:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>msi.gama</groupId>
<artifactId>msi.gama.parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<!-- You can see the effect of Execution Environnement here : https://wiki.eclipse.org/Tycho/Execution_Environments :
Tycho ensures that package imports may only be matched against the selected execution environment ,
b) Tycho hides packages which are not provided by the configured execution environment. -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<filters>
<!-- FIX the JDT core due to bug in tycho https://www.eclipse.org/forums/index.php/t/1068443/ -->
<filter>
<type>eclipse-plugin</type>
<id>org.eclipse.jdt.core</id>
<restrictTo>
<version>3.11.2.v20160128-0629</version>
<!--<version>3.4.0.v20150518-1201</version>-->
</restrictTo>
</filter>
<!-- work around Equinox bug 348045 -->
<filter>
<type>p2-installable-unit</type>
<id>org.eclipse.equinox.servletbridge.extensionbundle</id>
<removeAll />
</filter>
</filters>
<resolver>p2</resolver>
<pomDependencies>consider</pomDependencies>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
我的 pom.xml 用于产品文件夹:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>msi.gama</groupId>
<artifactId>msi.gama.parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../msi.gama.parent/</relativePath>
</parent>
<artifactId>msi.gama.application.product</artifactId>
<packaging>eclipse-repository</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<includeAllDependencies>true</includeAllDependencies>
</configuration>
</plugin>
<!-- If the project contains more than one product file ... -->
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho.version}</version>
<executions>
<execution>
<id>create-distributions</id>
<goals>
<goal>materialize-products</goal>
<goal>archive-products</goal>
</goals>
</execution>
</executions>
</plugin>
</build>
</project>
文件夹中的结果:
➜ products git:(master) ls
msi.gama.application.product msi.gama.application.product-linux.gtk.x86.zip msi.gama.application.product-win32.win32.x86_64.zip
msi.gama.application.product-linux.gtk.x86_64.zip msi.gama.application.product-macosx.cocoa.x86_64.zip msi.gama.application.product-win32.win32.x86.zip
➜ products git:(master) cd msi.gama.application.product
➜ msi.gama.application.product git:(master) ls
linux macosx win32
我的问题是每个操作系统都需要一些特定的操作。
例如,对于 MACOS 打包,我需要重新复制一些文件夹和文件来构建 .app 应用程序的元数据。
有没有办法使用 tycho 指定复制、过滤 IO 操作,或者我需要使用 maven-resource-plugin 之类的东西?
如果是这种情况,在tycho打包的这一步,os如何指定maven-resource-plugin操作?
【问题讨论】:
标签: java eclipse maven osgi tycho