【问题标题】:Running Eclipse inside Tycho using reactor artifacts使用反应器工件在 Tycho 中运行 Eclipse
【发布时间】:2014-06-09 09:58:04
【问题描述】:

有没有办法让tycho-eclipserun-plugin:eclipse-run 目标解决对当前反应器或本地存储库中工件的依赖关系。我正在尝试运行 Eclipse/CDT 无头构建应用程序作为 Tycho 构建中的一个步骤,但我不知道如何使用新构建的工具链插件填充 Eclipse 实例。

<plugin>
    <groupId>org.eclipse.tycho.extras</groupId>              
    <artifactId>tycho-eclipserun-plugin</artifactId>
    <executions>
    <execution>
        <configuration>
        <appArgLine>-application org.eclipse.cdt.managedbuilder.core.headlessbuild -import file:///...  -cleanBuild all</appArgLine>
                <repositories>
                    <repository>
                        <url>http://download.eclipse.org/releases/kepler/</url>
                        <layout>p2</layout>
                    </repository>
                </repositories>
                <dependencies>
                    ...
                    <dependency> 
                        <artifactId>my.toolchain.feature</artifactId>
                        <type>eclipse-feature</type>
                    </dependency>
        </dependencies>
            </configuration>
            <goals>
                <goal>eclipse-run</goal>
            </goals>
            <phase>test</phase>
        </execution>
    </executions>
 </plugin>

这将失败,因为托管无头构建应用程序的 Eclipse 实例中不存在我的工具链插件。当然,我可以指出一个托管插件的外部更新站点,但我希望能够使用已经在同一个反应器中构建的插件。这可能吗?

编辑:原始问题包括“或本地存储库工件”,但这不是我真正的意思。

【问题讨论】:

    标签: eclipse maven tycho


    【解决方案1】:

    不,这是不可能的。

    早期版本的 Tycho 允许将反应器中的工件用于 eclipserun-plugin,但这是 caused problems for projects which build upstream artifacts from the artifacts they used for the eclipserun-plugin,即 Eclipse 平台。因此,为了解决这个问题,eclipserun-plugin 使用的工件与 Tycho 0.17.0 中的 reactor 和 reactor 依赖项分离。

    可以想象重新允许此用例的方法,但目前尚未实现。 AFAIK 目前还没有具体的想法如何做到这一点。如果你想贡献一份,你可以file an enhancement in Tycho's issue tracker

    【讨论】:

      【解决方案2】:

      我能找到的最简单的方法是使用maven-dependency-plugin 从存储库模块复制存储库:

      <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
          <executions>
              <execution>
                  <goals>
                      <goal>unpack</goal>
                  </goals>
                  <phase>integration-test</phase>
                  <configuration>
                      <artifactItems>
                          <artifactItem>
                              <groupId>com.iar</groupId>
                              <artifactId>my.toolchain.repository</artifactId>
                              <version>0.0.1-SNAPSHOT</version>
                              <type>zip</type>
                          </artifactItem>
                      </artifactItems>
                  </configuration>
              </execution>
          </executions>
      </plugin>
      

      这将在本地复制和解压缩存储库。然后可以在调用eclipserun 目标时将其指定为存储库:

      <repository>
          <url>file://${project.build.directory}/dependency</url>
          <layout>p2</layout>
      </repository>
      

      您唯一需要知道的是“eclipse-repository”模块的 GAV,其中包含您需要的存储库。

      编辑:结果并没有像我预期的那样工作。它将从本地存储库中提取工件,而不是像我预期的那样从反应器中提取。

      【讨论】:

      • ${project.baseUri}/target 会比 file://${project.build.directory} 更便携
      • 您的解决方案是解决如何引用其他反应器构建的 p2 存储库的一般问题。第谷真的可以有更好的支持。我们(作为一个更大的组织)有一个带有Unzip Plugin 的 Nexus 来为我们解决这个问题。
      • 如果您将存储库的路径指定为 ${project.baseUri}/target/repository,我认为您可以完全跳过 maven-dependency-plugin。这也将确保您不会意外使用本地或远程存储库中的插件版本。
      • ${project.baseUri} 指的是 test 插件,而不是构建存储库的模块。还是我误会你了?同一反应堆中的另一个项目如何参考${project.baseUri}
      • ${project.baseUri} 是当前项目的位置,您可以在其中附加 /../siblingProject/target/repository 之类的字符串。但是请注意,这只适用于您在一个项目中需要该相对路径的情况。如果你把这样的配置放在父 POM 中,${project.baseUri} 将被评估到每个子项目中的不同位置。
      猜你喜欢
      • 1970-01-01
      • 2022-01-06
      • 1970-01-01
      • 1970-01-01
      • 2016-05-22
      • 1970-01-01
      • 2011-09-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多