,然后我的构建失败,因为无法解决我的依赖性.我想念什么吗?这是因为为目标平台配置配置了p2解析程序吗?解决方案实际上看来您是正确的.首先,创建目标定义文件(.target)并将其放入Maven项目中,请参阅此处的目标示例: https://github.com/eclipsesource/com.eclipsesource.tycho.aspectj.demo/blob/master/platform/indigo.target您需要使用构建助手将.target文件附加到工件:<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.3</version> <executions> <execution> <id>attach-artifacts</id> <phase>package</phase> <goals> <goal>attach-artifact</goal> </goals> <configuration> <artifacts> <artifact> <file>indigo.target</file> <type>target</type> <classifier>indigo</classifier> </artifact> </artifacts> </configuration> </execution> </executions></plugin>(来自 https://github.com/eclipsesource/com.eclipsesource.tycho.aspectj.demo/blob/master/platform/pom.xml )然后,在使用该目标定义文件的父POM或插件项目中,您需要配置target-platform-configuration Maven插件的"target",例如:<plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho-version}</version> <configuration> <resolver>p2</resolver> <ignoreTychoRepositories>true</ignoreTychoRepositories> <target> <artifact> <groupId>com.eclipsesource.sandbox.weaving.demo</groupId> <artifactId>com.eclipsesource.sandbox.weaving.demo.platform</artifactId> <version>0.1.0-SNAPSHOT</version> <classifier>indigo</classifier> </artifact> </target> <environments> <environment> <os>${build.os}</os> <ws>${build.ws}</ws> <arch>${build.arch}</arch> </environment> </environments> </configuration></plugin>(取自 https://github.com/eclipsesource/com.eclipsesource.tycho.aspectj.demo/blob/master/releng/pom.xml )然后,您的项目应使用Tycho很好地构建. :-)如果您的.target引用了远程p2存储库,而尚未在p2捆绑池中,则将自动下载必要的工件.祝你好运! 已知问题: [WARNING] Target location type: Profile is not supported从Tycho 0.12.0开始,这意味着"Eclipse安装"目标源类型不能与第谷(还?)以及目录"和功能"一起使用.解决方案:使用更新站点"目标源.如果您还没有更新站点,这里是从Eclipse(或从包含捆绑包的任何文件夹中)生成更新站点的方法:/opt/eclipse_rcp/eclipse -consolelog -nosplash -verbose \ -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \ -metadataRepository file:/home/ceefour/p2/bonita/ \ -artifactRepository file:/home/ceefour/p2/bonita/ \ -source /home/ceefour/BOS-5.5.1/studio/ \ -publishArtifacts注意:将/opt/eclipse_rcp更改为您自己的Eclipse SDK安装 metadataRepository和artifactRepository是将在其中创建新更新站点的文件夹来源是-您猜中了-包含原始捆绑软件的文件夹/安装程序I am trying to get a test feature project building with Tycho, but it fails to resolve dependencies listed in my pom from the Maven central repository that is listed in my parent pom. Here is the relevant part from my parent pom: <properties> <tycho-version>0.12.0</tycho-version> </properties> <repositories> <repository> <id>helios</id> <layout>p2</layout> <url>http://download.eclipse.org/releases/helios/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <name>Maven Plugin Repository</name> <url>http://repo1.maven.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <updatePolicy>never</updatePolicy> </releases> </pluginRepository> </pluginRepositories> <build> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-maven-plugin</artifactId> <version>${tycho-version}</version> <extensions>true</extensions> </plugin> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho-version}</version> <configuration> <pomDependencies>consider</pomDependencies> <resolver>p2</resolver> <environments> <environment> <os>linux</os> <ws>gtk</ws> <arch>x86_64</arch> </environment> <environment> <os>win32</os> <ws>win32</ws> <arch>x86</arch> </environment> </environments> </configuration> </plugin> </plugins> </build>and here my feature pom: <modelVersion>4.0.0</modelVersion> <parent> <artifactId>parent</artifactId> <groupId>com.example</groupId> <version>1.0.0-SNAPSHOT</version> </parent> <groupId>com.example</groupId> <artifactId>com.example.testing.feature</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>eclipse-feature</packaging> <dependencyManagement> <dependencies> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.8.5</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> </dependency> </dependencies>when I run mvn clean package on my feature project, I get the following:[INFO] Adding repository http://download.eclipse.org/releases/helios/[INFO] Adding repository http://download.eclipse.org/releases/helios/[DEBUG] Added p2 repository helios (http://download.eclipse.org/releases/helios/)[DEBUG] Ignoring Maven repository central (http://repo1.maven.org/maven2)and then my build fails, because my dependency cannot be resolved. Am I missing something? Is this because of the p2 resolver configured for target-platform-configuration? 解决方案 Indeed it seems you are correct.First, create a Target Definition file (.target) and put it inside a Maven project, see here for example target: https://github.com/eclipsesource/com.eclipsesource.tycho.aspectj.demo/blob/master/platform/indigo.targetYou need to attach the .target file to the artifact, using the build helper:<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.3</version> <executions> <execution> <id>attach-artifacts</id> <phase>package</phase> <goals> <goal>attach-artifact</goal> </goals> <configuration> <artifacts> <artifact> <file>indigo.target</file> <type>target</type> <classifier>indigo</classifier> </artifact> </artifacts> </configuration> </execution> </executions></plugin>(from https://github.com/eclipsesource/com.eclipsesource.tycho.aspectj.demo/blob/master/platform/pom.xml )Then, in the parent POM or the plug-in projects that use that target definition file, you need to configure the "target" of target-platform-configuration Maven plugin, for example:<plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho-version}</version> <configuration> <resolver>p2</resolver> <ignoreTychoRepositories>true</ignoreTychoRepositories> <target> <artifact> <groupId>com.eclipsesource.sandbox.weaving.demo</groupId> <artifactId>com.eclipsesource.sandbox.weaving.demo.platform</artifactId> <version>0.1.0-SNAPSHOT</version> <classifier>indigo</classifier> </artifact> </target> <environments> <environment> <os>${build.os}</os> <ws>${build.ws}</ws> <arch>${build.arch}</arch> </environment> </environments> </configuration></plugin>(taken from https://github.com/eclipsesource/com.eclipsesource.tycho.aspectj.demo/blob/master/releng/pom.xml )Then your project(s) should build very nicely using Tycho. :-) If your .target references remote p2 repositories and not already in the p2 bundle pool, the necessary artifacts will be downloaded automatically.Good luck!Known Issue:[WARNING] Target location type: Profile is not supportedAs of Tycho 0.12.0, It means the "Eclipse Installation" target source type cannot be used with Tycho (yet?), along with "Directory" and "Features".Solution: Use the "Update Site" target source.If you don't have yet an update site, here's to generate an update site from an Eclipse (or from any folder containing bundles, for that matter):/opt/eclipse_rcp/eclipse -consolelog -nosplash -verbose \ -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \ -metadataRepository file:/home/ceefour/p2/bonita/ \ -artifactRepository file:/home/ceefour/p2/bonita/ \ -source /home/ceefour/BOS-5.5.1/studio/ \ -publishArtifactsNote:change /opt/eclipse_rcp to your own Eclipse SDK installationmetadataRepository and artifactRepository is the folder where the new update site will be createdsource is --you guessed it-- the folder/installation containing the original bundles 这篇关于无法解决Tycho项目中的Mockito依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-21 14:00