aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormatyrobbrt <65940752+Matyrobbrt@users.noreply.github.com>2023-01-09 00:58:52 +0200
committerGitHub <noreply@github.com>2023-01-08 16:58:52 -0600
commit86fe50bd075b6e543d319fa9b99641812e1014fa (patch)
tree9bb15531b3da3237f24996578cee5298d078e41a /src
parent578f33b206c7325762a956a1f3e3171d5c6d9052 (diff)
downloadArtifactural-86fe50bd075b6e543d319fa9b99641812e1014fa.tar.gz
Artifactural-86fe50bd075b6e543d319fa9b99641812e1014fa.tar.bz2
Artifactural-86fe50bd075b6e543d319fa9b99641812e1014fa.zip
Add compatibility with Gradle 7.6 (#5)
Co-authored-by: SizableShrimp <sizableshrimp@sizableshrimp.me>
Diffstat (limited to 'src')
-rw-r--r--src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java b/src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java
index 0970397..7291731 100644
--- a/src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java
+++ b/src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java
@@ -34,6 +34,7 @@ import org.gradle.api.internal.artifacts.BaseRepositoryFactory;
import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentResolvers;
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.strategy.VersionParser;
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.DefaultMavenLocalArtifactRepository;
@@ -53,14 +54,12 @@ import org.gradle.internal.component.external.model.MutableModuleComponentResolv
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.ConfigurationMetadata;
import org.gradle.internal.component.model.ModuleSources;
import org.gradle.internal.nativeintegration.filesystem.FileSystem;
import org.gradle.internal.nativeintegration.services.FileSystems;
import org.gradle.internal.reflect.Instantiator;
-import org.gradle.internal.resolve.result.BuildableArtifactResolveResult;
+import org.gradle.internal.resolve.result.BuildableArtifactFileResolveResult;
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.ExternalResourceName;
@@ -71,6 +70,7 @@ import org.gradle.internal.resource.local.LocalFileStandInExternalResource;
import org.gradle.internal.resource.local.LocallyAvailableExternalResource;
import org.gradle.internal.resource.metadata.ExternalResourceMetaData;
import org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor;
+import org.gradle.util.GradleVersion;
import java.io.File;
import java.io.IOException;
@@ -96,9 +96,16 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
m.artifact();
});
- GradleRepositoryAdapter repo;
+ final GradleRepositoryAdapter repo;
+
+ if (GradleVersion.current().compareTo(GradleVersion.version("7.6")) >= 0) {
+ // If we are on gradle 7.6+ we want to use the super constructor with 2 arguments (with the VersionParser)
+ repo = new GradleRepositoryAdapter(repository, maven, getVersionParser(maven));
+ } else {
+ // If we are on gradle 4.10 - 7.5 we use the super constructor with only the ObjectFactory parameter
+ repo = new GradleRepositoryAdapter(repository, maven);
+ }
- repo = new GradleRepositoryAdapter(repository, maven);
repo.setName(name);
handler.add(repo);
return repo;
@@ -112,28 +119,34 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
// This constructor is modified via bytecode manipulation in 'build.gradle'
// DO NOT change this without modifying 'build.gradle'
- // This contructor is used on Gradle 4.9 and below
+ // This constructor is used on Gradle 7.5.* and below
+ @Deprecated // TODO - remove this constructor when we can break ABI compatibility
private GradleRepositoryAdapter(Repository repository, DefaultMavenLocalArtifactRepository local) {
- // This is replaced with a call to 'super()', with no arguments
- super(null);
+ // This is replaced with a call to 'super(getObjectFactory(local))'
+ super(getObjectFactory(local), null);
this.repository = repository;
this.local = local;
this.root = cleanRoot(local.getUrl());
this.cache = new LocatedArtifactCache(new File(root));
}
-
- // This constructor is used on Gradle 4.10 and above
- GradleRepositoryAdapter(ObjectFactory objectFactory, Repository repository, DefaultMavenLocalArtifactRepository local) {
- super(objectFactory);
- // This duplication from the above two-argument constructor is unfortunate,
- // but unavoidable
+ // This constructor is used on Gradle 7.6 and above
+ private GradleRepositoryAdapter(Repository repository, DefaultMavenLocalArtifactRepository local, VersionParser versionParser) {
+ super(getObjectFactory(local), versionParser);
this.repository = repository;
this.local = local;
this.root = cleanRoot(local.getUrl());
this.cache = new LocatedArtifactCache(new File(root));
}
+ private static ObjectFactory getObjectFactory(DefaultMavenLocalArtifactRepository maven) {
+ return ReflectionUtils.get(maven, "objectFactory");
+ }
+
+ private static VersionParser getVersionParser(DefaultMavenLocalArtifactRepository maven) {
+ return ReflectionUtils.get(maven, "versionParser");
+ }
+
@Override
public String getDisplayName() {
return local.getDisplayName();
@@ -192,11 +205,6 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
}
@Override
- public void resolveArtifacts(ComponentResolveMetadata component, ConfigurationMetadata variant, BuildableComponentArtifactsResolveResult result) {
- delegate.resolveArtifacts(component, variant, result);
- }
-
- @Override
public void listModuleVersions(ModuleDependencyMetadata dependency, BuildableModuleVersionListingResolveResult result) {
delegate.listModuleVersions(dependency, result);
}
@@ -207,11 +215,10 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
}
@Override
- public void resolveArtifact(ComponentArtifactMetadata artifact, ModuleSources moduleSources, BuildableArtifactResolveResult result) {
- delegate.resolveArtifact(artifact, moduleSources, result);
+ public void resolveArtifact(ComponentArtifactMetadata componentArtifactMetadata, ModuleSources moduleSources, BuildableArtifactFileResolveResult buildableArtifactFileResolveResult) {
+ delegate.resolveArtifact(componentArtifactMetadata, moduleSources, buildableArtifactFileResolveResult);
}
-
@Override
public MetadataFetchingCost estimateMetadataFetchingCost(ModuleComponentIdentifier moduleComponentIdentifier) {
return delegate.estimateMetadataFetchingCost(moduleComponentIdentifier);