aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmadornes <amadornes@gmail.com>2018-08-19 00:19:38 +0200
committerAmadornes <amadornes@gmail.com>2018-08-19 00:19:38 +0200
commit897a13a65e5e4e94b73276753255ba3b7e2a9087 (patch)
treecb7a91386e1071b0f9b70b8084022b9bee0a2a06
parent8f22509fd04c5b1124bda533cf276dd1a34c31bf (diff)
downloadArtifactural-897a13a65e5e4e94b73276753255ba3b7e2a9087.tar.gz
Artifactural-897a13a65e5e4e94b73276753255ba3b7e2a9087.tar.bz2
Artifactural-897a13a65e5e4e94b73276753255ba3b7e2a9087.zip
Fixed dependencies on gradle repackaged libs
-rw-r--r--build.gradle31
-rw-r--r--src/gradlecomp/java/com/amadornes/artifactural/gradle/DependencyResolver.java28
-rw-r--r--src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java23
-rw-r--r--src/gradlecomp/java/com/amadornes/artifactural/gradle/ReflectionUtils.java4
-rw-r--r--src/shared/java/com/amadornes/artifactural/base/artifact/SimpleArtifactIdentifier.java (renamed from src/shared/java/com/amadornes/artifactural/base/artifact/ArtifactIdentifierImpl.java)4
5 files changed, 68 insertions, 22 deletions
diff --git a/build.gradle b/build.gradle
index 64c4c30..3f6f986 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,13 +1,12 @@
apply plugin: 'java'
-apply plugin: 'idea'
group = 'com.amadornes.artifactural'
version = '1.0.0'
sourceSets {
api
- shared
- gradlecomp
+ shared
+ gradlecomp
}
repositories {
@@ -15,15 +14,29 @@ repositories {
mavenCentral()
}
+configurations {
+ sharedImplementation.extendsFrom apiImplementation
+ gradlecompImplementation.extendsFrom sharedImplementation
+
+ compile.extendsFrom sharedImplementation
+ compile.extendsFrom gradlecompImplementation
+}
+
dependencies {
sharedImplementation sourceSets.api.output
-
- gradlecompImplementation sourceSets.api.output
+
gradlecompImplementation sourceSets.shared.output
gradlecompImplementation gradleApi()
-
- compile sourceSets.api.output
- compile sourceSets.shared.output
- compile sourceSets.gradlecomp.output
+ gradlecompImplementation 'com.google.guava:guava:26.0-jre'
+ gradlecompImplementation 'commons-io:commons-io:2.4'
+
+ compile sourceSets.api.output
+ compile sourceSets.shared.output
+ compile sourceSets.gradlecomp.output
}
+jar {
+ from sourceSets.api.output
+ from sourceSets.shared.output
+ from sourceSets.gradlecomp.output
+}
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);
diff --git a/src/shared/java/com/amadornes/artifactural/base/artifact/ArtifactIdentifierImpl.java b/src/shared/java/com/amadornes/artifactural/base/artifact/SimpleArtifactIdentifier.java
index 26acd29..231f68b 100644
--- a/src/shared/java/com/amadornes/artifactural/base/artifact/ArtifactIdentifierImpl.java
+++ b/src/shared/java/com/amadornes/artifactural/base/artifact/SimpleArtifactIdentifier.java
@@ -2,11 +2,11 @@ package com.amadornes.artifactural.base.artifact;
import com.amadornes.artifactural.api.artifact.ArtifactIdentifier;
-public class ArtifactIdentifierImpl implements ArtifactIdentifier {
+public class SimpleArtifactIdentifier implements ArtifactIdentifier {
private final String group, name, version, classifier, extension;
- public ArtifactIdentifierImpl(String group, String name, String version, String classifier, String extension) {
+ public SimpleArtifactIdentifier(String group, String name, String version, String classifier, String extension) {
this.group = group;
this.name = name;
this.version = version;