diff options
author | Amadornes <amadornes@gmail.com> | 2018-08-19 00:19:38 +0200 |
---|---|---|
committer | Amadornes <amadornes@gmail.com> | 2018-08-19 00:19:38 +0200 |
commit | 897a13a65e5e4e94b73276753255ba3b7e2a9087 (patch) | |
tree | cb7a91386e1071b0f9b70b8084022b9bee0a2a06 /src/gradlecomp | |
parent | 8f22509fd04c5b1124bda533cf276dd1a34c31bf (diff) | |
download | Artifactural-897a13a65e5e4e94b73276753255ba3b7e2a9087.tar.gz Artifactural-897a13a65e5e4e94b73276753255ba3b7e2a9087.tar.bz2 Artifactural-897a13a65e5e4e94b73276753255ba3b7e2a9087.zip |
Fixed dependencies on gradle repackaged libs
Diffstat (limited to 'src/gradlecomp')
3 files changed, 44 insertions, 11 deletions
diff --git a/src/gradlecomp/java/com/amadornes/artifactural/gradle/DependencyResolver.java b/src/gradlecomp/java/com/amadornes/artifactural/gradle/DependencyResolver.java index 12364d7..b97de78 100644 --- a/src/gradlecomp/java/com/amadornes/artifactural/gradle/DependencyResolver.java +++ b/src/gradlecomp/java/com/amadornes/artifactural/gradle/DependencyResolver.java @@ -1,9 +1,14 @@ package com.amadornes.artifactural.gradle; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import org.gradle.api.Project; -import org.gradle.api.artifacts.*; -import org.gradle.internal.impldep.com.google.common.cache.Cache; -import org.gradle.internal.impldep.com.google.common.cache.CacheBuilder; +import org.gradle.api.artifacts.ClientModule; +import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.Dependency; +import org.gradle.api.artifacts.DependencyArtifact; +import org.gradle.api.artifacts.FileCollectionDependency; +import org.gradle.api.artifacts.ModuleDependency; import java.io.File; import java.util.Set; @@ -72,6 +77,15 @@ public class DependencyResolver { * Resolves a dependency, downloading the file and its transitives * if not cached and returns the set of files. */ + public Set<File> resolveDependency(Object dependency) { + Dependency dep = project.getDependencies().create(dependency); + return resolveDependency(dep); + } + + /** + * Resolves a dependency, downloading the file and its transitives + * if not cached and returns the set of files. + */ public Set<File> resolveDependency(Object dependency, boolean transitive) { Dependency dep = project.getDependencies().create(dependency); if (dep instanceof ClientModule) { @@ -80,4 +94,12 @@ public class DependencyResolver { return resolveDependency(dep); } + /** + * Resolves a single dependency without any of its transitives + * if not cached and returns the file. + */ + public File resolveSingleDependency(Object dependency) { + return resolveDependency(dependency, false).iterator().next(); + } + } diff --git a/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java b/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java index a601a1e..4bac887 100644 --- a/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java +++ b/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java @@ -3,7 +3,9 @@ package com.amadornes.artifactural.gradle; import com.amadornes.artifactural.api.artifact.Artifact; import com.amadornes.artifactural.api.artifact.ArtifactIdentifier; import com.amadornes.artifactural.api.repository.Repository; -import com.amadornes.artifactural.base.artifact.ArtifactIdentifierImpl; +import com.amadornes.artifactural.base.artifact.SimpleArtifactIdentifier; +import com.google.common.io.CountingInputStream; +import org.apache.commons.io.IOUtils; import org.gradle.api.Action; import org.gradle.api.NamedDomainObjectCollection; import org.gradle.api.Transformer; @@ -18,14 +20,23 @@ import org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceA import org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver; import org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver; import org.gradle.api.resources.ResourceException; -import org.gradle.internal.impldep.com.google.common.io.CountingInputStream; -import org.gradle.internal.impldep.org.apache.commons.io.IOUtils; -import org.gradle.internal.resource.*; +import org.gradle.internal.resource.AbstractExternalResource; +import org.gradle.internal.resource.ExternalResource; +import org.gradle.internal.resource.ExternalResourceName; +import org.gradle.internal.resource.ExternalResourceReadResult; +import org.gradle.internal.resource.ExternalResourceRepository; +import org.gradle.internal.resource.ExternalResourceWriteResult; +import org.gradle.internal.resource.ReadableContent; +import org.gradle.internal.resource.ResourceExceptions; import org.gradle.internal.resource.metadata.DefaultExternalResourceMetaData; import org.gradle.internal.resource.metadata.ExternalResourceMetaData; import javax.annotation.Nullable; -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URI; import java.util.List; import java.util.regex.Matcher; @@ -104,7 +115,7 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen URI uri = name.getUri(); Matcher matcher = URL_PATTERN.matcher(uri.getPath()); if (!matcher.matches()) return new NullExternalResource(uri); - ArtifactIdentifier identifier = new ArtifactIdentifierImpl( + ArtifactIdentifier identifier = new SimpleArtifactIdentifier( matcher.group("group").replace('/', '.'), matcher.group("name"), matcher.group("version"), diff --git a/src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java b/src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java index 4fbe925..5dcb9a3 100644 --- a/src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java +++ b/src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java @@ -12,12 +12,12 @@ public class ReflectionUtils { Field f = null; for (String n : name.split("\\.")) { f = findField(target.getClass(), n); - if(f == null) throw new IllegalStateException("Could not find '" + name + "'"); + if (f == null) throw new IllegalStateException("Could not find '" + name + "'"); f.setAccessible(true); prev = target; target = f.get(target); } - if(f == null) throw new IllegalStateException("Could not find '" + name + "'"); + if (f == null) throw new IllegalStateException("Could not find '" + name + "'"); f.set(prev, operator.apply((T) target)); } catch (IllegalAccessException ex) { throw new RuntimeException(ex); |