Hi,
I'm building a project using maven-local. My pom file has dependency to hamcrest-core and hamcrest-library version 1.2.1 My spec file has BuildRequires: hamcrest12
In my local box (f17) it resolved correctly. But when I try to build it in mock targeting rawhide, it always resolve to hamcrest (which is 1.1 and fail to compile) I've tried to add a depmap with -Dmaven.local.depmap.file as below, still no luck. Any one know why is that and how can I force it to reference hamcrest12 package? Thanks.
============= local dep map =================== <dependency> <maven> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core</artifactId> <version>1.2.1</version> </maven> <jpp> <groupId>JPP/hamcrest12</groupId> <artifactId>core</artifactId> <version>1.2</version> </jpp> </dependency> <dependency> <maven> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-library</artifactId> <version>1.2.1</version> </maven> <jpp> <groupId>JPP/hamcrest12</groupId> <artifactId>library</artifactId> <version>1.2</version> </jpp> </dependency>
Patrick Huang Senior Software Engineer Engineering - Internationalisation Red Hat, Asia-Pacific Pty Ltd Level 1, 193 North Quay Brisbane 4000 Office: +61 7 3514 8278 Fax: +61 7 3514 8199 IRC: pahuang github: github.com/huangp Website: www.redhat.com
I'm building a project using maven-local. My pom file has dependency to hamcrest-core and hamcrest-library version 1.2.1 My spec file has BuildRequires: hamcrest12
In my local box (f17) it resolved correctly. But when I try to build it in mock targeting rawhide, it always resolve to hamcrest (which is 1.1 and fail to compile) I've tried to add a depmap with -Dmaven.local.depmap.file as below, still no luck. Any one know why is that and how can I force it to reference hamcrest12 package? Thanks.
There are 2 reasons for that.
1. Your POM specifies version 1.2.1 of hamcrest, but in Fedora hamcrest12 has version 1.2. Quote from Java packaging guidelines: "Maven will [...] return versioned jar if it matches the version asked for in the pom file." In your case these versions don't match. You need to patch your POM file to point to the exact version available in the system if you want to use compatibility package, otherwise default system version vill be used.
2. There is a bug in hamcrest12 package. It doesn't follow packaging guidelines of compatibility packages. Quoting the guidelines: "Jar and pom files MUST be versioned". In case of hamcrest12 they are not:
$ rpm -ql hamcrest12 /usr/share/doc/hamcrest12-1.2 /usr/share/doc/hamcrest12-1.2/LICENSE.txt /usr/share/java/hamcrest12 /usr/share/java/hamcrest12/all.jar /usr/share/java/hamcrest12/core.jar /usr/share/java/hamcrest12/generator.jar /usr/share/java/hamcrest12/library.jar /usr/share/maven-fragments/hamcrest12 /usr/share/maven-poms/JPP.hamcrest12-all.pom /usr/share/maven-poms/JPP.hamcrest12-core.pom /usr/share/maven-poms/JPP.hamcrest12-generator.pom /usr/share/maven-poms/JPP.hamcrest12-library.pom
You should report this bug against hamcrest12 package.
-- Mikolaj Izdebski
Thanks Mikolaj,
I've patched my pom to use the exact version 1.2 but it still fail to resolve to hamcrest12 in rawhide. In fact hamcrest12(upstream version 1.2) is newer than hamcrest (upstream version 1.1). Shouldn't this make hamcrest obsolete? I also updated my local dependency map to use 1.2 but maven still resolves to use hamcrest. Please help thanks.
========== how I patched it ======== %pom_remove_dep org.hamcrest:hamcrest-core %pom_remove_dep org.hamcrest:hamcrest-library %pom_xpath_inject "pom:dependencies" "<dependency><groupId>org.hamcrest</groupId><artifactId>hamcrest-core</artifactId><version>1.2</version><scope>test</scope></dependency>" %pom_xpath_inject "pom:dependencies" "<dependency><groupId>org.hamcrest</groupId><artifactId>hamcrest-library</artifactId><version>1.2</version><scope>test</scope></dependency>"
Patrick Huang Senior Software Engineer Engineering - Internationalisation Red Hat
----- Original Message -----
From: "Mikolaj Izdebski" mizdebsk@redhat.com To: "Patrick Huang" pahuang@redhat.com Cc: java-devel@lists.fedoraproject.org Sent: Monday, March 4, 2013 4:38:48 PM Subject: Re: [fedora-java] hamcrest dependency in fedora rawhide
I'm building a project using maven-local. My pom file has dependency to hamcrest-core and hamcrest-library version 1.2.1 My spec file has BuildRequires: hamcrest12
In my local box (f17) it resolved correctly. But when I try to build it in mock targeting rawhide, it always resolve to hamcrest (which is 1.1 and fail to compile) I've tried to add a depmap with -Dmaven.local.depmap.file as below, still no luck. Any one know why is that and how can I force it to reference hamcrest12 package? Thanks.
There are 2 reasons for that.
1. Your POM specifies version 1.2.1 of hamcrest, but in Fedora hamcrest12 has version 1.2. Quote from Java packaging guidelines: "Maven will [...] return versioned jar if it matches the version asked for in the pom file." In your case these versions don't match. You need to patch your POM file to point to the exact version available in the system if you want to use compatibility package, otherwise default system version vill be used.
2. There is a bug in hamcrest12 package. It doesn't follow packaging guidelines of compatibility packages. Quoting the guidelines: "Jar and pom files MUST be versioned". In case of hamcrest12 they are not:
$ rpm -ql hamcrest12 /usr/share/doc/hamcrest12-1.2 /usr/share/doc/hamcrest12-1.2/LICENSE.txt /usr/share/java/hamcrest12 /usr/share/java/hamcrest12/all.jar /usr/share/java/hamcrest12/core.jar /usr/share/java/hamcrest12/generator.jar /usr/share/java/hamcrest12/library.jar /usr/share/maven-fragments/hamcrest12 /usr/share/maven-poms/JPP.hamcrest12-all.pom /usr/share/maven-poms/JPP.hamcrest12-core.pom /usr/share/maven-poms/JPP.hamcrest12-generator.pom /usr/share/maven-poms/JPP.hamcrest12-library.pom
You should report this bug against hamcrest12 package.
I've patched my pom to use the exact version 1.2 but it still fail to resolve to hamcrest12 in rawhide.
Because by patching your POM you fixed only one problem. The second one remains open.
In fact hamcrest12(upstream version 1.2) is newer than hamcrest (upstream version 1.1). Shouldn't this make hamcrest obsolete?
I agree that in generall case the newest version should be default system version. But it's really up to maintainers to decide which version of the library will be default one and which one will be compatibility package. In case of hamcrest it looks like they decided that 1.2 will be compatibility package.
I also updated my local dependency map to use 1.2 but maven still resolves to use hamcrest. Please help thanks.
It's because of the bug in hamcrest12 (#917857)
========== how I patched it ======== %pom_remove_dep org.hamcrest:hamcrest-core %pom_remove_dep org.hamcrest:hamcrest-library %pom_xpath_inject "pom:dependencies" "<dependency><groupId>org.hamcrest</groupId><artifactId>hamcrest-core</artifactId><version>1.2</version><scope>test</scope></dependency>" %pom_xpath_inject "pom:dependencies" "<dependency><groupId>org.hamcrest</groupId><artifactId>hamcrest-library</artifactId><version>1.2</version><scope>test</scope></dependency>"
This should work.
-- Mikolaj Izdebski
java-devel@lists.fedoraproject.org