aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLexManos <LexManos@gmail.com>2018-11-07 16:09:09 -0800
committerLexManos <LexManos@gmail.com>2018-11-07 16:09:09 -0800
commit37d713bdb7459cdd44707b350fd12fd59517b415 (patch)
tree6d500b4c8c040ab65ff17a51382a6bd2271210c6 /src
parent564ddae6a4dbc6946092821183708283356c618d (diff)
downloadArtifactural-37d713bdb7459cdd44707b350fd12fd59517b415.tar.gz
Artifactural-37d713bdb7459cdd44707b350fd12fd59517b415.tar.bz2
Artifactural-37d713bdb7459cdd44707b350fd12fd59517b415.zip
Allow repos to provide maven-metadata.xml files to list known versions.
Diffstat (limited to 'src')
-rw-r--r--src/api/java/com/amadornes/artifactural/api/repository/Repository.java15
-rw-r--r--src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java17
2 files changed, 29 insertions, 3 deletions
diff --git a/src/api/java/com/amadornes/artifactural/api/repository/Repository.java b/src/api/java/com/amadornes/artifactural/api/repository/Repository.java
index da8aa69..2e1de79 100644
--- a/src/api/java/com/amadornes/artifactural/api/repository/Repository.java
+++ b/src/api/java/com/amadornes/artifactural/api/repository/Repository.java
@@ -19,6 +19,8 @@
package com.amadornes.artifactural.api.repository;
+import java.io.File;
+
import com.amadornes.artifactural.api.artifact.Artifact;
import com.amadornes.artifactural.api.artifact.ArtifactIdentifier;
@@ -26,4 +28,17 @@ public interface Repository {
Artifact getArtifact(ArtifactIdentifier identifier);
+ /**
+ * Returns a file in maven-metadata.xml format for the specified artifact,
+ * this is used by gradle to list all known versions, so that it can resolve wildcard
+ * dependencies such as foo:bar:1.+
+ *
+ * @param group Group
+ * @param name Artifact name
+ * @return maven-metadata.xml file listing all versions of the artifact this repo can provide. Or null if you don't want to list any.
+ */
+ default File getMavenMetadata(String group, String name) {
+ return null;
+ }
+
}
diff --git a/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java b/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java
index 834905c..64d6652 100644
--- a/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java
+++ b/src/gradlecomp/java/com/amadornes/artifactural/gradle/GradleRepositoryAdapter.java
@@ -236,9 +236,7 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
String relative = path.substring(root.length());
debug(" Relative: " + relative);
Matcher matcher = URL_PATTERN.matcher(relative);
- if (!matcher.matches()) {
- log(" Matcher Failed: " + relative);
- } else {
+ if (matcher.matches()) {
ArtifactIdentifier identifier = new SimpleArtifactIdentifier(
matcher.group("group").replace('/', '.'),
matcher.group("name"),
@@ -247,6 +245,19 @@ public class GradleRepositoryAdapter extends AbstractArtifactRepository implemen
matcher.group("extension"));
Artifact artifact = repository.getArtifact(identifier);
return wrap(artifact, identifier);
+ } else if (relative.endsWith("maven-metadata.xml")) {
+ String tmp = relative.substring(0, relative.length() - "maven-metadata.xml".length() - 1);
+ int idx = tmp.lastIndexOf('/');
+ if (idx != -1) {
+ File ret = repository.getMavenMetadata(tmp.substring(0, idx - 1), tmp.substring(idx));
+ if (ret != null) {
+ return new LocalFileStandInExternalResource(ret, fileSystem);
+ }
+ }
+ } else if (relative.endsWith("/")) {
+ debug(" Directory listing not supported");
+ } else {
+ log(" Matcher Failed: " + relative);
}
} else {
log("Unknown root: " + path);