我有需要一个库的项目。这个lib已经在本地repro中。我通过它的pom.xml
告诉项目它依赖于这个lib:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.mygui</groupId>
<artifactId>de.mygui.app.releng</artifactId>
<relativePath>../de.mygui.app.releng/pom.xml</relativePath>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>de.mygui</groupId>
<artifactId>de.mygui.map</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<dependencies>
<dependency>
<groupId>common</groupId>
<artifactId>my.util.geo</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
并且项目清单如下所示:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: gui map
Bundle-SymbolicName: de.mygui.map;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: my.util.geo;version="2.0.0"
my.util.geo
清单:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Geo
Bundle-SymbolicName: my.util.geo
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: my.util.geo
Require-Bundle: org.proj4j;bundle-version="0.1.0"
当运行父POM来编译所有内容(还有其他必需的项目)时,我收到以下错误:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: de.mygui.app.feature.feature.group 1.0.0.qualifier
[ERROR] Missing requirement: de.mygui.map 1.0.0.qualifier requires 'package my.util.geo 2.0.0' but it could not be found
[ERROR] Cannot satisfy dependency: de.mygui.app.feature.feature.group 1.0.0.qualifier depends on: de.mygui.map 0.0.0
[ERROR]
[ERROR] See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.
[ERROR] Cannot resolve dependencies of MavenProject: de.mygui:de.mygui.app.feature:1.0.0-SNAPSHOT @ /home/myuser/dev/gui/de.mygui.app.feature/pom.xml: See log for details -> [Help 1]
org.apache.maven.MavenExecutionException: Cannot resolve dependencies of MavenProject: de.mygui:de.mygui.app.feature:1.0.0-SNAPSHOT @ /home/myuser/dev/gui/de.mygui.app.feature/pom.xml
at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:100)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:274)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
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: org.eclipse.tycho.artifacts.DependencyResolutionException: Cannot resolve dependencies of MavenProject: de.mygui:de.mygui.app.feature:1.0.0-SNAPSHOT @ /home/myuser/dev/gui/de.mygui.app.feature/pom.xml
at org.eclipse.tycho.p2.resolver.P2ResolverImpl.resolveDependencies(P2ResolverImpl.java:202)
at org.eclipse.tycho.p2.resolver.P2ResolverImpl.resolveDependencies(P2ResolverImpl.java:116)
at org.eclipse.tycho.p2.resolver.P2DependencyResolver.doResolveDependencies(P2DependencyResolver.java:367)
at org.eclipse.tycho.p2.resolver.P2DependencyResolver.resolveDependencies(P2DependencyResolver.java:335)
at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject(DefaultTychoResolver.java:117)
at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:95)
... 13 more
Caused by: org.eclipse.tycho.p2.util.resolution.ResolverException: See log for details
at org.eclipse.tycho.p2.util.resolution.ProjectorResolutionStrategy.resolve(ProjectorResolutionStrategy.java:88)
at org.eclipse.tycho.p2.util.resolution.AbstractResolutionStrategy.resolve(AbstractResolutionStrategy.java:42)
at org.eclipse.tycho.p2.resolver.P2ResolverImpl.resolveDependencies(P2ResolverImpl.java:195)
... 18 more
对我而言,看起来Maven首先进入清单,然后在POM中查找其依赖关系。如您所见,我更改了my.util.geo
的版本号,以验证是否在POM之前使用了清单。即使我在清单和POM中都有相同的版本,Maven仍然无法解决依赖关系。
我该怎么做才能解决这个问题?
答案 0 :(得分:0)
事实证明,放入本地复制品的jar(mainfest
)的my.util.geo
是default manifest的maven archiver。所以我需要编辑my.util.geo
lib的构建脚本以包含所有必要的值
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-ClassPath>.</Bundle-ClassPath>
<Export-Package>my.util.geo</Export-Package>
</manifestEntries>
</archive>
</configuration>
</plugin>