569 lines
26 KiB
Diff
569 lines
26 KiB
Diff
From 34b37637bd469621bb3eadfdf5fb856a806722df Mon Sep 17 00:00:00 2001
|
|
From: Michael Simacek <msimacek@redhat.com>
|
|
Date: Mon, 2 Oct 2017 12:01:09 +0300
|
|
Subject: [PATCH] Port to Gradle 4.2
|
|
|
|
---
|
|
libs/gradle-core-api/pom.xml | 32 ++++++
|
|
libs/gradle-logging/pom.xml | 32 ++++++
|
|
libs/gradle-model-core/pom.xml | 32 ++++++
|
|
libs/pom.xml | 3 +
|
|
xmvn-connector-gradle/pom.xml | 15 +++
|
|
.../xmvn/connector/gradle/GradleResolver.java | 119 ++++++++++++++-------
|
|
.../xmvn/connector/gradle/XMvnGradlePlugin.java | 16 +--
|
|
.../xmvn/connector/gradle/XMvnInstallTask.java | 22 +++-
|
|
xmvn-parent/pom.xml | 17 ++-
|
|
9 files changed, 235 insertions(+), 53 deletions(-)
|
|
create mode 100644 libs/gradle-core-api/pom.xml
|
|
create mode 100644 libs/gradle-logging/pom.xml
|
|
create mode 100644 libs/gradle-model-core/pom.xml
|
|
|
|
diff --git a/libs/gradle-core-api/pom.xml b/libs/gradle-core-api/pom.xml
|
|
new file mode 100644
|
|
index 00000000..7b3d68d5
|
|
--- /dev/null
|
|
+++ b/libs/gradle-core-api/pom.xml
|
|
@@ -0,0 +1,32 @@
|
|
+<?xml version="1.0" encoding="US-ASCII"?>
|
|
+<!--
|
|
+ ! Copyright (c) 2016-2017 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.
|
|
+ `-->
|
|
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
|
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
+ <modelVersion>4.0.0</modelVersion>
|
|
+ <parent>
|
|
+ <groupId>org.fedoraproject.xmvn</groupId>
|
|
+ <artifactId>libs</artifactId>
|
|
+ <version>3.0.0</version>
|
|
+ <relativePath>..</relativePath>
|
|
+ </parent>
|
|
+ <groupId>org.gradle</groupId>
|
|
+ <artifactId>gradle-core-api</artifactId>
|
|
+ <version>${gradleVersion}</version>
|
|
+ <name>Gradle core API module</name>
|
|
+</project>
|
|
diff --git a/libs/gradle-logging/pom.xml b/libs/gradle-logging/pom.xml
|
|
new file mode 100644
|
|
index 00000000..d2dec7c1
|
|
--- /dev/null
|
|
+++ b/libs/gradle-logging/pom.xml
|
|
@@ -0,0 +1,32 @@
|
|
+<?xml version="1.0" encoding="US-ASCII"?>
|
|
+<!--
|
|
+ ! Copyright (c) 2016-2017 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.
|
|
+ `-->
|
|
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
|
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
+ <modelVersion>4.0.0</modelVersion>
|
|
+ <parent>
|
|
+ <groupId>org.fedoraproject.xmvn</groupId>
|
|
+ <artifactId>libs</artifactId>
|
|
+ <version>3.0.0</version>
|
|
+ <relativePath>..</relativePath>
|
|
+ </parent>
|
|
+ <groupId>org.gradle</groupId>
|
|
+ <artifactId>gradle-logging</artifactId>
|
|
+ <version>${gradleVersion}</version>
|
|
+ <name>Gradle logging module</name>
|
|
+</project>
|
|
diff --git a/libs/gradle-model-core/pom.xml b/libs/gradle-model-core/pom.xml
|
|
new file mode 100644
|
|
index 00000000..f841b960
|
|
--- /dev/null
|
|
+++ b/libs/gradle-model-core/pom.xml
|
|
@@ -0,0 +1,32 @@
|
|
+<?xml version="1.0" encoding="US-ASCII"?>
|
|
+<!--
|
|
+ ! Copyright (c) 2016-2017 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.
|
|
+ `-->
|
|
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
|
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
+ <modelVersion>4.0.0</modelVersion>
|
|
+ <parent>
|
|
+ <groupId>org.fedoraproject.xmvn</groupId>
|
|
+ <artifactId>libs</artifactId>
|
|
+ <version>3.0.0</version>
|
|
+ <relativePath>..</relativePath>
|
|
+ </parent>
|
|
+ <groupId>org.gradle</groupId>
|
|
+ <artifactId>gradle-model-core</artifactId>
|
|
+ <version>${gradleVersion}</version>
|
|
+ <name>Gradle model-core module</name>
|
|
+</project>
|
|
diff --git a/libs/pom.xml b/libs/pom.xml
|
|
index 2b31c5d0..fc29e359 100644
|
|
--- a/libs/pom.xml
|
|
+++ b/libs/pom.xml
|
|
@@ -37,8 +37,11 @@
|
|
<module>gradle-base-services</module>
|
|
<module>gradle-base-services-groovy</module>
|
|
<module>gradle-core</module>
|
|
+ <module>gradle-core-api</module>
|
|
+ <module>gradle-model-core</module>
|
|
<module>gradle-dependency-management</module>
|
|
<module>gradle-resources</module>
|
|
+ <module>gradle-logging</module>
|
|
</modules>
|
|
<dependencies>
|
|
<dependency>
|
|
diff --git a/xmvn-connector-gradle/pom.xml b/xmvn-connector-gradle/pom.xml
|
|
index b433e5dd..f18a285e 100644
|
|
--- a/xmvn-connector-gradle/pom.xml
|
|
+++ b/xmvn-connector-gradle/pom.xml
|
|
@@ -54,11 +54,21 @@
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.gradle</groupId>
|
|
+ <artifactId>gradle-core-api</artifactId>
|
|
+ <scope>provided</scope>
|
|
+ </dependency>
|
|
+ <dependency>
|
|
+ <groupId>org.gradle</groupId>
|
|
<artifactId>gradle-core</artifactId>
|
|
<scope>provided</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.gradle</groupId>
|
|
+ <artifactId>gradle-model-core</artifactId>
|
|
+ <scope>provided</scope>
|
|
+ </dependency>
|
|
+ <dependency>
|
|
+ <groupId>org.gradle</groupId>
|
|
<artifactId>gradle-dependency-management</artifactId>
|
|
<scope>provided</scope>
|
|
</dependency>
|
|
@@ -68,6 +78,11 @@
|
|
<scope>provided</scope>
|
|
</dependency>
|
|
<dependency>
|
|
+ <groupId>org.gradle</groupId>
|
|
+ <artifactId>gradle-logging</artifactId>
|
|
+ <scope>provided</scope>
|
|
+ </dependency>
|
|
+ <dependency>
|
|
<groupId>org.apache.ivy</groupId>
|
|
<artifactId>ivy</artifactId>
|
|
<scope>provided</scope>
|
|
diff --git a/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/GradleResolver.java b/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/GradleResolver.java
|
|
index a81c5bc0..6305aa86 100644
|
|
--- a/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/GradleResolver.java
|
|
+++ b/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/GradleResolver.java
|
|
@@ -18,41 +18,47 @@ package org.fedoraproject.xmvn.connector.gradle;
|
|
import java.nio.file.Path;
|
|
import java.util.Collections;
|
|
import java.util.LinkedHashSet;
|
|
+import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
+import org.gradle.api.artifacts.ComponentMetadataSupplier;
|
|
import org.gradle.api.artifacts.ModuleVersionIdentifier;
|
|
+import org.gradle.api.artifacts.component.ComponentArtifactIdentifier;
|
|
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
|
|
+import org.gradle.api.internal.artifacts.ImmutableModuleIdentifierFactory;
|
|
import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ConfiguredModuleComponentRepository;
|
|
import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ModuleComponentRepositoryAccess;
|
|
import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.DescriptorParseContext;
|
|
-import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.GradlePomModuleDescriptorParser;
|
|
import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.MetaDataParser;
|
|
-import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.DefaultVersionComparator;
|
|
-import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.DefaultVersionSelectorScheme;
|
|
+import org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvableArtifact;
|
|
import org.gradle.api.internal.artifacts.repositories.AbstractArtifactRepository;
|
|
import org.gradle.api.internal.artifacts.repositories.ResolutionAwareRepository;
|
|
+import org.gradle.api.internal.artifacts.repositories.resolver.MetadataFetchingCost;
|
|
import org.gradle.api.internal.component.ArtifactType;
|
|
-import org.gradle.internal.component.external.model.DefaultMavenModuleResolveMetaData;
|
|
-import org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetaData;
|
|
-import org.gradle.internal.component.external.model.ModuleComponentResolveMetaData;
|
|
-import org.gradle.internal.component.external.model.MutableModuleComponentResolveMetaData;
|
|
-import org.gradle.internal.component.model.ComponentArtifactMetaData;
|
|
+import org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata;
|
|
+import org.gradle.internal.component.external.model.DefaultMutableMavenModuleResolveMetadata;
|
|
+import org.gradle.internal.component.external.model.FixedComponentArtifacts;
|
|
+import org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata;
|
|
+import org.gradle.internal.component.external.model.ModuleComponentResolveMetadata;
|
|
+import org.gradle.internal.component.external.model.MutableMavenModuleResolveMetadata;
|
|
+import org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata;
|
|
+import org.gradle.internal.component.model.ComponentArtifactMetadata;
|
|
import org.gradle.internal.component.model.ComponentOverrideMetadata;
|
|
-import org.gradle.internal.component.model.ComponentResolveMetaData;
|
|
-import org.gradle.internal.component.model.ComponentUsage;
|
|
+import org.gradle.internal.component.model.ComponentResolveMetadata;
|
|
import org.gradle.internal.component.model.DefaultIvyArtifactName;
|
|
-import org.gradle.internal.component.model.DependencyMetaData;
|
|
+import org.gradle.internal.component.model.DependencyMetadata;
|
|
import org.gradle.internal.component.model.IvyArtifactName;
|
|
import org.gradle.internal.component.model.ModuleSource;
|
|
import org.gradle.internal.resolve.ArtifactResolveException;
|
|
import org.gradle.internal.resolve.ModuleVersionResolveException;
|
|
import org.gradle.internal.resolve.result.BuildableArtifactResolveResult;
|
|
import org.gradle.internal.resolve.result.BuildableArtifactSetResolveResult;
|
|
+import org.gradle.internal.resolve.result.BuildableComponentArtifactsResolveResult;
|
|
import org.gradle.internal.resolve.result.BuildableModuleComponentMetaDataResolveResult;
|
|
import org.gradle.internal.resolve.result.BuildableModuleVersionListingResolveResult;
|
|
-import org.gradle.internal.resource.local.DefaultLocallyAvailableExternalResource;
|
|
-import org.gradle.internal.resource.local.DefaultLocallyAvailableResource;
|
|
+import org.gradle.internal.resource.local.FileResourceRepository;
|
|
import org.gradle.internal.resource.local.LocallyAvailableExternalResource;
|
|
+import org.gradle.internal.resource.metadata.DefaultExternalResourceMetaData;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@@ -72,6 +78,21 @@ public class GradleResolver
|
|
implements ResolutionAwareRepository, ConfiguredModuleComponentRepository, ModuleComponentRepositoryAccess,
|
|
DescriptorParseContext
|
|
{
|
|
+ public GradleResolver( MetaDataParser<MutableMavenModuleResolveMetadata> pomParser,
|
|
+ ImmutableModuleIdentifierFactory moduleIdentifierFactory,
|
|
+ FileResourceRepository fileRepository )
|
|
+ {
|
|
+ this.pomParser = pomParser;
|
|
+ this.moduleIdentifierFactory = moduleIdentifierFactory;
|
|
+ this.fileRepository = fileRepository;
|
|
+ }
|
|
+
|
|
+ private MetaDataParser<MutableMavenModuleResolveMetadata> pomParser;
|
|
+
|
|
+ private ImmutableModuleIdentifierFactory moduleIdentifierFactory;
|
|
+
|
|
+ private FileResourceRepository fileRepository;
|
|
+
|
|
private final Logger logger = LoggerFactory.getLogger( GradleResolver.class );
|
|
|
|
static class LazyLocatorProvider
|
|
@@ -135,17 +156,17 @@ public class GradleResolver
|
|
}
|
|
|
|
@Override
|
|
- public void listModuleVersions( DependencyMetaData arg0, BuildableModuleVersionListingResolveResult arg1 )
|
|
+ public void listModuleVersions( DependencyMetadata arg0, BuildableModuleVersionListingResolveResult arg1 )
|
|
{
|
|
logger.debug( "listModuleVersions() called, but it is NOT IMPLEMENTED" );
|
|
}
|
|
|
|
@Override
|
|
- public void resolveArtifact( ComponentArtifactMetaData artifact, ModuleSource module,
|
|
+ public void resolveArtifact( ComponentArtifactMetadata artifact, ModuleSource module,
|
|
BuildableArtifactResolveResult result )
|
|
{
|
|
ModuleVersionIdentifier moduleId =
|
|
- ( (DefaultModuleComponentArtifactMetaData) artifact ).toArtifactIdentifier().getModuleVersionIdentifier();
|
|
+ ( (DefaultModuleComponentArtifactMetadata) artifact ).toArtifactIdentifier().getModuleVersionIdentifier();
|
|
String groupId = moduleId.getGroup();
|
|
String artifactId = artifact.getName().getName();
|
|
String extension = artifact.getName().getExtension();
|
|
@@ -180,11 +201,9 @@ public class GradleResolver
|
|
{
|
|
logger.debug( "Found Maven POM: {}", pomPath );
|
|
|
|
- MetaDataParser<DefaultMavenModuleResolveMetaData> parser =
|
|
- new GradlePomModuleDescriptorParser( new DefaultVersionSelectorScheme( new DefaultVersionComparator() ) );
|
|
- MutableModuleComponentResolveMetaData metaData = parser.parseMetaData( this, pomPath.toFile() );
|
|
+ MutableModuleComponentResolveMetadata metaData = pomParser.parseMetaData( this, pomPath.toFile() );
|
|
|
|
- result.resolved( metaData );
|
|
+ result.resolved( metaData.asImmutable() );
|
|
return;
|
|
}
|
|
else
|
|
@@ -204,9 +223,11 @@ public class GradleResolver
|
|
if ( path != null )
|
|
{
|
|
logger.debug( "Artifact {} found, returning minimal model", artifact3 );
|
|
- MutableModuleComponentResolveMetaData metaData =
|
|
- new DefaultMavenModuleResolveMetaData( id, request.getArtifacts() );
|
|
- result.resolved( metaData );
|
|
+ ModuleVersionIdentifier mvi =
|
|
+ moduleIdentifierFactory.moduleWithVersion( id.getGroup(), id.getModule(), id.getVersion() );
|
|
+ MutableModuleComponentResolveMetadata metaData =
|
|
+ new DefaultMutableMavenModuleResolveMetadata( mvi, id, request.getArtifacts() );
|
|
+ result.resolved( metaData.asImmutable() );
|
|
return;
|
|
}
|
|
}
|
|
@@ -224,24 +245,15 @@ public class GradleResolver
|
|
|
|
if ( artifactSet.isEmpty() )
|
|
{
|
|
- artifactSet.add( new DefaultIvyArtifactName( id.getModule(), "jar", "jar",
|
|
- Collections.<String, String>emptyMap() ) );
|
|
+ artifactSet.add( new DefaultIvyArtifactName( id.getModule(), "jar", "jar", null ) );
|
|
}
|
|
|
|
return artifactSet;
|
|
}
|
|
|
|
@Override
|
|
- public void resolveModuleArtifacts( ComponentResolveMetaData component, ComponentUsage usage,
|
|
- BuildableArtifactSetResolveResult result )
|
|
- {
|
|
- result.resolved( Collections.singleton( ( (ModuleComponentResolveMetaData) component ).artifact( "jar", "jar",
|
|
- null ) ) );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void resolveModuleArtifacts( ComponentResolveMetaData component, ArtifactType type,
|
|
- BuildableArtifactSetResolveResult result )
|
|
+ public void resolveArtifactsWithType( ComponentResolveMetadata component, ArtifactType type,
|
|
+ BuildableArtifactSetResolveResult result )
|
|
{
|
|
if ( type != ArtifactType.MAVEN_POM )
|
|
{
|
|
@@ -250,15 +262,22 @@ public class GradleResolver
|
|
return;
|
|
}
|
|
|
|
- ModuleComponentResolveMetaData metaData = (ModuleComponentResolveMetaData) component;
|
|
- ModuleComponentIdentifier id = metaData.getComponentId();
|
|
+ ModuleComponentIdentifier id = (ModuleComponentIdentifier) component.getComponentId();
|
|
DefaultIvyArtifactName name = new DefaultIvyArtifactName( id.getModule(), "pom", "pom" );
|
|
- DefaultModuleComponentArtifactMetaData resolvedMetaData =
|
|
- new DefaultModuleComponentArtifactMetaData( id, name );
|
|
+ DefaultModuleComponentArtifactMetadata resolvedMetaData =
|
|
+ new DefaultModuleComponentArtifactMetadata( id, name );
|
|
result.resolved( Collections.singleton( resolvedMetaData ) );
|
|
}
|
|
|
|
@Override
|
|
+ public void resolveArtifacts( ComponentResolveMetadata component, BuildableComponentArtifactsResolveResult result )
|
|
+ {
|
|
+ ModuleComponentArtifactMetadata artifact =
|
|
+ ( (ModuleComponentResolveMetadata) component ).artifact( "jar", "jar", null );
|
|
+ result.resolved( new FixedComponentArtifacts( Collections.singleton( artifact ) ) );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
public LocallyAvailableExternalResource getMetaDataArtifact( ModuleComponentIdentifier id, ArtifactType type )
|
|
{
|
|
Path pomPath = resolve( new DefaultArtifact( id.getGroup(), id.getModule(), "pom", id.getVersion() ) );
|
|
@@ -266,7 +285,25 @@ public class GradleResolver
|
|
if ( pomPath == null )
|
|
return null;
|
|
|
|
- return new DefaultLocallyAvailableExternalResource( pomPath.toUri(),
|
|
- new DefaultLocallyAvailableResource( pomPath.toFile() ) );
|
|
+ DefaultExternalResourceMetaData metadata = new DefaultExternalResourceMetaData( pomPath.toUri(), 0, 0 );
|
|
+ return fileRepository.resource( pomPath.toFile(), pomPath.toUri(), metadata );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public ComponentMetadataSupplier createMetadataSupplier()
|
|
+ {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Map<ComponentArtifactIdentifier, ResolvableArtifact> getArtifactCache()
|
|
+ {
|
|
+ return Collections.emptyMap();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public MetadataFetchingCost estimateMetadataFetchingCost( ModuleComponentIdentifier arg0 )
|
|
+ {
|
|
+ return MetadataFetchingCost.CHEAP;
|
|
}
|
|
}
|
|
diff --git a/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/XMvnGradlePlugin.java b/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/XMvnGradlePlugin.java
|
|
index 2646f098..c3250e3c 100644
|
|
--- a/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/XMvnGradlePlugin.java
|
|
+++ b/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/XMvnGradlePlugin.java
|
|
@@ -15,9 +15,11 @@
|
|
*/
|
|
package org.fedoraproject.xmvn.connector.gradle;
|
|
|
|
+import groovy.lang.Closure;
|
|
+import groovy.lang.GroovyShell;
|
|
import org.gradle.api.Plugin;
|
|
import org.gradle.api.Task;
|
|
-import org.gradle.api.artifacts.repositories.ArtifactRepository;
|
|
+import org.gradle.api.artifacts.dsl.RepositoryHandler;
|
|
import org.gradle.api.invocation.Gradle;
|
|
|
|
/**
|
|
@@ -26,15 +28,17 @@ import org.gradle.api.invocation.Gradle;
|
|
public class XMvnGradlePlugin
|
|
implements Plugin<Gradle>
|
|
{
|
|
+ private void configureRepositories( RepositoryHandler repositories )
|
|
+ {
|
|
+ repositories.configure( (Closure<?>) new GroovyShell().evaluate( "{ it -> xmvn() }" ) );
|
|
+ }
|
|
+
|
|
@Override
|
|
public void apply( Gradle gradle )
|
|
{
|
|
- ArtifactRepository repo = new GradleResolver();
|
|
- repo.setName( "xmvn" );
|
|
-
|
|
gradle.allprojects( project -> {
|
|
- project.getRepositories().addFirst( repo );
|
|
- project.getBuildscript().getRepositories().addFirst( repo );
|
|
+ configureRepositories( project.getRepositories() );
|
|
+ configureRepositories( project.getBuildscript().getRepositories() );
|
|
|
|
Task upload = project.getTasks().create( "xmvnInstall", XMvnInstallTask.class );
|
|
upload.setDescription( "Installs all artifacts through XMvn" );
|
|
diff --git a/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/XMvnInstallTask.java b/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/XMvnInstallTask.java
|
|
index 196f4a5b..07905f1f 100644
|
|
--- a/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/XMvnInstallTask.java
|
|
+++ b/xmvn-connector-gradle/src/main/java/org/fedoraproject/xmvn/connector/gradle/XMvnInstallTask.java
|
|
@@ -17,6 +17,7 @@ package org.fedoraproject.xmvn.connector.gradle;
|
|
|
|
import java.nio.file.Files;
|
|
import java.util.Collections;
|
|
+import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.stream.Collectors;
|
|
@@ -32,7 +33,7 @@ import org.gradle.api.artifacts.PublishArtifact;
|
|
import org.gradle.api.artifacts.PublishException;
|
|
import org.gradle.api.component.SoftwareComponent;
|
|
import org.gradle.api.internal.component.SoftwareComponentInternal;
|
|
-import org.gradle.api.internal.component.Usage;
|
|
+import org.gradle.api.internal.component.UsageContext;
|
|
import org.gradle.api.tasks.TaskAction;
|
|
|
|
import org.fedoraproject.xmvn.artifact.Artifact;
|
|
@@ -83,7 +84,7 @@ class XMvnInstallTask
|
|
Project dependencyProject = projectDependency.getDependencyProject();
|
|
Stream<SoftwareComponent> components = dependencyProject.getComponents().stream();
|
|
Stream<SoftwareComponentInternal> internalComponents = components.map( c -> (SoftwareComponentInternal) c );
|
|
- Stream<Usage> usages = internalComponents.flatMap( ic -> ic.getUsages().stream() );
|
|
+ Stream<UsageContext> usages = internalComponents.flatMap( ic -> ic.getUsages().stream() );
|
|
Stream<PublishArtifact> publishArtifacts = usages.flatMap( usage -> usage.getArtifacts().stream() );
|
|
Stream<Artifact> artifacts = publishArtifacts.map( pa -> getPublishArtifact( dependencyProject, pa ) );
|
|
return artifacts.collect( Collectors.toList() );
|
|
@@ -144,7 +145,13 @@ class XMvnInstallTask
|
|
}
|
|
}
|
|
|
|
- DeploymentResult result = getDeployer().deploy( request );
|
|
+ DeploymentResult result;
|
|
+
|
|
+ // prevent parallel access to installation plan
|
|
+ synchronized ( XMvnInstallTask.class )
|
|
+ {
|
|
+ result = getDeployer().deploy( request );
|
|
+ }
|
|
|
|
if ( result.getException() != null )
|
|
{
|
|
@@ -155,17 +162,22 @@ class XMvnInstallTask
|
|
@TaskAction
|
|
protected void deployProject()
|
|
{
|
|
+ Set<PublishArtifact> seenArtifacts = new HashSet<>();
|
|
+
|
|
for ( SoftwareComponent component : getProject().getComponents() )
|
|
{
|
|
SoftwareComponentInternal internalComponent = (SoftwareComponentInternal) component;
|
|
|
|
- for ( Usage usage : internalComponent.getUsages() )
|
|
+ for ( UsageContext usage : internalComponent.getUsages() )
|
|
{
|
|
Set<ModuleDependency> dependencies = usage.getDependencies();
|
|
|
|
for ( PublishArtifact artifact : usage.getArtifacts() )
|
|
{
|
|
- deploy( artifact, dependencies );
|
|
+ if ( seenArtifacts.add( artifact ) )
|
|
+ {
|
|
+ deploy( artifact, dependencies );
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
diff --git a/xmvn-parent/pom.xml b/xmvn-parent/pom.xml
|
|
index 661cc24d..7e7a6d94 100644
|
|
--- a/xmvn-parent/pom.xml
|
|
+++ b/xmvn-parent/pom.xml
|
|
@@ -84,7 +84,7 @@
|
|
<atinjectVersion>1</atinjectVersion>
|
|
<ivyVersion>2.4.0</ivyVersion>
|
|
<jcommanderVersion>1.64</jcommanderVersion>
|
|
- <gradleVersion>2.13-rc-1</gradleVersion>
|
|
+ <gradleVersion>4.2.1</gradleVersion>
|
|
<groovyVersion>2.4.10</groovyVersion>
|
|
<mavenInvokerVersion>2.2</mavenInvokerVersion>
|
|
<mavenResolverVersion>1.0.3</mavenResolverVersion>
|
|
@@ -278,11 +278,21 @@
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.gradle</groupId>
|
|
+ <artifactId>gradle-core-api</artifactId>
|
|
+ <version>${gradleVersion}</version>
|
|
+ </dependency>
|
|
+ <dependency>
|
|
+ <groupId>org.gradle</groupId>
|
|
<artifactId>gradle-core</artifactId>
|
|
<version>${gradleVersion}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.gradle</groupId>
|
|
+ <artifactId>gradle-model-core</artifactId>
|
|
+ <version>${gradleVersion}</version>
|
|
+ </dependency>
|
|
+ <dependency>
|
|
+ <groupId>org.gradle</groupId>
|
|
<artifactId>gradle-dependency-management</artifactId>
|
|
<version>${gradleVersion}</version>
|
|
</dependency>
|
|
@@ -292,6 +302,11 @@
|
|
<version>${gradleVersion}</version>
|
|
</dependency>
|
|
<dependency>
|
|
+ <groupId>org.gradle</groupId>
|
|
+ <artifactId>gradle-logging</artifactId>
|
|
+ <version>${gradleVersion}</version>
|
|
+ </dependency>
|
|
+ <dependency>
|
|
<groupId>org.codehaus.groovy</groupId>
|
|
<artifactId>groovy-all</artifactId>
|
|
<version>${groovyVersion}</version>
|
|
--
|
|
2.13.6
|
|
|