【发布时间】:2016-06-01 22:58:36
【问题描述】:
我正在处理重组我们的 Maven 构建流程以在我们所有项目之间共享公共项目的问题,但我无法让它工作。
到目前为止,我们有五个 GUI(带有 JavaFX 的 RCP E4),总共使用了 30 个库。这些部分是我们的(源代码)和第 3 方(罐子)。每个 GUI 都有自己的(工作的)Maven 构建过程。每个 GUI 都有自己的 Git,其中包含编译所需的每个库的副本。为了让您了解依赖项的外观(只有几个 GUI 和几个常见的库):
现在我想摆脱这些项目中的冗余。正如我所说,每个 GUI 都有自己的 Git 和所需公共项目的自己的副本(!)。我已经为公共库创建了 Git 来分离它们。现在我的问题来了。到目前为止,这些常见项目中的每一个都有自己的pom.xml,我需要在其中指定一个父项。这是一个例子pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>gui.a.e4</groupId>
<artifactId>gui.a.e4.app.releng</artifactId>
<relativePath>../gui.a.e4.app.releng/pom.xml</relativePath>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>gui.a.e4</groupId>
<artifactId>common.project.x</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
起初我试图将common.project.x 包含在gui.b.e4 中,导致以下错误:
[INFO] Scanning for projects...
[ERROR] Internal error: java.lang.RuntimeException: Could not resolve target platform specification artifact gui.a:gui.a.app.target:target:1.0.0-SNAPSHOT -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Could not resolve target platform specification artifact gui.a:gui.a.app.target:target:1.0.0-SNAPSHOT
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.RuntimeException: Could not resolve target platform specification artifact gui.a:gui.a.app.target:target:1.0.0-SNAPSHOT
at org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader.addTargetArtifact(DefaultTargetPlatformConfigurationReader.java:389)
at org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader.setTarget(DefaultTargetPlatformConfigurationReader.java:342)
at org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader.getTargetPlatformConfiguration(DefaultTargetPlatformConfigurationReader.java:75)
at org.eclipse.tycho.core.resolver.DefaultTychoResolver.setupProject(DefaultTychoResolver.java:86)
at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:90)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:274)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
... 11 more
[ERROR]
这个错误是由于 Maven 试图找到 common.project.x 的父级并尝试解决它以及在这种情况下需要创建目标平台的父级的父级(一些 RCP E4 特定的东西)。我第一次尝试解决这个问题是从pom.xml 中删除父级。因此,当我没有在 common.project.x 中指定父级时,gui.a.e4 的构建会抱怨:
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project auv.e4:art.util.geo:1.0.0-SNAPSHOT (/home/mhoffmann/apps/workspace_rcp_gui/art.util.geo.bundle/pom.xml) has 1 error
[ERROR] Unknown packaging: eclipse-plugin @ line 8, column 14
[ERROR]
如果我之后将包装类型更改为pom 其他项目找不到这个项目:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: gui.a.e4.application 1.0.0.qualifier
[ERROR] Missing requirement: common.project.y 1.0.0.qualifier requires 'bundle common.project.x 0.0.0' but it could not be found
[ERROR] Cannot satisfy dependency: gui.a.e4.application 1.0.0.qualifier depends on: bundle common.project.y 0.0.0
[ERROR]
这是用于构建我们的 GUI 之一的 maven XML,它们都是相同的(项目名称除外)
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<name>gui.a - releng</name>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<groupId>gui.a</groupId>
<artifactId>gui.a.app.releng</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<tycho-version>0.23.1</tycho-version>
<junit-version>4.11</junit-version>
<mockito-version>1.8.4</mockito-version>
<platform-version>4.2</platform-version>
<efx-version>1.0.0</efx-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<show-eclipse-log>true</show-eclipse-log>
</properties>
<modules>
<module>../gui.a.app</module>
<module>../gui.a.app.feature</module>
<module>../gui.a.app.product</module>
<module>../gui.a.specific.project.a</module>
<module>../gui.a.specific.project.b</module>
<module>../common.project.a</module>
<module>../common.project.b</module>
</modules>
<pluginRepositories>
<pluginRepository>
<id>tycho</id>
<url>http://repository.sonatype.org/content/groups/sonatype-public-grid</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<!-- build plugins -->
<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>
<target>
<artifact>
<groupId>gui.a</groupId>
<artifactId>gui.a.app.target</artifactId>
<version>1.0.0-SNAPSHOT</version>
</artifact>
</target>
<resolver>p2</resolver>
<pomDependencies>consider</pomDependencies>
<environments>
<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>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
<!-- defines the default settings for the used plugins -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
<extraClasspathElements>
<extraClasspathElement>
<groupId>javafx</groupId>
<artifactId>javafx.mvn</artifactId>
<version>2.2.0-SNAPSHOT</version>
</extraClasspathElement>
</extraClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>plugin-source</id>
<goals>
<goal>plugin-source</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
我也不知道常见项目的 POM 应该是什么样子或做什么。我对 Maven 了解不多,仅适用于调整现有脚本以包含更多 common.projects :-)。到目前为止,我不知道我应该改变什么才能使其正常工作。请帮助我,Maven让我发疯。 :-)
【问题讨论】:
标签: maven eclipse-rcp tycho e4