使用feature-maven-plugin时,在pom.xml中定义的版本范围未正确解析

时间:2014-07-15 04:12:13

标签: maven version

我在使用我的依赖项中定义的版本范围的features-maven-plugin时遇到了问题。

如果我不使用版本范围,它可以正常工作。

这是一个已知问题还是我做错了什么?   它说:

    -
[INFO] -- Start generating H:\WDP\workspace\com.company.ssb.pm.ilexamplebundle\target\classes\feature.xml --
[INFO]  Generating feature org.osgi.core from org.osgi:org.osgi.core:jar:4.3.1:provided
[INFO]   adding bundle org.osgi:org.osgi.core:jar:4.3.1:provided
[INFO]  Generating feature api from com.company.ssb.nbda.cpm:api:jar:0.9.1:compile
[WARNING] Unable to retrieve metadata for com.company.ssb.cpm.common:pmcore:jar:[0.1,):compile, not including dependencies for it
Downloading: http://artifacts.ijk.company.se:8081/nexus/content/groups/public/com/company/ssb/cpm/common/pmcore/[0.1,)/pmcore-[0.1,).jar

[WARNING] Unable to determine if com.company.ssb.cpm.common:pmcore:jar:[0.1,):compile is a bundle; defaulting to false
org.apache.maven.artifact.resolver.ArtifactResolutionException: Could not transfer artifact com.company.ssb.cpm.common:pmcore:jar:[0.1,) from/to artifacts (http://artifacts.ijk.company.se:8081/nexus/content/groups/public/): Illegal character in path at index 102: http://artifacts.ijk.company.se:8081/nexus/content/groups/public/com/company/ssb/cpm/common/pmcore/[0.1,)/pmcore-[0.1,).jar
  com.company.ssb.cpm.common:pmcore:jar:null

from the specified remote repositories:
  artifacts (http://artifacts.ijk.company.se:8081/nexus/content/groups/public/, releases=true, snapshots=true)

    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:232)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:164)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:555)
    at org.apache.karaf.tooling.features.GenerateFeaturesFileMojo.isBundle(GenerateFeaturesFileMojo.java:407)
    at org.apache.karaf.tooling.features.GenerateFeaturesFileMojo.writeBundle(GenerateFeaturesFileMojo.java:300)
    at org.apache.karaf.tooling.features.GenerateFeaturesFileMojo.writeBundle(GenerateFeaturesFileMojo.java:292)
    at org.apache.karaf.tooling.features.GenerateFeaturesFileMojo.writeProjectDependencyFeatures(GenerateFeaturesFileMojo.java:256)
    at org.apache.karaf.tooling.features.GenerateFeaturesFileMojo.populateProperties(GenerateFeaturesFileMojo.java:197)
    at org.apache.karaf.tooling.features.GenerateFeaturesFileMojo.execute(GenerateFeaturesFileMojo.java:172)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    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.aether.resolution.ArtifactResolutionException: Could not transfer artifact com.company.ssb.cpm.common:pmcore:jar:[0.1,) from/to artifacts (http://artifacts.ijk.company.se:8081/nexus/content/groups/public/): Illegal character in path at index 102: http://artifacts.ijk.company.se:8081/nexus/content/groups/public/com/company/ssb/cpm/common/pmcore/[0.1,)/pmcore-[0.1,).jar
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:459)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:262)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:239)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:295)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:222)
    ... 29 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact com.company.ssb.cpm.common:pmcore:jar:[0.1,) from/to artifacts (http://artifacts.ijk.company.se:8081/nexus/content/groups/public/): Illegal character in path at index 102: http://artifacts.ijk.company.se:8081/nexus/content/groups/public/com/company/ssb/cpm/common/pmcore/[0.1,)/pmcore-[0.1,).jar
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1016)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1004)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:725)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 102: http://artifacts.ijk.company.se:8081/nexus/content/groups/public/com/company/ssb/cpm/common/pmcore/[0.1,)/pmcore-[0.1,).jar
    at java.net.URI.create(URI.java:859)
    at org.apache.maven.wagon.providers.http.httpclient.client.methods.HttpGet.<init>(HttpGet.java:69)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:841)
    at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
    at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
    at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:660)
    ... 4 more
