Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
gradle.34548
0005-Port-to-Maven-3.3.9-and-Eclipse-Aether.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0005-Port-to-Maven-3.3.9-and-Eclipse-Aether.patch of Package gradle.34548
From d5dc17df18ae38230761b9ce9efbfdd66217ec37 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski <mizdebsk@redhat.com> Date: Mon, 6 Jul 2015 09:57:22 +0200 Subject: [PATCH 05/17] Port to Maven 3.3.9 and Eclipse Aether --- gradle/dependencies.gradle | 23 ++++++--- .../internal/maven/MavenProjectsCreator.java | 7 +-- .../action/AbstractMavenPublishAction.java | 49 +++++++++---------- .../action/LoggingMavenTransferListener.java | 6 +-- .../internal/action/MavenDeployAction.java | 31 ++++++------ .../internal/action/MavenInstallAction.java | 10 ++-- .../action/SnapshotVersionManager.java | 16 +++--- 7 files changed, 76 insertions(+), 66 deletions(-) diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 73cf0b1ee08..54dc27d7fbe 100755 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -123,12 +123,19 @@ libraries.nekohtml = dependencies.module("net.sourceforge.nekohtml:nekohtml:1.9. libraries.maven3 = dependencies.module("org.apache.maven:maven-core:${versions.maven}") { dependency "org.apache.maven:maven-settings:${versions.maven}@jar" dependency "org.apache.maven:maven-settings-builder:${versions.maven}@jar" + dependency "org.apache.maven:maven-builder-support:${versions.maven}@jar" + + //sisu: + dependency "org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.0@jar" + dependency "org.eclipse.sisu:org.eclipse.sisu.inject:0.3.0@jar" + dependency "org.sonatype.sisu:sisu-guice:3.2.5@jar" + dependency "aopalliance:aopalliance:1.0@jar" + dependency "javax.inject:javax.inject:1@jar" //plexus: dependency "org.codehaus.plexus:plexus-utils:2.1@jar" dependency "org.codehaus.plexus:plexus-interpolation:1.14@jar" dependency "org.codehaus.plexus:plexus-component-annotations:1.5.5@jar" - dependency "org.codehaus.plexus:plexus-container-default:1.5.5@jar" dependency "org.codehaus.plexus:plexus-classworlds:2.4@jar" //sonatype plexus @@ -150,14 +156,18 @@ libraries.maven3 = dependencies.module("org.apache.maven:maven-core:${versions.m dependency 'org.apache.maven.wagon:wagon-file:2.4@jar' dependency 'org.apache.maven.wagon:wagon-http:2.4@jar' dependency 'org.apache.maven.wagon:wagon-provider-api:2.4@jar' - dependency 'org.apache.maven.wagon:wagon-http-shared4:2.4@jar' + dependency 'org.apache.maven.wagon:wagon-http-shared:2.4@jar' //eather: - dependency "org.sonatype.aether:aether-api:1.13.1@jar" - dependency "org.sonatype.aether:aether-impl:1.13.1@jar" - dependency "org.sonatype.aether:aether-spi:1.13.1@jar" - dependency "org.sonatype.aether:aether-util:1.13.1@jar" - dependency 'org.sonatype.aether:aether-connector-wagon:1.13.1@jar' + dependency "org.eclipse.aether:aether-api:1.0.0.v20140518@jar" + dependency "org.eclipse.aether:aether-impl:1.0.0.v20140518@jar" + dependency "org.eclipse.aether:aether-named-locks:1.0.0.v20140518@jar" + dependency "org.eclipse.aether:aether-spi:1.0.0.v20140518@jar" + dependency "org.eclipse.aether:aether-util:1.0.0.v20140518@jar" + dependency 'org.eclipse.aether:aether-connector-basic:1.0.0.v20140518@jar' + dependency 'org.eclipse.aether:aether-transport-wagon:1.0.0.v20140518@jar' + + dependency 'org.apache.commons:commons-lang3:3.4@jar' } libraries.spock = [ diff --git a/subprojects/build-init/src/main/java/org/gradle/buildinit/plugins/internal/maven/MavenProjectsCreator.java b/subprojects/build-init/src/main/java/org/gradle/buildinit/plugins/internal/maven/MavenProjectsCreator.java index 7a858124b29..69a580405b4 100644 --- a/subprojects/build-init/src/main/java/org/gradle/buildinit/plugins/internal/maven/MavenProjectsCreator.java +++ b/subprojects/build-init/src/main/java/org/gradle/buildinit/plugins/internal/maven/MavenProjectsCreator.java @@ -25,12 +25,13 @@ import org.apache.maven.settings.Settings; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.util.DefaultRepositorySystemSession; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; import org.gradle.util.CollectionUtils; import java.io.File; @@ -55,7 +56,7 @@ public class MavenProjectsCreator { private Set<MavenProject> createNow(Settings settings, File pomFile) throws PlexusContainerException, PlexusConfigurationException, ComponentLookupException, MavenExecutionRequestPopulationException, ProjectBuildingException { ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration() .setClassWorld(new ClassWorld("plexus.core", ClassWorld.class.getClassLoader())) - .setName("mavenCore"); + .setName("mavenCore").setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true); DefaultPlexusContainer container = new DefaultPlexusContainer(containerConfiguration); ProjectBuilder builder = container.lookup(ProjectBuilder.class); diff --git a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/AbstractMavenPublishAction.java b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/AbstractMavenPublishAction.java index 9dd6e695afd..7d65dde67e3 100644 --- a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/AbstractMavenPublishAction.java +++ b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/AbstractMavenPublishAction.java @@ -18,11 +18,11 @@ package org.gradle.api.publication.maven.internal.action; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; -import org.apache.maven.repository.internal.SnapshotMetadataGeneratorFactory; -import org.apache.maven.repository.internal.VersionsMetadataGeneratorFactory; +import org.apache.maven.repository.internal.MavenRepositorySystemUtils; +import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.classworlds.ClassWorld; @@ -30,16 +30,16 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.gradle.api.GradleException; import org.gradle.internal.UncheckedException; -import org.sonatype.aether.RepositoryException; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.artifact.ArtifactType; -import org.sonatype.aether.impl.Deployer; -import org.sonatype.aether.impl.internal.DefaultDeployer; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; -import org.sonatype.aether.util.DefaultRepositorySystemSession; -import org.sonatype.aether.util.artifact.DefaultArtifact; +import org.eclipse.aether.RepositoryException; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.ArtifactType; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.NoLocalRepositoryManagerException; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.artifact.DefaultArtifact; import java.io.File; import java.io.FileReader; @@ -60,9 +60,8 @@ abstract class AbstractMavenPublishAction implements MavenPublishAction { protected AbstractMavenPublishAction(File pomFile, List<File> wagonJars) { container = newPlexusContainer(wagonJars); - session = new MavenRepositorySystemSession(); + session = MavenRepositorySystemUtils.newSession(); session.setTransferListener(new LoggingMavenTransferListener()); - session.getConfigProperties().put("maven.metadata.legacy", "true"); Model pom = parsePom(pomFile); pomArtifact = new DefaultArtifact(pom.getGroupId(), pom.getArtifactId(), "pom", pom.getVersion()).setFile(pomFile); @@ -70,7 +69,11 @@ abstract class AbstractMavenPublishAction implements MavenPublishAction { } public void setLocalMavenRepositoryLocation(File localMavenRepository) { - session.setLocalRepositoryManager(new SimpleLocalRepositoryManager(localMavenRepository)); + try { + session.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory().newInstance(session, new LocalRepository(localMavenRepository))); + } catch (NoLocalRepositoryManagerException e) { + throw UncheckedException.throwAsUncheckedException(e); + } } public void setMainArtifact(File file) { @@ -117,7 +120,11 @@ abstract class AbstractMavenPublishAction implements MavenPublishAction { classRealm.addURL(jar.toURI().toURL()); } } - return new DefaultPlexusContainer(new DefaultContainerConfiguration().setRealm(classRealm)); + ContainerConfiguration conf = new DefaultContainerConfiguration(); + conf.setClassPathScanning(PlexusConstants.SCANNING_INDEX); + conf.setAutoWiring(true); + conf.setRealm(classRealm); + return new DefaultPlexusContainer(conf); } catch (PlexusContainerException e) { throw UncheckedException.throwAsUncheckedException(e); } catch (MalformedURLException e) { @@ -127,14 +134,6 @@ abstract class AbstractMavenPublishAction implements MavenPublishAction { private RepositorySystem newRepositorySystem() { try { - DefaultDeployer deployer = (DefaultDeployer) getContainer().lookup(Deployer.class); - // This is a workaround for https://issues.gradle.org/browse/GRADLE-3324. - // Somehow the ArrayList 'result' in `org.sonatype.aether.impl.internal.Utils#sortMetadataGeneratorFactories` ends up - // being a list of nulls on windows and IBM's 1.6 JDK. - deployer.setMetadataFactories(null); - deployer.addMetadataGeneratorFactory(new VersionsMetadataGeneratorFactory()); - deployer.addMetadataGeneratorFactory(new SnapshotMetadataGeneratorFactory()); - deployer.addMetadataGeneratorFactory(snapshotVersionManager); return container.lookup(RepositorySystem.class); } catch (ComponentLookupException e) { throw UncheckedException.throwAsUncheckedException(e); diff --git a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/LoggingMavenTransferListener.java b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/LoggingMavenTransferListener.java index 5d75a16744b..46287cff506 100644 --- a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/LoggingMavenTransferListener.java +++ b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/LoggingMavenTransferListener.java @@ -18,9 +18,9 @@ package org.gradle.api.publication.maven.internal.action; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonatype.aether.transfer.AbstractTransferListener; -import org.sonatype.aether.transfer.TransferEvent; -import org.sonatype.aether.transfer.TransferEvent.RequestType; +import org.eclipse.aether.transfer.AbstractTransferListener; +import org.eclipse.aether.transfer.TransferEvent; +import org.eclipse.aether.transfer.TransferEvent.RequestType; class LoggingMavenTransferListener extends AbstractTransferListener { private static final Logger LOGGER = LoggerFactory.getLogger(LoggingMavenTransferListener.class); diff --git a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/MavenDeployAction.java b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/MavenDeployAction.java index 220e8535c18..c9891dfb583 100644 --- a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/MavenDeployAction.java +++ b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/MavenDeployAction.java @@ -19,14 +19,15 @@ import org.apache.maven.artifact.ant.RemoteRepository; import org.gradle.api.GradleException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.deployment.DeployRequest; -import org.sonatype.aether.deployment.DeploymentException; -import org.sonatype.aether.repository.Authentication; -import org.sonatype.aether.repository.Proxy; -import org.sonatype.aether.util.repository.DefaultProxySelector; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.deployment.DeploymentException; +import org.eclipse.aether.repository.Authentication; +import org.eclipse.aether.repository.Proxy; +import org.eclipse.aether.util.repository.AuthenticationBuilder; +import org.eclipse.aether.util.repository.DefaultProxySelector; import java.io.File; import java.util.Collection; @@ -57,7 +58,7 @@ public class MavenDeployAction extends AbstractMavenPublishAction { throw new GradleException("Must specify a repository for deployment"); } - org.sonatype.aether.repository.RemoteRepository aetherRepo = createRepository(gradleRepo); + org.eclipse.aether.repository.RemoteRepository aetherRepo = createRepository(gradleRepo); DeployRequest request = new DeployRequest(); request.setRepository(aetherRepo); @@ -69,22 +70,22 @@ public class MavenDeployAction extends AbstractMavenPublishAction { repositorySystem.deploy(session, request); } - private org.sonatype.aether.repository.RemoteRepository createRepository(RemoteRepository gradleRepo) { - org.sonatype.aether.repository.RemoteRepository repo = new org.sonatype.aether.repository.RemoteRepository("remote", gradleRepo.getLayout(), gradleRepo.getUrl()); + private org.eclipse.aether.repository.RemoteRepository createRepository(RemoteRepository gradleRepo) { + org.eclipse.aether.repository.RemoteRepository.Builder repoBuilder = new org.eclipse.aether.repository.RemoteRepository.Builder("remote", gradleRepo.getLayout(), gradleRepo.getUrl()); org.apache.maven.artifact.ant.Authentication auth = gradleRepo.getAuthentication(); if (auth != null) { - repo.setAuthentication(new Authentication(auth.getUserName(), auth.getPassword(), auth.getPrivateKey(), auth.getPassphrase())); + repoBuilder.setAuthentication(new AuthenticationBuilder().addUsername(auth.getUserName()).addPassword(auth.getPassword()).addPrivateKey(auth.getPrivateKey(), auth.getPassphrase()).build()); } org.apache.maven.artifact.ant.Proxy proxy = gradleRepo.getProxy(); if (proxy != null) { DefaultProxySelector proxySelector = new DefaultProxySelector(); - Authentication proxyAuth = new Authentication(proxy.getUserName(), proxy.getPassword()); + Authentication proxyAuth = new AuthenticationBuilder().addUsername(proxy.getUserName()).addPassword(proxy.getPassword()).build(); proxySelector.add(new Proxy(proxy.getType(), proxy.getHost(), proxy.getPort(), proxyAuth), proxy.getNonProxyHosts()); - repo.setProxy(proxySelector.getProxy(repo)); + repoBuilder.setProxy(proxySelector.getProxy(repoBuilder.build())); } - return repo; + return repoBuilder.build(); } } diff --git a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/MavenInstallAction.java b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/MavenInstallAction.java index 37d9dc52d5b..3b121111f2b 100644 --- a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/MavenInstallAction.java +++ b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/MavenInstallAction.java @@ -15,11 +15,11 @@ */ package org.gradle.api.publication.maven.internal.action; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.installation.InstallRequest; -import org.sonatype.aether.installation.InstallationException; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.installation.InstallRequest; +import org.eclipse.aether.installation.InstallationException; import java.io.File; import java.util.Collection; diff --git a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/SnapshotVersionManager.java b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/SnapshotVersionManager.java index 1fedf1d281a..b1ee8c09a1a 100644 --- a/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/SnapshotVersionManager.java +++ b/subprojects/maven/src/main/java/org/gradle/api/publication/maven/internal/action/SnapshotVersionManager.java @@ -16,13 +16,13 @@ package org.gradle.api.publication.maven.internal.action; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.deployment.DeployRequest; -import org.sonatype.aether.impl.MetadataGenerator; -import org.sonatype.aether.impl.MetadataGeneratorFactory; -import org.sonatype.aether.installation.InstallRequest; -import org.sonatype.aether.metadata.Metadata; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.installation.InstallRequest; +import org.eclipse.aether.metadata.Metadata; import java.util.Collection; import java.util.Collections; @@ -35,7 +35,7 @@ class SnapshotVersionManager implements MetadataGeneratorFactory, MetadataGenera } @Override - public int getPriority() { + public float getPriority() { return -100; } -- 2.17.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor