Java 如何在特定目标文件中插入文件
我有一个在eclipse下开发的osgi服务器,它运行在windows、macosx和linux上。 Tycho和maven正在完美地为这些平台进行目标构建配置 现在,我需要根据最终的os+ws和arch平台在最终的.zip文件中插入startup.sh或startup.bat。 是否有类似“配置.environments.environment.os”之类的变量可以用来复制产品目标文件夹旁边的脚本文件夹,如下所示:Java 如何在特定目标文件中插入文件,java,eclipse,maven,tycho,Java,Eclipse,Maven,Tycho,我有一个在eclipse下开发的osgi服务器,它运行在windows、macosx和linux上。 Tycho和maven正在完美地为这些平台进行目标构建配置 现在,我需要根据最终的os+ws和arch平台在最终的.zip文件中插入startup.sh或startup.bat。 是否有类似“配置.environments.environment.os”之类的变量可以用来复制产品目标文件夹旁边的脚本文件夹,如下所示: delivery_folder/ ->x86_64/ ->scri
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>
maven资源插件
3.0.2
复制资源
安装
复制资源
${project.build.directory}/products/${project.artifactId}/${configuration.environments.environment.os}
剧本
真的
我想使用第谷目标环境机制
我已通过以下方式设置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>
org.eclipse.tycho
目标平台配置
${tycho.version}
linux
gtk
x86_64
win32
win32
x86
win32
win32
x86_64
马科斯
热可可
x86_64
感谢您的帮助我将使用构建配置文件来完成此任务。您可以为支持的任何平台指定配置文件,并可以选择添加
激活
:
<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>
您也可以使用PDE风格的根文件,而不是使用相当低级的
maven Resources插件
,它允许特定于平台的文件包含在eclipse存储库
(我假设是生成ZIP的打包类型):
有关详细信息,请参阅。(请注意,即将发布的版本将通过支持root.folder.
语法进一步改进Tycho中对rootfiles的支持。)
<outputDirectory>${project.build.directory}/products/${project.artifactId}/${target.os}.${target.ws}.${target.arch}</outputDirectory>
root.win32.win32.x86=rootfiles