Caused by: java.net.URISyntaxException: Illegal character in path at index 102: http://artifacts.ijk.company.se:8081/nexus/content/groups/public/com/company/ssb/cpm/common/pmcore/[0.1,)/pmcore-[0.1,).jar
    at java.net.URI$Parser.fail(URI.java:2829)
    at java.net.URI$Parser.checkChars(URI.java:3002)
    at java.net.URI$Parser.parseHierarchical(URI.java:3086)
    at java.net.URI$Parser.parse(URI.java:3034)
    at java.net.URI.<init>(URI.java:595)
    at java.net.URI.create(URI.java:857)
    ... 10 more
[ERROR]  unable to find suitable bundle for artifact 'com.company.ssb.cpm.common:pmcore:jar:[0.1,):compile'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

Maven版本是3.2.2

{user home} .m2 \ repository \ com \ company \ ssb \ pm \ common \ pmcore \ 0.1.0

中有一个0.1.0版本的jar

我的pom.xml是

    ...
    <dependency>
        <groupId>com.company.ssb.nbda.pm</groupId>
        <artifactId>api</artifactId>
        <version>0.9.1</version>
    </dependency>
    ....



    ...
<plugin>
                    <groupId>org.apache.karaf.tooling</groupId>
                    <artifactId>features-maven-plugin</artifactId>
                    <version>2.3.5</version>
                    <executions>
                        <execution>
                            <id>generate-features-file</id>
                            <goals>
                                <goal>generate-features-file</goal>
                            </goals>
                            <configuration>
                                <karafVersion>2.3.5</karafVersion>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
           ...

com / company / ssb / nbda / pm / api / 0.9.1 /中的pom如下:

...
  <groupId>com.company.ssb.nbda.pm</groupId>
  <artifactId>api</artifactId>
  <version>0.9.1</version>
  <dependencies>
    <dependency>
      <groupId>com.company.ssb.pm.common</groupId>
      <artifactId>pmcore</artifactId>
      <version>[0.1,)</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.company.ssb.cil.client</groupId>
      <artifactId>service</artifactId>
      <version>[0.10,)</version>
      <scope>compile</scope>
    </dependency>
 ...

1 个答案:

答案 0 :(得分:0)

最可能是一个错误。我只是挖掘了Karaf和Maven的代码,但是在我为此设置的时间范围内找不到正确的位置,但是其他一些有趣的东西,请阅读:

我注意到你的Karaf 2.3.5使用了maven 3.0. alpha 2。因此,最有可能升级到Karaf 3.0.1将对您有所帮助,但请记住,feature-maven-plugin的命令已经改变。如果没有,请在此处提交包含此问题数据的错误报告:https://issues.apache.org/jira/browse/KARAF

我查看了GenerateFeaturesFileMojo.java

失败的方法(第407行)包含搜索META-INF/MANIFEST.MF包信息的代码。

这会在不推荐使用的方法上调用DefaultArtifactResolver.java(正如您在堆栈跟踪中看到的那样),其中url是通过ArtifactRequest.java构建的(在堆栈跟踪中看不到)

从那里继续进入解析Artifacts的maven代码,这是在Maven中运行良好的代码,所以我假设它会在这里这样做,因为Artifact信息是正确的。

所以我开始探索Karef代码来弄清楚Artifact Objects是如何构建的,但却无法轻易理解它,所以我试图弄清楚Artifacts的构建位置和注释(和代码) )那些像“@TODO:现在有效,但它应该在版本进入文物的地方修复”之类的东西。

所以,虽然这不是一个明确的答案,但如果它不是一个错误,你的方法应该有效。