Bug 865599 - maven local mode does not seem to resolve first from the m2 cache
maven local mode does not seem to resolve first from the m2 cache
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: maven (Show other bugs)
rawhide
All Linux
high Severity high
: ---
: ---
Assigned To: Stanislav Ochotnicky
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 871788
  Show dependency treegraph
 
Reported: 2012-10-11 17:16 EDT by Roland Grunberg
Modified: 2012-11-27 00:08 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-11-27 00:08:52 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Roland Grunberg 2012-10-11 17:16:25 EDT
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 11:59:29 EDT
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 17:10:22 EDT
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 08:05:29 EDT
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 08:05:49 EDT
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 12:17:09 EDT
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 10:53:20 EST
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 00:08:54 EST
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.