我的eclipse产品需要使用tycho maven插件打包(zip,tar.gz,app)三个操作系统(win,linux,mac)。
我的父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操作?
答案 0 :(得分:0)
1-有没有办法指定副本,使用tycho过滤IO操作,或者我需要使用像maven-resource-plugin这样的东西?
是的,您可以使用maven-resource-plugin
并且它具有过滤操作。
2-如果是这种情况,我怎样才能在这个包装在tycho中的步骤中指定maven-resource-plugin操作?
您可以在maven-resource-plugin
中定义多个执行,每次执行都可以将某些文件复制到您想要的目标OS包中。
示例:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources-win</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/products/msi.gama.application.product/win32/win32/x86/configurations</outputDirectory>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>app</nonFilteredFileExtension>
<nonFilteredFileExtension>config</nonFilteredFileExtension>
</nonFilteredFileExtensions>
<resources>
<resource>
<directory>sourcefolder</directory>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-resources-mac</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/products/msi.gama.application.product/macosx/cocoa/x86_64</outputDirectory>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>extension1</nonFilteredFileExtension>
<nonFilteredFileExtension>extesion2</nonFilteredFileExtension>
</nonFilteredFileExtensions>
<resources>
<resource>
<directory>macfolder</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
请参阅maven-resources-plugin可选参数以获取更多详细信息
希望这会有所帮助。