【问题标题】:How to insert a file in a specific target file如何在特定目标文件中插入文件
【发布时间】:2017-01-18 18:35:35
【问题描述】:

我有一个 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 目标环境机制。

我已经设置了第谷:

<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>

感谢您的帮助

【问题讨论】:

    标签: java eclipse maven tycho


    【解决方案1】:

    除了使用低级 maven-resoures-plugin,您还可以使用 PDE 样式的根文件,它允许将特定于平台的文件包含在 eclipse-repository 中(我假设是生成 ZIP 的包装类型):

    root.win32.win32.x86=rootfiles
    

    详情请参阅Tycho FAQ。 (请注意,即将推出的Tycho version 1.0.0 将通过支持root.folder.&lt;subfolder&gt; 语法进一步改进Tycho 对根文件的支持。)

    【讨论】:

      【解决方案2】:

      我会使用构建配置文件来完成此任务。您可以为您支持的任何平台指定配置文件,并可选择添加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>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-06
        • 1970-01-01
        相关资源
        最近更新 更多