Revision: 20059
http://sourceforge.net/p/gate/code/20059
Author: markagreenwood
Date: 2017-02-02 10:57:04 +0000 (Thu, 02 Feb 2017)
Log Message:
-----------
support for multiple workspaces by chaining them together so that maven only
ever sees the top one
Modified Paths:
--------------
gate/branches/sawdust2/gate-core/src/main/java/gate/util/maven/SimpleMavenCache.java
Modified:
gate/branches/sawdust2/gate-core/src/main/java/gate/util/maven/SimpleMavenCache.java
===================================================================
---
gate/branches/sawdust2/gate-core/src/main/java/gate/util/maven/SimpleMavenCache.java
2017-02-02 10:02:32 UTC (rev 20058)
+++
gate/branches/sawdust2/gate-core/src/main/java/gate/util/maven/SimpleMavenCache.java
2017-02-02 10:57:04 UTC (rev 20059)
@@ -8,6 +8,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.apache.commons.io.FileUtils;
@@ -32,16 +33,23 @@
private static final long serialVersionUID = 8612094868614282978L;
- private File root;
+ private File head;
+ private SimpleMavenCache tail;
+
private transient WorkspaceRepository repo;
- public SimpleMavenCache(File root) {
- this.root = root;
+ public SimpleMavenCache(File head, File... tail) {
+ this.head = head;
+
+ if (tail.length > 0) {
+ this.tail = new SimpleMavenCache(tail[0],
+ tail.length == 1 ? new File[] {} :
Arrays.copyOfRange(tail, 1, tail.length - 1));
+ }
}
private File getArtifactFile(Artifact artifact) {
- File file = root;
+ File file = head;
for (String part : artifact.getGroupId().split("\\.")) {
file = new File(file, part);
@@ -61,16 +69,23 @@
File file = getArtifactFile(artifact);
- if (!file.exists())
+ if (file.exists())
+ return file;
+
+ if (tail == null)
return null;
- return file;
+ return tail.findArtifact(artifact);
}
@Override
public List<String> findVersions(Artifact artifact) {
List<String> versions = new ArrayList<String>();
+ if (tail != null) {
+ versions.addAll(tail.findVersions(artifact));
+ }
+
File file =
getArtifactFile(artifact).getParentFile().getParentFile();
if (!file.exists() || !file.isDirectory())
@@ -105,7 +120,7 @@
File file = getArtifactFile(ar.getArtifact());
// file.getParentFile().mkdirs();
- System.out.println(ar.getArtifact().getFile());
+ //System.out.println(ar.getArtifact().getFile());
FileUtils.copyFile(ar.getArtifact().getFile(), file);
}
@@ -135,7 +150,10 @@
reader.cacheArtifact(artifactObj);
System.out.println(reader.findArtifact(artifactObj));
System.out.println(reader.findVersions(artifactObj));
-
+
+ reader = new SimpleMavenCache(new File("repo2"), new
File("repo"));
+ System.out.println(reader.findArtifact(artifactObj));
+ System.out.println(reader.findVersions(artifactObj));
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs