如何在特定目标文件中插入文件
How to insert a file in a specific target file
我有一个 osgi 服务器,在 eclipse 下开发,运行在 windows、macosx 和 linux 上。
Tycho 和 maven 正在完美地为这些平台做目标构建配置。
现在,我需要根据最终的os + ws 和arch 平台在最终的.zip 文件中插入一个startup.sh 或startup.bat。
是否有类似“configuration.environments.environment.os”之类的 Maven 变量,我可以使用它来复制产品目标旁边的 scripts 文件夹像这样的文件夹:
delivery_folder/
->x86_64/
->scripts/
这是产品 pom 文件的摘录:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/products/${project.artifactId}/${configuration.environments.environment.os}</outputDirectory>
<resources>
<resource>
<directory>scripts</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
我想使用 Tycho 目标环境机制。
我已经通过以下方式设置了 Tycho:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<environments>
<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>
感谢您的帮助
我会使用构建配置文件来完成此操作。您可以为您支持的任何平台指定配置文件,并可选择添加 activation
:
<profiles>
<profile>
<id>win32-win32-x86</id>
<activation>
<os>
<arch>x86</arch>
<family>windows</family>
</os>
</activation>
<properties>
<target.os>win32</target.os>
<target.ws>win32</target.ws>
<target.arch>x86</target.arch>
</properties>
</profile>
<profile>
<id>win32-win32-x86_64</id>
<activation>
<os>
<arch>x86_64</arch>
<family>windows</family>
</os>
</activation>
<properties>
<target.os>win32</target.os>
<target.ws>win32</target.ws>
<target.arch>x86_64</target.arch>
</properties>
</profile>
<profile>
<id>gtk-linux-x86</id>
<activation>
<os>
<arch>i386</arch>
<family>unix</family>
<name>linux</name>
</os>
</activation>
<properties>
<target.os>linux</target.os>
<target.ws>gtk</target.ws>
<target.arch>x86</target.arch>
</properties>
</profile>
<profile>
<id>gtk-linux-amd64</id>
<activation>
<os>
<arch>amd64</arch>
<family>unix</family>
<name>linux</name>
</os>
</activation>
<properties>
<target.os>linux</target.os>
<target.ws>gtk</target.ws>
<target.arch>x86_64</target.arch>
</properties>
</profile>
<profile>
<id>cocoa-macosx-i386</id>
<activation>
<os>
<arch>i386</arch>
<family>unix</family>
<name>mac os x</name>
</os>
</activation>
<properties>
<target.os>macosx</target.os>
<target.ws>cocoa</target.ws>
<target.arch>x86</target.arch>
</properties>
</profile>
<profile>
<id>cocoa-macosx-x86_64</id>
<activation>
<os>
<arch>x86_64</arch>
<family>unix</family>
<name>mac os x</name>
</os>
</activation>
<properties>
<target.os>macosx</target.os>
<target.ws>cocoa</target.ws>
<target.arch>x86_64</target.arch>
</properties>
</profile>
</profiles>
这将设置三个可用于配置目录的属性:
${target.os}
${target.ws}
${target.arch}
然后在您的 maven-resources-plugin
配置中:
<outputDirectory>${project.build.directory}/products/${project.artifactId}/${target.os}.${target.ws}.${target.arch}</outputDirectory>
除了使用 low-level maven-resoures-plugin
,您还可以使用 PDE-style 根文件,它允许 platform-specific 个文件包含在 eclipse-repository
中(我假设是生成 ZIP 的包装类型):
root.win32.win32.x86=rootfiles
查看 Tycho FAQ for details. (Note that the upcoming Tycho version 1.0.0 将通过支持 root.folder.<subfolder>
语法进一步改进 Tycho 中的根文件支持。)
我有一个 osgi 服务器,在 eclipse 下开发,运行在 windows、macosx 和 linux 上。 Tycho 和 maven 正在完美地为这些平台做目标构建配置。
现在,我需要根据最终的os + ws 和arch 平台在最终的.zip 文件中插入一个startup.sh 或startup.bat。 是否有类似“configuration.environments.environment.os”之类的 Maven 变量,我可以使用它来复制产品目标旁边的 scripts 文件夹像这样的文件夹:
delivery_folder/
->x86_64/
->scripts/
这是产品 pom 文件的摘录:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/products/${project.artifactId}/${configuration.environments.environment.os}</outputDirectory>
<resources>
<resource>
<directory>scripts</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
我想使用 Tycho 目标环境机制。
我已经通过以下方式设置了 Tycho:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<environments>
<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>
感谢您的帮助
我会使用构建配置文件来完成此操作。您可以为您支持的任何平台指定配置文件,并可选择添加 activation
:
<profiles>
<profile>
<id>win32-win32-x86</id>
<activation>
<os>
<arch>x86</arch>
<family>windows</family>
</os>
</activation>
<properties>
<target.os>win32</target.os>
<target.ws>win32</target.ws>
<target.arch>x86</target.arch>
</properties>
</profile>
<profile>
<id>win32-win32-x86_64</id>
<activation>
<os>
<arch>x86_64</arch>
<family>windows</family>
</os>
</activation>
<properties>
<target.os>win32</target.os>
<target.ws>win32</target.ws>
<target.arch>x86_64</target.arch>
</properties>
</profile>
<profile>
<id>gtk-linux-x86</id>
<activation>
<os>
<arch>i386</arch>
<family>unix</family>
<name>linux</name>
</os>
</activation>
<properties>
<target.os>linux</target.os>
<target.ws>gtk</target.ws>
<target.arch>x86</target.arch>
</properties>
</profile>
<profile>
<id>gtk-linux-amd64</id>
<activation>
<os>
<arch>amd64</arch>
<family>unix</family>
<name>linux</name>
</os>
</activation>
<properties>
<target.os>linux</target.os>
<target.ws>gtk</target.ws>
<target.arch>x86_64</target.arch>
</properties>
</profile>
<profile>
<id>cocoa-macosx-i386</id>
<activation>
<os>
<arch>i386</arch>
<family>unix</family>
<name>mac os x</name>
</os>
</activation>
<properties>
<target.os>macosx</target.os>
<target.ws>cocoa</target.ws>
<target.arch>x86</target.arch>
</properties>
</profile>
<profile>
<id>cocoa-macosx-x86_64</id>
<activation>
<os>
<arch>x86_64</arch>
<family>unix</family>
<name>mac os x</name>
</os>
</activation>
<properties>
<target.os>macosx</target.os>
<target.ws>cocoa</target.ws>
<target.arch>x86_64</target.arch>
</properties>
</profile>
</profiles>
这将设置三个可用于配置目录的属性:
${target.os}
${target.ws}
${target.arch}
然后在您的 maven-resources-plugin
配置中:
<outputDirectory>${project.build.directory}/products/${project.artifactId}/${target.os}.${target.ws}.${target.arch}</outputDirectory>
除了使用 low-level maven-resoures-plugin
,您还可以使用 PDE-style 根文件,它允许 platform-specific 个文件包含在 eclipse-repository
中(我假设是生成 ZIP 的包装类型):
root.win32.win32.x86=rootfiles
查看 Tycho FAQ for details. (Note that the upcoming Tycho version 1.0.0 将通过支持 root.folder.<subfolder>
语法进一步改进 Tycho 中的根文件支持。)