diff options
author | Gabriel Harris-Rouquette <gabizou@me.com> | 2021-01-17 16:49:22 -0800 |
---|---|---|
committer | LexManos <LexManos@gmail.com> | 2021-01-17 17:28:00 -0800 |
commit | 631cd05e726092c51e95b52bb8a8bb6a2ae2cc42 (patch) | |
tree | 7508b126e2287f78a4d8f59c80c200f7c2d52646 | |
parent | 5725530e7e8b379d506ca737e9ddd0f00c7f1e32 (diff) | |
download | Artifactural-631cd05e726092c51e95b52bb8a8bb6a2ae2cc42.tar.gz Artifactural-631cd05e726092c51e95b52bb8a8bb6a2ae2cc42.tar.bz2 Artifactural-631cd05e726092c51e95b52bb8a8bb6a2ae2cc42.zip |
Bump project to Gradle 6.8
-rw-r--r-- | build.gradle | 190 | ||||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.jar | bin | 54413 -> 59203 bytes | |||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 3 | ||||
-rwxr-xr-x | gradlew | 53 | ||||
-rw-r--r-- | gradlew.bat | 43 | ||||
-rw-r--r-- | src/gradlecomp/java/com/amadornes/artifactural/gradle/Gradle410RepositoryAdapter.java | 42 | ||||
-rw-r--r-- | src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java | 52 | ||||
-rw-r--r-- | src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java | 2 | ||||
-rw-r--r-- | src/shared/java/com/amadornes/artifactural/base/util/HashFunction.java | 12 |
9 files changed, 102 insertions, 295 deletions
diff --git a/build.gradle b/build.gradle index 8b5242f..00240bd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,44 +1,21 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - // Needed for bytecode manipulation - classpath 'org.ow2.asm:asm-all:5.2' - } -} - plugins { + id 'java-library' + id 'maven-publish' + id 'eclipse' id 'net.minecrell.licenser' version '0.3' - id 'org.ajoberstar.grgit' version '2.3.0' - //id 'com.github.johnrengelman.shadow' version '2.0.4' + id 'org.ajoberstar.grgit' version '4.1.0' } -import java.nio.file.Paths -import org.objectweb.asm.ClassReader -import org.objectweb.asm.ClassWriter -import org.objectweb.asm.Opcodes -import org.objectweb.asm.tree.ClassNode -import org.objectweb.asm.tree.MethodInsnNode -import org.objectweb.asm.tree.VarInsnNode -import org.objectweb.asm.tree.InsnNode - -import java.util.jar.JarFile - -apply plugin: 'java' -apply plugin: 'maven-publish' -apply plugin: 'eclipse' - group = 'net.minecraftforge' version = gitVersion() + def gitVersion() { def raw = grgit.describe(longDescr: true) def desc = (raw == null ? 'unknown-unknown-unknown' : raw).split('-') as List def hash = desc.remove(desc.size() - 1) def offset = desc.remove(desc.size() - 1) def tag = desc.join('-') - def branch = grgit.branch.current().name - return "${tag}.${offset}" //${t -> if (branch != 'master') t << '-' + branch}" + return "${tag}.${offset}" } sourceSets { @@ -65,12 +42,10 @@ dependencies { java9Implementation files(sourceSets.main.output.classesDirs) { builtBy compileJava } sharedImplementation sourceSets.api.output - sharedImplementation 'commons-io:commons-io:2.4' gradlecompImplementation sourceSets.shared.output gradlecompImplementation gradleApi() - gradlecompImplementation 'com.google.guava:guava:26.0-jre' - gradlecompImplementation 'commons-io:commons-io:2.4' + gradlecompImplementation 'com.google.guava:guava:30.1-jre' compile sourceSets.api.output compile sourceSets.shared.output @@ -78,22 +53,20 @@ dependencies { } -// Default all standard Java compile tasks to Java 8 -// We'll specify Java 9 only for the java9 compile task tasks.withType(JavaCompile) { options.encoding = 'utf-8' options.deprecation = true - sourceCompatibility = 8 - targetCompatibility = 8 - options.compilerArgs.addAll(['--release', '8']) +} +java { + toolchain.languageVersion = JavaLanguageVersion.of(8) } project(':artifactural9') { apply plugin: 'java' apply plugin: 'eclipse' - sourceCompatibility = targetCompatibility = 9 group = rootProject.group - + java.toolchain.languageVersion = JavaLanguageVersion.of(9) + sourceSets { java9.java.srcDirs = [rootProject.file('src/java9').getAbsolutePath()] } @@ -110,114 +83,19 @@ project(':artifactural9') { tasks.withType(JavaCompile) { options.encoding = 'utf-8' - sourceCompatibility = 9 - targetCompatibility = 9 - options.compilerArgs.addAll(['--release', '9']) - } -} - -def gradleRepositoryAdapterPath = Paths.get("com", "amadornes", "artifactural", "gradle", "GradleRepositoryAdapter.class") -def classesDirs = sourceSets.gradlecomp.output.classesDirs.getFiles().first().toPath() - - -def _constructorName = "<init>" -def _constructorDesc = "(Lcom/amadornes/artifactural/api/repository/Repository;Lorg/gradle/api/internal/artifacts/repositories/DefaultMavenLocalArtifactRepository;)V" -def _modifiedSuperDesc = "()V" - -// This task patches 'GradleRepositoryAdapter' to make it compatibile with both Gradle 4.9 and 4.10 -// In Gradle 4.9, the constructor of AbstractArtifactRepository changes has zero arguments -// (instead of the one-argument constructor in 4.10, which we compile against) -// It's not possible to write a normal Java class that calls a constructor which doesn't exist at compile time. -// Therefore, we need to patch the bytecode of the class to properly call the non-arg super() constrcutor -class PatchGradleRepositoryAdapter extends DefaultTask { - - @Input String constructorName - @Input String constructorDesc - @Input String modifiedSuperDesc - @Input File gradleRepositoryAdapter - @Input File classesDir - @OutputDirectory java.nio.file.Path outputDir - - - @TaskAction - void patchClass() { - def originalGradleRepositoryAdapter = Paths.get(classesDir.toString(), gradleRepositoryAdapter.toString()) - - ClassNode node = new ClassNode() - ClassReader reader = new ClassReader(new FileInputStream(originalGradleRepositoryAdapter.toFile())) - reader.accept(node, 0) - - - def constructor = node.methods.find { - it.name == constructorName && it.desc == constructorDesc - } - - def getDescriptor = node.methods.find { - it.name == "getDescriptor" + javaCompiler = javaToolchains.compilerFor { + languageVersion = JavaLanguageVersion.of(9) } - - if (constructor == null) { - throw new RuntimeException("Failed to find target constructor!") - } - - if (getDescriptor == null) { - throw new RuntimeException("Failed to find getDescriptor()") - } - - // Strip out this method - it only exists - // so that GradleRepositoryAdapter will compile - node.methods.remove(getDescriptor) - - def superInvoc = constructor.instructions.find { - it instanceof MethodInsnNode && it.owner == "org/gradle/api/internal/artifacts/repositories/AbstractArtifactRepository" - } as MethodInsnNode - - if (superInvoc == null) { - throw new RuntimeException("Failed to find target super() invocation!") - } - - superInvoc.desc = modifiedSuperDesc - - def aconstNull = superInvoc.previous - if (!(aconstNull instanceof InsnNode) || aconstNull.type != 0) { - throw new RuntimeException("Unexpected instruction: " + aconstNull) - } - - constructor.instructions.remove(aconstNull) - - // Push first parameter of constructor (the ObjectFactory) onto the stack. - // This has the effect of calling super(objectFactory) - //constructor.instructions.insertBefore(superInvoc, new VarInsnNode(Opcodes.ALOAD, 1)) - - ClassWriter writer = new ClassWriter(0) - node.accept(writer) - - def outputFile = outputDir.resolve(gradleRepositoryAdapter.toPath()).toFile() - - outputFile.parentFile.mkdirs() - FileOutputStream fs = new FileOutputStream(outputFile) - fs.write(writer.toByteArray()) } } -task patchConstructor(type: PatchGradleRepositoryAdapter) { - constructorName = _constructorName - constructorDesc = _constructorDesc - modifiedSuperDesc = _modifiedSuperDesc - classesDir = classesDirs.toFile() - outputDir = Paths.get(buildDir.toString(), "modifiedclasses") - gradleRepositoryAdapter = gradleRepositoryAdapterPath.toFile() -} + jar { from sourceSets.api.output from sourceSets.shared.output - from(sourceSets.gradlecomp.output) { - exclude gradleRepositoryAdapterPath.toString() - } + from(sourceSets.gradlecomp.output) - from patchConstructor.outputs - into('META-INF/versions/9') { from project(':artifactural9').sourceSets.java9.output } @@ -229,38 +107,6 @@ jar { } } -jar.doLast { - def jarPath = it.outputs.files.getFiles().first() - def jarFile = new JarFile(jarPath) - def entry = jarFile.getEntry(gradleRepositoryAdapterPath.toString().replace('\\', '/')) - def stream = jarFile.getInputStream(entry) - - ClassReader reader = new ClassReader(stream) - ClassNode node = new ClassNode() - reader.accept(node, 0) - - def constructor = node.methods.find { - it.name == _constructorName && it.desc == _constructorDesc - } - - def superInvoc = constructor.instructions.find { - it instanceof MethodInsnNode && it.owner == "org/gradle/api/internal/artifacts/repositories/AbstractArtifactRepository" - } as MethodInsnNode - - if (superInvoc.desc == _modifiedSuperDesc) { - println("Successfully modified super() call!") - } else { - throw new RuntimeException("Failed to modify super() invocation - got desc of " + superInvoc.desc) - } - - def getDescriptor = node.methods.find { it.name == "getDescriptor"} - if (getDescriptor != null) { - throw new RuntimeException("Failed to remove getDescriptor with signature: " + getDescriptor.signature) - } else { - println("Successfully stripped getDescriptor method!") - } -} - task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.api.allSource @@ -321,7 +167,3 @@ publishing { } } -if (!JavaVersion.current().java9Compatible) { - println("You must build this with JDK 9") - System.exit(1) -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differindex 0d4a951..e708b1c 100644 --- a/gradle/wrapper/gradle-wrapper.jar +++ b/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e7105d..da9702f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu Apr 25 19:18:54 EDT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# 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 +# +# https://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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index e95643d..ac1b06f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation. goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/src/gradlecomp/java/com/amadornes/artifactural/gradle/Gradle410RepositoryAdapter.java b/src/gradlecomp/java/com/amadornes/artifactural/gradle/Gradle410RepositoryAdapter.java deleted file mode 100644 index ceaf989..0000000 --- a/src/gradlecomp/java/com/amadornes/artifactural/gradle/Gradle410RepositoryAdapter.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Artifactural - * Copyright (c) 2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package com.amadornes.artifactural.gradle; - -import com.amadornes.artifactural.api.repository.Repository; -import org.gradle.api.internal.artifacts.repositories.DefaultMavenLocalArtifactRepository; -import org.gradle.api.internal.artifacts.repositories.descriptor.FlatDirRepositoryDescriptor; -import org.gradle.api.internal.artifacts.repositories.descriptor.RepositoryDescriptor; -import org.gradle.api.model.ObjectFactory; - -import java.util.ArrayList; - -public class Gradle410RepositoryAdapter extends GradleRepositoryAdapter { - - Gradle410RepositoryAdapter(ObjectFactory objectFactory, Repository repository, DefaultMavenLocalArtifactRepository local) { - super(objectFactory, repository, local); - } - - - @Override - public RepositoryDescriptor getDescriptor() { - return new FlatDirRepositoryDescriptor("ArtifacturalRepository", new ArrayList<>()); - } - -} diff --git a/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java b/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java index 669ad4c..51def33 100644 --- a/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java +++ b/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java @@ -31,6 +31,7 @@ import org.gradle.api.artifacts.component.ComponentArtifactIdentifier; import org.gradle.api.artifacts.component.ModuleComponentIdentifier; import org.gradle.api.artifacts.dsl.RepositoryHandler; 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.resolveengine.artifact.ResolvableArtifact; @@ -52,9 +53,11 @@ 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.ModuleSource; +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.BuildableArtifactSetResolveResult; import org.gradle.internal.resolve.result.BuildableComponentArtifactsResolveResult; @@ -68,7 +71,6 @@ 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; @@ -92,16 +94,7 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen GradleRepositoryAdapter repo; - // On Gradle 4.10 above, we need to use the constructor with the 'ObjectFactory' parameter - // (which can be safely passed as null - see BaseMavenInstaller). - // We use Gradle410RepositoryAdapter, which actually overrides 'getDescriptor' - if (GradleVersion.current().compareTo(GradleVersion.version("4.10")) >= 0) { - repo = new Gradle410RepositoryAdapter(null, repository, maven); - } else { - // On versions of gradle older than 4.10, we use the no-arg super constructor - repo = new GradleRepositoryAdapter(repository, maven); - } - + repo = new GradleRepositoryAdapter(repository, maven); repo.setName(name); handler.add(repo); return repo; @@ -171,6 +164,13 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen @Override public boolean isDynamicResolveMode() { return resolver.isDynamicResolveMode(); } @Override public boolean isLocal() { return resolver.isLocal(); } + @Override + public void setComponentResolvers(ComponentResolvers resolver) { } + @Override + public Instantiator getComponentMetadataInstantiator() { + return resolver.getComponentMetadataInstantiator(); + } + private ModuleComponentRepositoryAccess wrap(ModuleComponentRepositoryAccess delegate) { return new ModuleComponentRepositoryAccess() { @Override @@ -188,13 +188,13 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen } @Override - public void listModuleVersions(ModuleDependencyMetadata dependency, BuildableModuleVersionListingResolveResult result) { - delegate.listModuleVersions(dependency, result); + public void resolveArtifacts(ComponentResolveMetadata component, ConfigurationMetadata variant, BuildableComponentArtifactsResolveResult result) { + delegate.resolveArtifacts(component, variant, result); } @Override - public void resolveArtifacts(ComponentResolveMetadata component, BuildableComponentArtifactsResolveResult result) { - delegate.resolveArtifacts(component, result); + public void listModuleVersions(ModuleDependencyMetadata dependency, BuildableModuleVersionListingResolveResult result) { + delegate.listModuleVersions(dependency, result); } @Override @@ -203,10 +203,11 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen } @Override - public void resolveArtifact(ComponentArtifactMetadata artifact, ModuleSource moduleSource, BuildableArtifactResolveResult result) { - delegate.resolveArtifact(artifact, moduleSource, result); + public void resolveArtifact(ComponentArtifactMetadata artifact, ModuleSources moduleSources, BuildableArtifactResolveResult result) { + delegate.resolveArtifact(artifact, moduleSources, result); } + @Override public MetadataFetchingCost estimateMetadataFetchingCost(ModuleComponentIdentifier moduleComponentIdentifier) { return delegate.estimateMetadataFetchingCost(moduleComponentIdentifier); @@ -216,21 +217,8 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen }; } - // This method will be deleted entirely in build.gradle - // In order for this class to compile, this method needs to exist - // at compile-time. However, the class 'RepositoryDescriptor' doesn't - // exist in Gradle 4.9. If we try to classload a class - // that contains RepositoryDescriptor as a method return type, - // the JVM will try to classload RepositoryDescriptor, leading - // to a NoClassDefFoundError - - // To fix this, we strip out this method at build time. - // At runtime, we instantiate Gradle410RepositoryAdapter - // when we're running on Gradle 4.10 on above. - // This ensures that 'getDescriptor' exists on Gradle 4.10, - // and doesn't existon Gradle 4.9 public RepositoryDescriptor getDescriptor() { - throw new Error("This method should be been stripped at build time!"); + return new FlatDirRepositoryDescriptor("ArtifacturalRepository", new ArrayList<>()); } diff --git a/src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java b/src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java index 9ee484c..1bef580 100644 --- a/src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java +++ b/src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java @@ -21,8 +21,6 @@ package com.amadornes.artifactural.gradle; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.function.Function; import java.util.function.UnaryOperator; public class ReflectionUtils { diff --git a/src/shared/java/com/amadornes/artifactural/base/util/HashFunction.java b/src/shared/java/com/amadornes/artifactural/base/util/HashFunction.java index 61119e7..9fe4ea9 100644 --- a/src/shared/java/com/amadornes/artifactural/base/util/HashFunction.java +++ b/src/shared/java/com/amadornes/artifactural/base/util/HashFunction.java @@ -30,8 +30,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Locale; -import org.apache.commons.io.IOUtils; - //These are all standard hashing functions the JRE is REQUIRED to have, so add a nice factory that doesnt require catching annoying exceptions; public enum HashFunction { MD5("md5", 32), @@ -43,7 +41,8 @@ public enum HashFunction { private HashFunction(String algo, int length) { this.algo = algo; - this.pad = String.format("%0" + length + "d", 0); + // must specify locale to get correct number formatting + this.pad = String.format(Locale.ENGLISH, "%0" + length + "d", 0); } public String getExtension() { @@ -90,7 +89,12 @@ public enum HashFunction { } public String hash(InputStream stream) throws IOException { - return hash(IOUtils.toByteArray(stream)); + MessageDigest hash = get(); + byte[] buf = new byte[1024]; + int count = -1; + while ((count = stream.read(buf)) != -1) + hash.update(buf, 0, count); + return pad(new BigInteger(1, hash.digest()).toString(16)); } public String hash(byte[] data) { |