3

我正在尝试在一个全新的系统中使用我的自定义 Maven 插件。它似乎无法解析自定义 Maven 插件使用的父 POM。

我已经尝试了几件事,但我不知所措。

任何见解将不胜感激。谢谢你。

更新

这很奇怪......这个错误只发生在我清理本地存储库时(模拟一个干净的系统,如新的开发人员或集成系统)。如果我再次立即运行“mvn -U install”命令(根本不更改命令),那么它会成功构建!

这尖叫着“传递依赖”,但我如何找到这样的违规行为?

更新

我认为这是 Maven 中的一个错误。即使它位于同一个项目中,reactor 也找不到父 POM!大家怎么看?

自定义插件 POM:

<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>my.org</groupId>
        <artifactId>parent-java-with-foundation</artifactId>
        <version>11.1.1.8-SNAPSHOT</version>
        <relativePath></relativePath>
    </parent>

    <groupId>my.org.maven</groupId>
    <artifactId>maven-plugin</artifactId>
    <version>11.1.1.8-SNAPSHOT</version>
    <packaging>maven-plugin</packaging>

</project>

错误跟踪:

[ERROR] Plugin my.org.maven:maven-plugin:11.1.1.8-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for my.org.maven:maven-plugin:jar:11.1.1.8-SNAPSHOT: Could not find artifact my.org:parent-java-with-foundation:pom:11.1.1.8-SNAPSHOT -> [Help 1] org.apache.maven.plugin.PluginResolutionException: Plugin my.org.maven:maven-plugin:11.1.1.8-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for my.org.maven:maven-plugin:jar:11.1.1.8-SNAPSHOT
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:122)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:146)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:265)
    at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:190)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecution(DefaultLifecycleExecutionPlanCalculator.java:157)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecutions(DefaultLifecycleExecutionPlanCalculator.java:144)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:121)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:134)
    at org.apache.maven.lifecycle.internal.BuilderCommon.resolveBuildPlan(BuilderCommon.java:92)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    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.ArtifactDescriptorException: Failed to read artifact descriptor for my.org.maven:maven-plugin:jar:11.1.1.8-SNAPSHOT
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:370)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:217)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:288)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:108)
    ... 25 more
Caused by: org.apache.maven.model.resolution.UnresolvableModelException: Could not find artifact my.org:parent-java-with-foundation:pom:11.1.1.8-SNAPSHOT
    at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:126)
    at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:817)
    at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:669)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:307)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:361)
    ... 28 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact my.org:parent-java-with-foundation:pom:11.1.1.8-SNAPSHOT
    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.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:122)
    ... 32 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact my.org:parent-java-with-foundation:pom:11.1.1.8-SNAPSHOT
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:449)
    ... 35 more
4

1 回答 1

0

There can be several reasons for this. If the parent POM isn't part of the reactor (= the current build) and you deleted your local cache, then Maven has to find it somewhere.

If you have a company wide repository, make sure that this version is available from there. Make especially sure that you can download SNAPSHOT versions (some repos can disable that plus you can configure Maven never to download snapshots from certain repos).

If you don't have a company wide repository, then you need to run mvn install in the parent project, first. Maven doesn't try to find missing pieces anywhere on your hard disk.

于 2013-11-07T16:31:16.937 回答