On 23/08/2013, at 2:47 AM, johnrengelman <john.r.engel...@gmail.com> wrote:

> I've started looking at a fix for  GRADLE-2034
> <http://issues.gradle.org/browse/GRADLE-2034>   with respect to mavenLocal()
> having artifact POMs but not the corresponding artifact. It appears the
> Maven does this a lot. I've been seeing it anytime I execute a 'mvn install'
> on the same machine that I run Gradle builds on (totally prevents our CI
> server being used for both Maven and Gradle).
> 
> This is my plan to fix:
> 1) Create a new 'DefaultMavenLocalArtifactRespository' extending from
> 'DefaultMavenArtifactRespository'
> 2) Override the 'createRealResolver' method to return a new
> 'MavenLocalResolver' class
> 3) 'MavenLocalResolver' extends 'MavenResolver' and overrides the
> 'getDependency' method.
> 4) 'MavenLocalResolve.getDependency' delegates to 'MavenResolver' for
> snapshot behavior, otherwise..
> 5) Implement a new method 'resolveIfArtifactPresent' that upon 'ivyRef !=
> null', it calls the 'findAnyArtifact' method in 'ExternalResourceResolver'
> and only resolves the artifact if the return is non-null
> 
> I've implemented this fix locally and it appears to the solve the issue and
> allow the mavenLocal resolve to fail-over to the next repository when it
> finds a POM but no artifact. I'm implement some tests around these scenarios
> now...I suspect a bunch of integration tests will break because they create
> a Pom file test test resolution but not an artifact.
> 
> Does this sound like a good plan for fixing the bug?

Thanks for tackling this bug.

Your plan sounds good. I would probably get rid of step 4, as I don't think 
there's any difference between a snapshot and a release as far as this bug goes 
- it affects anything that may have come from a remote repository.

I'd also probably do step 5 only if the packaging is not 'pom'. If we find a 
pom whose packaging is 'pom', then we should probably use it.

One question is what happens if I manually configure a `maven()` repository to 
point at the m2 cache? Or, if I manually configure a `mavenLocal()` so that it 
no longer points at the m2 cache?

Possibly we want to decide whether to use the 'cache' (the new) or 'repository' 
(the current) behaviour based on whether a repository points at the m2 cache, 
regardless of how it ended up pointing there.


--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com

Join us at the Gradle eXchange 2013, Oct 28th in London, UK: 
http://skillsmatter.com/event/java-jee/gradle-exchange-2013



Reply via email to