diff --git a/0003-Implement-Java-home-resolver.patch b/0003-Implement-Java-home-resolver.patch new file mode 100644 index 0000000..6f7e347 --- /dev/null +++ b/0003-Implement-Java-home-resolver.patch @@ -0,0 +1,209 @@ +From 4114b3d2fd431c9fe82c4a0da1b44dafcf2f9c9c Mon Sep 17 00:00:00 2001 +From: Mikolaj Izdebski +Date: Wed, 5 Jun 2013 15:36:57 +0200 +Subject: [PATCH 3/3] Implement Java home resolver + +--- + .../maven/resolver/DefaultResolver.java | 1 + + .../fedoraproject/maven/resolver/DepmapReader.java | 2 +- + .../maven/resolver/JavaHomeResolver.java | 62 ++++++++++++++++++++ + .../maven/resolver/JavaHomeResolverTest.java | 68 ++++++++++++++++++++++ + .../tools-jar-depmap.xml | 17 ++++++ + 5 files changed, 149 insertions(+), 1 deletion(-) + create mode 100644 xmvn-core/src/main/java/org/fedoraproject/maven/resolver/JavaHomeResolver.java + create mode 100644 xmvn-core/src/test/java/org/fedoraproject/maven/resolver/JavaHomeResolverTest.java + create mode 100644 xmvn-core/src/test/resources/java-home-resolver-depmaps/tools-jar-depmap.xml + +diff --git a/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/DefaultResolver.java b/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/DefaultResolver.java +index c6a82ad..89ba190 100644 +--- a/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/DefaultResolver.java ++++ b/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/DefaultResolver.java +@@ -100,6 +100,7 @@ public class DefaultResolver + File root = new File( prefix ); + if ( root.isDirectory() ) + { ++ resolvers.add( new JavaHomeResolver( root, settings, logger ) ); + Resolver resolver = new SystemResolver( root, settings, logger ); + resolvers.add( new CachingResolver( resolver, logger ) ); + } +diff --git a/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/DepmapReader.java b/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/DepmapReader.java +index 69398d7..a69ec5d 100644 +--- a/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/DepmapReader.java ++++ b/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/DepmapReader.java +@@ -107,7 +107,7 @@ class DepmapReader + { + for ( String path : settings.getMetadataRepositories() ) + { +- File file = new File( path ); ++ File file = root.toPath().resolve( path ).toFile(); + + if ( file.isDirectory() ) + { +diff --git a/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/JavaHomeResolver.java b/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/JavaHomeResolver.java +new file mode 100644 +index 0000000..964b6fa +--- /dev/null ++++ b/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/JavaHomeResolver.java +@@ -0,0 +1,62 @@ ++/*- ++ * Copyright (c) 2013 Red Hat, Inc. ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++package org.fedoraproject.maven.resolver; ++ ++import static org.fedoraproject.maven.utils.FileUtils.followSymlink; ++ ++import java.io.File; ++import java.nio.file.Path; ++import java.nio.file.Paths; ++ ++import org.codehaus.plexus.logging.Logger; ++import org.fedoraproject.maven.config.ResolverSettings; ++import org.fedoraproject.maven.model.Artifact; ++ ++/** ++ * @author Mikolaj Izdebski ++ */ ++class JavaHomeResolver ++ extends AbstractResolver ++{ ++ private final DependencyMap depmap; ++ ++ public JavaHomeResolver( File root, ResolverSettings settings, Logger logger ) ++ { ++ depmap = DepmapReader.readArtifactMap( root, settings, logger ); ++ } ++ ++ @Override ++ public File resolve( Artifact requestedArtifact ) ++ { ++ for ( Artifact artifact : depmap.translate( requestedArtifact.clearVersionAndExtension() ) ) ++ { ++ artifact = artifact.copyMissing( requestedArtifact ); ++ String javaHome = System.getProperty( "java.home" ); ++ ++ if ( artifact.getGroupId().equals( "JAVA_HOME" ) && javaHome != null ) ++ { ++ Path javaHomeDir = followSymlink( new File( javaHome ) ).toPath(); ++ Path artifactPath = Paths.get( artifact.getArtifactId() + "." + artifact.getExtension() ); ++ File artifactFile = javaHomeDir.resolve( artifactPath ).toFile(); ++ artifactFile = followSymlink( artifactFile ); ++ if ( artifactFile.exists() ) ++ return artifactFile; ++ } ++ } ++ ++ return null; ++ } ++} +diff --git a/xmvn-core/src/test/java/org/fedoraproject/maven/resolver/JavaHomeResolverTest.java b/xmvn-core/src/test/java/org/fedoraproject/maven/resolver/JavaHomeResolverTest.java +new file mode 100644 +index 0000000..ff5215d +--- /dev/null ++++ b/xmvn-core/src/test/java/org/fedoraproject/maven/resolver/JavaHomeResolverTest.java +@@ -0,0 +1,68 @@ ++/*- ++ * Copyright (c) 2013 Red Hat, Inc. ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++package org.fedoraproject.maven.resolver; ++ ++import java.io.File; ++ ++import org.codehaus.plexus.PlexusTestCase; ++import org.codehaus.plexus.logging.Logger; ++import org.fedoraproject.maven.config.ResolverSettings; ++import org.fedoraproject.maven.model.Artifact; ++import org.fedoraproject.maven.utils.FileUtils; ++ ++/** ++ * @author Mikolaj Izdebski ++ */ ++public class JavaHomeResolverTest ++ extends PlexusTestCase ++{ ++ /** ++ * Test if artifacts are resolved correctly from Java home. ++ * ++ * @throws Exception ++ */ ++ public void testJavaHomeResolver() ++ throws Exception ++ { ++ ResolverSettings settings = new ResolverSettings(); ++ assertTrue( settings.getPrefixes().isEmpty() ); ++ assertTrue( settings.getMetadataRepositories().isEmpty() ); ++ settings.addPrefix( FileUtils.CWD.getAbsolutePath() ); ++ settings.addMetadataRepository( "src/test/resources/java-home-resolver-depmaps" ); ++ ++ File root = new File( settings.getPrefixes().iterator().next() ); ++ assertTrue( root.isDirectory() ); ++ JavaHomeResolver javaHomeResolver = new JavaHomeResolver( root, settings, lookup( Logger.class ) ); ++ ++ Artifact comSunToolsArtifact = new Artifact( "com.sun", "tools", "SYSTEM", "jar" ); ++ File comSunToolsFile = javaHomeResolver.resolve( comSunToolsArtifact ); ++ assertNotNull( comSunToolsFile ); ++ assertTrue( comSunToolsFile.exists() ); ++ ++ Artifact toolsArtifact = new Artifact( "JAVA_HOME", "../lib/tools", "SYSTEM", "jar" ); ++ File toolsFile = javaHomeResolver.resolve( toolsArtifact ); ++ assertNotNull( toolsFile ); ++ assertTrue( toolsFile.exists() ); ++ ++ Artifact toolzArtifact = new Artifact( "JAVA_HOME", "../lib/toolz", "SYSTEM", "jar" ); ++ File toolzFile = javaHomeResolver.resolve( toolzArtifact ); ++ assertNull( toolzFile ); ++ ++ Artifact xpp3Artifact = new Artifact( "JPP/xpp3", "xpp3", "SYSTEM", "jar" ); ++ File xpp3File = javaHomeResolver.resolve( xpp3Artifact ); ++ assertNull( xpp3File ); ++ } ++} +diff --git a/xmvn-core/src/test/resources/java-home-resolver-depmaps/tools-jar-depmap.xml b/xmvn-core/src/test/resources/java-home-resolver-depmaps/tools-jar-depmap.xml +new file mode 100644 +index 0000000..86b85c4 +--- /dev/null ++++ b/xmvn-core/src/test/resources/java-home-resolver-depmaps/tools-jar-depmap.xml +@@ -0,0 +1,17 @@ ++ ++ ++ ++ ++ ++ com.sun ++ tools ++ SYSTEM ++ ++ ++ JAVA_HOME ++ ../lib/tools ++ SYSTEM ++ ++ ++ +-- +1.8.1.4 + diff --git a/xmvn.spec b/xmvn.spec index 128dd20..4567cf4 100644 --- a/xmvn.spec +++ b/xmvn.spec @@ -1,6 +1,6 @@ Name: xmvn Version: 0.5.0 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Local Extensions for Apache Maven License: ASL 2.0 URL: http://mizdebsk.fedorapeople.org/xmvn @@ -14,6 +14,10 @@ Patch0: 0001-Be-careful-when-unboxing-Boolean-that-can-be-null.patch # in groupid Patch1: 0002-Implement-desired-handling-dots-in-JPP-groupId.patch +# from upstream commits 44d9c60 and bf7b9a7 to allow resolution +# of tools.jar without specifying system scope or systemPath +Patch2: 0003-Implement-Java-home-resolver.patch + BuildRequires: maven-local BuildRequires: beust-jcommander @@ -53,6 +57,7 @@ This package provides %{summary}. %setup -q %patch0 -p1 %patch1 -p1 +%patch2 -p1 # Add cglib test dependency as a workaround for rhbz#911365 %pom_add_dep cglib:cglib::test %{name}-core @@ -141,6 +146,9 @@ end %doc LICENSE NOTICE %changelog +* Wed Jun 5 2013 Mikolaj Izdebski - 0.5.0-5 +- Fix resolution of tools.jar + * Fri May 31 2013 Stanislav Ochotnicky - 0.5.0-4 - Fix handling of packages with dots in groupId - Previous versions also fixed bug #948731