aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gradlecomp/java/com/amadornes/artifactural/gradle/Gradle410RepositoryAdapter.java42
-rw-r--r--src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java52
-rw-r--r--src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java2
-rw-r--r--src/shared/java/com/amadornes/artifactural/base/util/HashFunction.java12
4 files changed, 28 insertions, 80 deletions
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) {