← All tasks
javaapache/maven #6496Not a task: not reproduced

[MNG-5435] Project which has shared dependency with a plugin fails to recognize artifact was downloaded and fails.

envgap__apache__maven-6496

Original GitHub issue ↗Opened 2013-02-19

01 / FAILURE SIGNATURE

As reported upstream

Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact org.antlr:antlr:jar:3.4
Not a benchmark task.
  • No curated issue-specific recipe or verified environment fix is available.

02 / ENVIRONMENT RECIPE

Base commit
Not freshly verified
Manifest
pom.xml
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

apache/maven #6496 · read the original issue
**[Kirk Rasmussen](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=krasmussen)** opened **[MNG-5435](https://issues.apache.org/jira/browse/MNG-5435?redirect=false)** and commented

This is a twofer bug report :)

Issue #1:

I have included a stripped down version of an example using the maven antrun plugin to spawn the Antlr tool. For technical reasons we cannot use the native maven Antlr plugin.

If you look at the attached project you will see that Antlr is a dependency of both the antrun plugin:

```
...
<build>
  <plugins>		
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-antrun-plugin</artifactId>
        <dependencies>				
          <dependency>
          <groupId>org.antlr</groupId>
          <artifactId>antlr</artifactId>
          <version>${antlr.version}</version>
        </dependency>					
...
```

And the project itself:

```

...

<dependencies>
  <dependency>
    <groupId>org.antlr</groupId>
    <artifactId>antlr</artifactId>
   </dependency>
</dependencies>

...

```

Starting with a blank M2 local repo, and then running

$ mvn -e -X -U clean install -s settings.xml  > /tmp/maven.log

Results in failure:

Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact org.antlr:antlr:jar:3.4

However this artifact was indeed downloaded (first as a project dependency). I stepped through some of the Maven code and it appears to fail during the second run through org.sonatype.aether.impl.internal.DefaultArtifactResolver#resolve as a plugin dependency.

I strongly suspect it has to do with how org.sonatype.aether.impl.internal.EnhancedLocalRepositoryManager#find is implemented. It sees the file but it is not being tracked correctly I believe so it ignores it.

If you run the build a second time it will then succeed because the Antlr artifacts will be available as they are in the local repo from the previous run.

$ mvn -e -X -U clean install -s settings.xml  > /tmp/maven2.log

I observed the exact same problem when using the Maven enforcer plugin along with TestNG as they both depend on beanshell and with the Maven GWT plugin and GWT project dependencies.

This was discovered as an issue once we started clearing out our local repo. Once the artifacts are populated locally the issue goes away. It takes a couple of runs to get past the bogus "missing artifact" errors but after that it is ok. It's difficult to predict when it will fail w/o being intimately familiar with all plugin/project dependencies per project.

I noticed that having Antlr 3.0.4 only as plugin dependency works fine. It also works fine if it's only a project dependency. It's the combination of having it both as a plugin AND a project dependency causes this problem.

#2

My first thought to get around issue #1 was to use dependency:resolve as a pre-build step after cleaning the local repo but that doesn't full solve the problem.

Using the Mavan dependency:resolve and dependency:resolve-plugin
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]

Issue-specific recipe and runtime smoke command require review against the complete issue and repository.

Legacy reproduction is generic install-only; match the actual issue failure before admission.