os 使用 tycho create-distributions 进行不同的 io 打包操作?

Different io packaging operation by os using tycho create-distributions?

我的 eclipse 产品需要使用 tycho maven 插件打包 (zip,tar.gz,app) 三个 os (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

我的问题是每个 OS.

都需要一些特定的操作

例如,对于MACOS打包,我需要重新复制一些文件夹和文件来构建.app应用程序的元数据。

有没有办法使用 tycho 指定复制、过滤 IO 操作,或者我需要使用类似 maven-resource-plugin 的东西?

如果是这样,在tycho打包的这一步如何指定os到maven-resource-plugin运行?

1- 有没有办法使用 tycho 指定复制、过滤 IO 操作,或者我需要使用类似 maven-resource-plugin 的东西?

是的,你可以使用 maven-resource-plugin 并且它有过滤操作。

2-如果是这种情况,在第谷打包的这一步如何通过os指定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可选参数

希望这对您有所帮助。