Bug 865599 - maven local mode does not seem to resolve first from the m2 cache
Summary: maven local mode does not seem to resolve first from the m2 cache
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: maven
Version: rawhide
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Stanislav Ochotnicky
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 871788
TreeView+ depends on / blocked
 
Reported: 2012-10-11 21:16 UTC by Roland Grunberg
Modified: 2012-11-27 05:08 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-11-27 05:08:52 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Roland Grunberg 2012-10-11 21:16:25 UTC
When an artifact exists in both the m2 cache, and on the system, mvn-rpmbuild does not use the version in the m2 cache.

Resources :

http://rgrunber.fedorapeople.org/abc-1.0-1.fc19.noarch.rpm (rpm providing abc:abc)
http://rgrunber.fedorapeople.org/abc.tar.bz2 (project abc:abc)

Steps to reproduce :

1. yum install abc-1.0.fc19.noarch.rpm. So now there is abc:abc:1.0 on the system.
2. Extract abc.tar.bz2 and run mvn-rpmbuild clean install. Now there should be abc:abc:1.0 in the m2 cache from where the build was run.
3. Change project version to 1.1 in pom.xml and uncomment dependency on abc:abc:1.0.
4. Run mvn-rpmbuild -X -Dmaven.local.debug=true clean install 1>log1.txt 2>log2.txt

The logs (classpathElements list) should reveal that when abc:abc:1.0 was requested, abc:abc:1.0 was returned from the system repository (/usr/share/maven/repository/JPP/abc.jar), and not the local m2 cache.

Additionally, you can yum remove abc, and run the build again to confirm that the classpathElements list changes to use the artifact in the m2 cache (/path/to/build/.m2/abc/abc/1.0/abc-1.0.jar).

Have I done something weird ? It would be nice if there were a way (even if it weren't the default) to have the resolver check the m2 cache first.

Comment 1 Mikolaj Izdebski 2012-10-17 15:59:29 UTC
There is a workaround available.
Assuming you gave artifact FOO:BAR:VER stored in .m2 cache,
you can force maven to resolve it by using this custom depmap:

<dependency>
    <maven>
        <groupId>FOO</groupId>
        <artifactId>BAR</artifactId>
        <version>VER</version>
    </maven>
    <jpp>
        <groupId>../../../..</groupId>
        <artifactId>$(PWD)/.m2/FOO/BAR/VER</artifactId>
        <version>VER</version>
    </jpp>
</dependency>

Comment 2 Roland Grunberg 2012-10-18 21:10:22 UTC
There's a fix for this in rawhide (http://pkgs.fedoraproject.org/cgit/maven.git/commit/?id=9b93db7e101a6f191a5a63f468de1000204e15e9), and I've confirmed I can build Tycho with it. Artifacts seem to be resolving first from the reactor cache.

The workaround seemed pretty neat but didn't work in the case of resolving poms. This is mainly because when looking up the pom path, the groupId's '/' are replaced with '.' which breaks the path. I guess if anyone ever wanted to get this working locally, they could create symlinks to the root in %{_mavenpomdir} as 'foo-' and one in %{_datadir}/maven/repository as 'foo'. From there the gid could be set to 'foo' and the aid could be the path to the pom/jar with the extension omitted.

Comment 3 Fedora Update System 2012-10-24 12:05:29 UTC
maven-3.0.4-14.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/maven-3.0.4-14.fc17

Comment 4 Fedora Update System 2012-10-24 12:05:49 UTC
maven-3.0.4-14.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/maven-3.0.4-14.fc18

Comment 5 Fedora Update System 2012-10-24 16:17:09 UTC
Package maven-3.0.4-14.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing maven-3.0.4-14.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-16797/maven-3.0.4-14.fc18
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2012-11-09 15:53:20 UTC
maven-3.0.4-21.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/maven-3.0.4-21.fc18

Comment 7 Fedora Update System 2012-11-27 05:08:54 UTC
maven-3.0.4-21.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.