aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.teamcity/pom.xml2
-rw-r--r--.teamcity/settings.kts6
-rw-r--r--Jenkinsfile87
-rw-r--r--build.gradle75
-rw-r--r--gradle/wrapper/gradle-wrapper.jarbin61574 -> 63375 bytes
-rw-r--r--gradle/wrapper/gradle-wrapper.properties3
-rwxr-xr-xgradlew16
-rw-r--r--settings.gradle2
-rw-r--r--src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java104
9 files changed, 157 insertions, 138 deletions
diff --git a/.teamcity/pom.xml b/.teamcity/pom.xml
index 6cdf2ab..d508918 100644
--- a/.teamcity/pom.xml
+++ b/.teamcity/pom.xml
@@ -22,7 +22,7 @@
</repository>
<repository>
<id>teamcity-server</id>
- <url>https://teamcity.minecraftforge.net/app/dsl-plugins-repository</url>
+ <url>https://teamcity.neoforged.net/app/dsl-plugins-repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts
index 8b545a6..963e4fa 100644
--- a/.teamcity/settings.kts
+++ b/.teamcity/settings.kts
@@ -35,14 +35,14 @@ project {
text("git_main_branch", "master", label = "Git Main Branch", description = "The git main or default branch to use in VCS operations.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
text("github_repository_name", "Artifactural", label = "The github repository name. Used to connect to it in VCS Roots.", description = "This is the repository slug on github. So for example `Artifactural` or `MinecraftForge`. It is interpolated into the global VCS Roots.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
text("env.PUBLISHED_JAVA_ARTIFACT_ID", "artifactural", label = "Published artifact id", description = "The maven coordinate artifact id that has been published by this build. Can not be empty.", allowEmpty = false)
- text("env.PUBLISHED_JAVA_GROUP", "net.minecraftforge", label = "Published group", description = "The maven coordinate group that has been published by this build. Can not be empty.", allowEmpty = false)
+ text("env.PUBLISHED_JAVA_GROUP", "net.neoforged", label = "Published group", description = "The maven coordinate group that has been published by this build. Can not be empty.", allowEmpty = false)
}
features {
githubIssues {
id = "Artifactural__IssueTracker"
- displayName = "minecraftforge/Artifactural"
- repositoryURL = "https://github.com/minecraftforge/Artifactural"
+ displayName = "NeoForged/Artifactural"
+ repositoryURL = "https://github.com/neoforged/Artifactural"
}
}
}
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index 7e93cc7..0000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,87 +0,0 @@
-@Library('forge-shared-library')_
-
-pipeline {
- agent {
- docker {
- image 'gradle:jdk8'
- args '-v gradlecache:/gradlecache'
- }
- }
- environment {
- GRADLE_ARGS = '-Dorg.gradle.daemon.idletimeout=5000'
- DISCORD_WEBHOOK = credentials('forge-discord-jenkins-webhook')
- DISCORD_PREFIX = "Job: Artifactural Branch: ${BRANCH_NAME} Build: #${BUILD_NUMBER}"
- JENKINS_HEAD = 'https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png'
- }
-
- stages {
- stage('fetch') {
- steps {
- checkout scm
- }
- }
- stage('notify_start') {
- when {
- not {
- changeRequest()
- }
- }
- steps {
- discordSend(
- title: "${DISCORD_PREFIX} Started",
- successful: true,
- result: 'ABORTED', //White border
- thumbnail: JENKINS_HEAD,
- webhookURL: DISCORD_WEBHOOK
- )
- }
- }
- stage('buildandtest') {
- steps {
- withGradle {
- sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue build test'
- }
- script {
- env.MYGROUP = sh(returnStdout: true, script: './gradlew properties -q | grep "group:" | awk \'{print $2}\'').trim()
- env.MYARTIFACT = sh(returnStdout: true, script: './gradlew properties -q | grep "name:" | awk \'{print $2}\'').trim()
- env.MYVERSION = sh(returnStdout: true, script: './gradlew properties -q | grep "version:" | awk \'{print $2}\'').trim()
- }
- }
- }
- stage('publish') {
- when {
- not {
- changeRequest()
- }
- }
- steps {
- withCredentials([usernamePassword(credentialsId: 'maven-forge-user', usernameVariable: 'MAVEN_USER', passwordVariable: 'MAVEN_PASSWORD')]) {
- withGradle {
- sh './gradlew ${GRADLE_ARGS} publish'
- }
- }
- }
- post {
- success {
- build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote ${env.MYGROUP}:${env.MYARTIFACT} ${env.MYVERSION} latest")], propagate: false, wait: false
- }
- }
- }
- }
- post {
- always {
- script {
- if (env.CHANGE_ID == null) { // This is unset for non-PRs
- discordSend(
- title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}",
- description: '```\n' + getChanges(currentBuild) + '\n```',
- successful: currentBuild.resultIsBetterOrEqualTo("SUCCESS"),
- result: currentBuild.currentResult,
- thumbnail: JENKINS_HEAD,
- webhookURL: DISCORD_WEBHOOK
- )
- }
- }
- }
- }
-}
diff --git a/build.gradle b/build.gradle
index ac32a6e..6a29630 100644
--- a/build.gradle
+++ b/build.gradle
@@ -10,10 +10,11 @@ plugins {
id 'maven-publish'
id 'eclipse'
id 'org.cadixdev.licenser' version '0.6.1'
- id 'net.minecraftforge.gradleutils' version '2.+'
+ id 'net.neoforged.gradleutils' version '2.+'
+ id 'dev.gradleplugins.gradle-plugin-development' version '1.6.9'
}
-group = 'net.minecraftforge'
+group = 'net.neoforged'
version = gradleutils.getTagOffsetVersion()
println('Version: ' + version + ' Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
@@ -27,7 +28,7 @@ sourceSets {
repositories {
mavenCentral()
maven {
- url = 'https://maven.minecraftforge.net'
+ url = 'https://maven.neoforged.net'
}
}
@@ -43,7 +44,7 @@ dependencies {
sharedImplementation sourceSets.api.output
gradlecompImplementation sourceSets.shared.output
- gradlecompImplementation gradleApi()
+ gradlecompImplementation gradleApi('8.2.1')
gradlecompImplementation 'com.google.guava:guava:30.1-jre'
gradlecompImplementation 'net.minecraftforge:unsafe:0.2.0'
@@ -75,9 +76,39 @@ tasks.register('transformJar', JarTransformationTask) {
it instanceof MethodInsnNode && it.owner == 'org/gradle/api/internal/artifacts/repositories/AbstractArtifactRepository' && it.name == '<init>'
}?.tap { (it as MethodInsnNode).desc = '(Lorg/gradle/api/model/ObjectFactory;)V' }
}
+
+ it.methods.find {
+ it.name == 'getDescriptorGradle8_1Below' && it.desc == '()Lorg/gradle/api/internal/artifacts/repositories/descriptor/RepositoryDescriptor;'
+ }.tap {
+ it.instructions.find {
+ it instanceof InsnNode && it.opcode == Opcodes.ACONST_NULL
+ }.tap(it.instructions.&remove)
+ it.instructions.find {
+ it instanceof MethodInsnNode && it.owner == 'org/gradle/api/internal/artifacts/repositories/descriptor/FlatDirRepositoryDescriptor' && it.name == '<init>'
+ }.tap { (it as MethodInsnNode).desc = '(Ljava/lang/String;Ljava/util/Collection;)V' }
+ }
}
addTransformer('net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter$1$1') { clazz ->
+ // Gradle [???,8.2)
+ {
+ clazz.methods.find {
+ it.name == 'getMetadataGradle8_1Below' && it.desc == '(Lorg/gradle/internal/resolve/result/BuildableModuleComponentMetaDataResolveResult;)Lorg/gradle/internal/component/external/model/ModuleComponentResolveMetadata;'
+ }.tap {
+ it.instructions.find {
+ it instanceof MethodInsnNode && it.owner == 'org/gradle/internal/resolve/result/BuildableModuleComponentMetaDataResolveResult' && it.name == 'getMetaData'
+ }.tap { (it as MethodInsnNode).desc = '()Lorg/gradle/internal/component/external/model/ModuleComponentResolveMetadata;' }
+ }
+
+ clazz.methods.find {
+ it.name == 'setResultResolvedGradle8_1Below' && it.desc == '(Lorg/gradle/internal/resolve/result/BuildableModuleComponentMetaDataResolveResult;Lorg/gradle/internal/component/external/model/ModuleComponentResolveMetadata;)V'
+ }.tap {
+ it.instructions.find {
+ it instanceof MethodInsnNode && it.owner == 'org/gradle/internal/resolve/result/BuildableModuleComponentMetaDataResolveResult' && it.name == 'resolved'
+ }.tap { (it as MethodInsnNode).desc = '(Lorg/gradle/internal/component/external/model/ModuleComponentResolveMetadata;)V' }
+ }
+ }
+
// Gradle [6.1,7.6)
{
final method = clazz.visitMethod(Opcodes.ACC_PUBLIC, 'resolveArtifact', '(Lorg/gradle/internal/component/model/ComponentArtifactMetadata;Lorg/gradle/internal/component/model/ModuleSources;Lorg/gradle/internal/resolve/result/BuildableArtifactResolveResult;)V', null, new String[]{})
@@ -172,25 +203,25 @@ license {
header = file("$rootDir/LICENSE-header.txt")
}
-configurations.runtimeElements.outgoing {
- it.artifacts.removeIf {
- (it.classifier == null || it.classifier.blank) && it.extension == 'jar' // Remove the jar artifact as we want to replace it with the transformed one
- }
- it.artifact(tasks.named('transformJar').flatMap { it.outputFile }) {
- classifier = null
+[configurations.runtimeElements, configurations.apiElements, configurations.sourcesElements].each {
+ it.outgoing {
+ it.artifacts.removeIf {
+ (it.classifier == null || it.classifier.blank) && it.extension == 'jar' // Remove the jar artifact as we want to replace it with the transformed one
+ }
+ it.artifact(tasks.named('transformJar').flatMap { it.outputFile }) {
+ classifier = null
+ }
}
}
-
-final transformed = project.objects.newInstance(SoftwareComponentFactoryGrabber).softwareComponentFactory.adhoc('transformed')
-project.components.add(transformed)
-transformed.addVariantsFromConfiguration(configurations.runtimeElements) {
- mapToMavenScope 'runtime'
+configurations.sourcesElements.outgoing {
+ it.artifacts.removeIf {
+ it.classifier != 'sources'
+ }
}
publishing {
publications.create("mavenJava", MavenPublication) {
- from components.transformed
- artifact sourcesJar
+ from components.java
pom {
groupId = project.group
version = project.version
@@ -198,16 +229,16 @@ publishing {
name = project.archivesBaseName
packaging = 'jar'
description = 'A Gradle artifact processing and management tool'
- url = 'https://github.com/MinecraftForge/Artifactural/'
+ url = 'https://github.com/neoforged/Artifactural/'
scm {
- url = 'https://github.com/MinecraftForge/Artifactural/'
- connection = 'scm:git:git://github.com/MinecraftForge/Artifactural.git'
- developerConnection = 'scm:git:git@github.com:MinecraftForge/Artifactural.git'
+ url = 'https://github.com/neoforged/Artifactural/'
+ connection = 'scm:git:git://github.com/neoforged/Artifactural.git'
+ developerConnection = 'scm:git:git@github.com:neoforged/Artifactural.git'
}
issueManagement {
system = 'github'
- url = 'https://github.com/MinecraftForge/Artifactural/issues'
+ url = 'https://github.com/neoforged/Artifactural/issues'
}
licenses {
license {
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 943f0cb..033e24c 100644
--- a/gradle/wrapper/gradle-wrapper.jar
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f398c33..9f4197d 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 65dcd68..fcb6fca 100755
--- a/gradlew
+++ b/gradlew
@@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
@@ -144,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
diff --git a/settings.gradle b/settings.gradle
index ef93b52..f91e965 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,7 +1,7 @@
pluginManagement {
repositories {
gradlePluginPortal()
- maven { url = 'https://maven.minecraftforge.net/' }
+ maven { url = 'https://maven.neoforged.net/releases' }
}
}
diff --git a/src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java b/src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java
index 7291731..8b2a536 100644
--- a/src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java
+++ b/src/gradlecomp/java/net/minecraftforge/artifactural/gradle/GradleRepositoryAdapter.java
@@ -19,13 +19,13 @@
package net.minecraftforge.artifactural.gradle;
+import com.google.common.collect.ImmutableList;
import net.minecraftforge.artifactural.api.artifact.Artifact;
import net.minecraftforge.artifactural.api.artifact.ArtifactIdentifier;
import net.minecraftforge.artifactural.api.artifact.MissingArtifactException;
import net.minecraftforge.artifactural.api.repository.Repository;
import net.minecraftforge.artifactural.base.artifact.SimpleArtifactIdentifier;
import net.minecraftforge.artifactural.base.cache.LocatedArtifactCache;
-
import org.gradle.api.artifacts.ComponentMetadataSupplierDetails;
import org.gradle.api.artifacts.component.ComponentArtifactIdentifier;
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
@@ -40,6 +40,7 @@ import org.gradle.api.internal.artifacts.repositories.AbstractArtifactRepository
import org.gradle.api.internal.artifacts.repositories.DefaultMavenLocalArtifactRepository;
import org.gradle.api.internal.artifacts.repositories.ResolutionAwareRepository;
import org.gradle.api.internal.artifacts.repositories.descriptor.FlatDirRepositoryDescriptor;
+import org.gradle.api.internal.artifacts.repositories.descriptor.IvyRepositoryDescriptor;
import org.gradle.api.internal.artifacts.repositories.descriptor.RepositoryDescriptor;
import org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceArtifactResolver;
import org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver;
@@ -84,11 +85,11 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
private static final Pattern URL_PATTERN = Pattern.compile(
"^(?<group>\\S+(?:/\\S+)*)/(?<name>\\S+)/(?<version>\\S+)/" +
- "\\2-\\3(?:-(?<classifier>[^.\\s]+))?\\.(?<extension>\\S+)$");
+ "\\2-\\3(?:-(?<classifier>[^.\\s]+))?\\.(?<extension>\\S+)$");
public static GradleRepositoryAdapter add(RepositoryHandler handler, String name, File local, Repository repository) {
BaseRepositoryFactory factory = ReflectionUtils.get(handler, "repositoryFactory"); // We reflect here and create it manually so it DOESN'T get attached.
- DefaultMavenLocalArtifactRepository maven = (DefaultMavenLocalArtifactRepository)factory.createMavenLocalRepository(); // We use maven local because it bypasses the caching and coping to .m2
+ DefaultMavenLocalArtifactRepository maven = (DefaultMavenLocalArtifactRepository) factory.createMavenLocalRepository(); // We use maven local because it bypasses the caching and coping to .m2
maven.setUrl(local);
maven.setName(name);
maven.metadataSources(m -> {
@@ -154,9 +155,9 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
@Override
public ConfiguredModuleComponentRepository createResolver() {
- MavenResolver resolver = (MavenResolver)local.createResolver();
+ MavenResolver resolver = (MavenResolver) local.createResolver();
- GeneratingFileResourceRepository repo = new GeneratingFileResourceRepository();
+ GeneratingFileResourceRepository repo = new GeneratingFileResourceRepository();
ReflectionUtils.alter(resolver, "repository", prev -> repo); // ExternalResourceResolver.repository
//ReflectionUtils.alter(resolver, "metadataSources", ); //ExternalResourceResolver.metadataSources We need to fix these from returning 'missing'
// MavenResolver -> MavenMetadataLoader -> FileCacheAwareExternalResourceAccessor -> DefaultCacheAwareExternalResourceAccessor
@@ -169,6 +170,7 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
ReflectionUtils.alter(resolver, "cachingResourceAccessor.this$0.repository", prev -> repo);
ReflectionUtils.alter(resolver, "cachingResourceAccessor.delegate.delegate", prev -> repo);
+ //noinspection unchecked,rawtypes
return new ConfiguredModuleComponentRepository() {
private final ModuleComponentRepositoryAccess local = wrap(resolver.getLocalAccess());
private final ModuleComponentRepositoryAccess remote = wrap(resolver.getRemoteAccess());
@@ -182,28 +184,72 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
@Override public boolean isLocal() { return resolver.isLocal(); }
@Override
- public void setComponentResolvers(ComponentResolvers resolver) { }
+ public void setComponentResolvers(ComponentResolvers resolver) {}
+
@Override
public Instantiator getComponentMetadataInstantiator() {
return resolver.getComponentMetadataInstantiator();
}
private ModuleComponentRepositoryAccess wrap(ModuleComponentRepositoryAccess delegate) {
+ //noinspection rawtypes
return new ModuleComponentRepositoryAccess() {
@Override
- public void resolveComponentMetaData(ModuleComponentIdentifier moduleComponentIdentifier, ComponentOverrideMetadata requestMetaData, BuildableModuleComponentMetaDataResolveResult result) {
+ public void resolveComponentMetaData(ModuleComponentIdentifier moduleComponentIdentifier, ComponentOverrideMetadata requestMetaData,
+ BuildableModuleComponentMetaDataResolveResult result) {
+ //noinspection unchecked
delegate.resolveComponentMetaData(moduleComponentIdentifier, requestMetaData, result);
if (result.getState() == BuildableModuleComponentMetaDataResolveResult.State.Resolved) {
- ModuleComponentResolveMetadata meta = result.getMetaData();
+ ModuleComponentResolveMetadata meta = getMetadata(result);
if (meta.isMissing()) {
MutableModuleComponentResolveMetadata mutable = meta.asMutable();
mutable.setChanging(true);
mutable.setMissing(false);
- result.resolved(mutable.asImmutable());
+ setResultResolved(result, mutable.asImmutable());
}
}
}
+ private void setResultResolved(BuildableModuleComponentMetaDataResolveResult result, ModuleComponentResolveMetadata meta) {
+ if (GradleVersion.current().compareTo(GradleVersion.version("8.2")) >= 0) {
+ this.setResultResolvedGradle8_2Above(result, meta);
+ } else {
+ this.setResultResolvedGradle8_1Below(result, meta);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void setResultResolvedGradle8_2Above(BuildableModuleComponentMetaDataResolveResult result, ModuleComponentResolveMetadata meta) {
+ result.resolved(meta);
+ }
+
+ // DO NOT TOUCH
+ // This method is modified by ASM in build.gradle
+ @SuppressWarnings("unchecked")
+ private void setResultResolvedGradle8_1Below(BuildableModuleComponentMetaDataResolveResult result, ModuleComponentResolveMetadata meta) {
+ // Descriptor of resolved is changed to (Lorg/gradle/internal/component/external/model/ModuleComponentResolveMetadata;)V
+ result.resolved(meta);
+ }
+
+ private ModuleComponentResolveMetadata getMetadata(BuildableModuleComponentMetaDataResolveResult result) {
+ return GradleVersion.current().compareTo(GradleVersion.version("8.2")) >= 0
+ ? this.getMetadataGradle8_2Above(result)
+ : this.getMetadataGradle8_1Below(result);
+ }
+
+ private ModuleComponentResolveMetadata getMetadataGradle8_2Above(BuildableModuleComponentMetaDataResolveResult result) {
+ // This cast is actually safe, because we know the typing of the generics is <ModuleComponentResolveMetadata>
+ // We explicitly don't use the generics because they don't exist on Gradle versions 8.1.* and lower
+ return (ModuleComponentResolveMetadata) result.getMetaData();
+ }
+
+ // DO NOT TOUCH
+ // This method is modified by ASM in build.gradle
+ private ModuleComponentResolveMetadata getMetadataGradle8_1Below(BuildableModuleComponentMetaDataResolveResult result) {
+ // Descriptor of getMetaData is changed to ()Lorg/gradle/internal/component/external/model/ModuleComponentResolveMetadata;
+ return (ModuleComponentResolveMetadata) result.getMetaData();
+ }
+
@Override
public void listModuleVersions(ModuleDependencyMetadata dependency, BuildableModuleVersionListingResolveResult result) {
delegate.listModuleVersions(dependency, result);
@@ -215,7 +261,8 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
}
@Override
- public void resolveArtifact(ComponentArtifactMetadata componentArtifactMetadata, ModuleSources moduleSources, BuildableArtifactFileResolveResult buildableArtifactFileResolveResult) {
+ public void resolveArtifact(ComponentArtifactMetadata componentArtifactMetadata, ModuleSources moduleSources,
+ BuildableArtifactFileResolveResult buildableArtifactFileResolveResult) {
delegate.resolveArtifact(componentArtifactMetadata, moduleSources, buildableArtifactFileResolveResult);
}
@@ -229,21 +276,44 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
}
public RepositoryDescriptor getDescriptor() {
- return new FlatDirRepositoryDescriptor("ArtifacturalRepository", new ArrayList<>());
+ return GradleVersion.current().compareTo(GradleVersion.version("8.2")) >= 0
+ ? this.getDescriptorGradle8_2Above()
+ : this.getDescriptorGradle8_1Below();
}
+ // DO NOT TOUCH
+ // This method is used on Gradle 8.1.* and below
+ // It is modified by ASM in build.gradle
+ private RepositoryDescriptor getDescriptorGradle8_1Below() {
+ // Replaced by FlatDirRepositoryDescriptor(String, List) with ASM
+ return new FlatDirRepositoryDescriptor("ArtifacturalRepository", new ArrayList<>(), null);
+ }
+
+ private RepositoryDescriptor getDescriptorGradle8_2Above() {
+ IvyRepositoryDescriptor.Builder builder = new IvyRepositoryDescriptor.Builder("ArtifacturalRepository", null);
+ builder.setM2Compatible(false);
+ builder.setLayoutType("Unknown");
+ builder.setMetadataSources(ImmutableList.of());
+ builder.setAuthenticated(false);
+ builder.setAuthenticationSchemes(ImmutableList.of());
+ IvyRepositoryDescriptor ivyDescriptor = builder.create();
+ return new FlatDirRepositoryDescriptor("ArtifacturalRepository", new ArrayList<>(), ivyDescriptor);
+ }
private static String cleanRoot(URI uri) {
String ret = uri.normalize().getPath().replace('\\', '/');
- if (!ret.endsWith("/")) ret += '/';
+ if (!ret.endsWith("/"))
+ ret += '/';
return ret;
}
private class GeneratingFileResourceRepository implements FileResourceRepository {
private final FileSystem fileSystem = FileSystems.getDefault();
+
private void debug(String message) {
//System.out.println(message);
}
+
private void log(String message) {
System.out.println(message);
}
@@ -289,11 +359,11 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
Matcher matcher = URL_PATTERN.matcher(relative);
if (matcher.matches()) {
ArtifactIdentifier identifier = new SimpleArtifactIdentifier(
- matcher.group("group").replace('/', '.'),
- matcher.group("name"),
- matcher.group("version"),
- matcher.group("classifier"),
- matcher.group("extension"));
+ matcher.group("group").replace('/', '.'),
+ matcher.group("name"),
+ matcher.group("version"),
+ matcher.group("classifier"),
+ matcher.group("extension"));
Artifact artifact = repository.getArtifact(identifier);
return wrap(artifact, identifier);
} else if (relative.endsWith("maven-metadata.xml")) {