diff options
author | 2020-08-20 18:50:38 +0800 | |
---|---|---|
committer | 2020-08-20 22:04:15 +0800 | |
commit | 3012503417562f24f1479c10bde1b86da1917817 (patch) | |
tree | beb0591e5d19f904871768f637e6749ab4a900e1 | |
parent | Distinguish "dev-java/junit:0" and "dev-java/junit-4" (diff) | |
download | java-ebuilder-3012503417562f24f1479c10bde1b86da1917817.tar.gz java-ebuilder-3012503417562f24f1479c10bde1b86da1917817.tar.bz2 java-ebuilder-3012503417562f24f1479c10bde1b86da1917817.zip |
accept multiple --portage-trees while generating cache
Signed-off-by: zongyu <zzy2529420793@gmail.com>
-rw-r--r-- | src/main/java/org/gentoo/java/ebuilder/Config.java | 10 | ||||
-rw-r--r-- | src/main/java/org/gentoo/java/ebuilder/Main.java | 19 | ||||
-rw-r--r-- | src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java | 8 | ||||
-rw-r--r-- | src/main/resources/usage.txt | 4 |
4 files changed, 23 insertions, 18 deletions
diff --git a/src/main/java/org/gentoo/java/ebuilder/Config.java b/src/main/java/org/gentoo/java/ebuilder/Config.java index 4502ab3..e9396ca 100644 --- a/src/main/java/org/gentoo/java/ebuilder/Config.java +++ b/src/main/java/org/gentoo/java/ebuilder/Config.java @@ -88,7 +88,7 @@ public class Config { /** * Path to portage tree. */ - private Path portageTree; + private SortedSet<Path> portageTree = new TreeSet<>(); /** * Whether ebuild cache should be refreshed. */ @@ -365,17 +365,17 @@ public class Config { * * @return {@link #portageTree} */ - public Path getPortageTree() { + public SortedSet<Path> getPortageTree() { return portageTree; } /** - * Setter for {@link #portageTree}. + * Add portageTrees to {@link #portageTree}. * * @param portageTree {@link #portageTree} */ - public void setPortageTree(final Path portageTree) { - this.portageTree = portageTree; + public void addPortageTree(final Path portageTree) { + this.portageTree.add(portageTree); } /** diff --git a/src/main/java/org/gentoo/java/ebuilder/Main.java b/src/main/java/org/gentoo/java/ebuilder/Main.java index 999f741..6aaf24a 100644 --- a/src/main/java/org/gentoo/java/ebuilder/Main.java +++ b/src/main/java/org/gentoo/java/ebuilder/Main.java @@ -7,6 +7,7 @@ import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Path; import java.nio.file.Paths; import java.text.MessageFormat; import java.util.List; @@ -63,16 +64,18 @@ public class Main { */ private static void checkArgs(final Config config) { if (config.isRefreshCache()) { - if (config.getPortageTree() == null) { - config.setPortageTree(Paths.get("/usr/portage")); + if (config.getPortageTree().isEmpty()) { + config.addPortageTree(Paths.get("/usr/portage")); } - if (!config.getPortageTree().toFile().exists()) { - config.getErrorWriter().println("ERROR: Portage tree " - + config.getPortageTree() + " does not exist."); - Runtime.getRuntime().exit(1); + for (Path portageTree : config.getPortageTree()) { + if (!portageTree.toFile().exists()) { + config.getErrorWriter().println("ERROR: Portage tree " + + portageTree + " does not exist."); + Runtime.getRuntime().exit(1); + } } - } else if (config.getPortageTree() != null) { + } else if (!config.getPortageTree().isEmpty()) { config.getErrorWriter().println("WARNING: Portage tree is used " + "only when refreshing cache."); } @@ -277,7 +280,7 @@ public class Main { case "--portage-tree": case "-t": i++; - config.setPortageTree(Paths.get(args[i]).toAbsolutePath(). + config.addPortageTree(Paths.get(args[i]).toAbsolutePath(). normalize()); break; case "--cache-file": diff --git a/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java b/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java index b48e0d2..a1a7075 100644 --- a/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java +++ b/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java @@ -139,9 +139,11 @@ public class PortageParser { processedEbuilds = 0; eclassesCounts.clear(); - config.getStdoutWriter().println("Parsing portage tree @ " - + config.getPortageTree() + " ..."); - parseCategories(config.getPortageTree()); + for (Path portageTree : config.getPortageTree()) { + config.getStdoutWriter().println("Parsing portage tree @ " + + portageTree + " ..."); + parseCategories(portageTree); + } final long endTimestamp = System.currentTimeMillis(); diff --git a/src/main/resources/usage.txt b/src/main/resources/usage.txt index e48e3f9..b197a39 100644 --- a/src/main/resources/usage.txt +++ b/src/main/resources/usage.txt @@ -22,8 +22,8 @@ Generating ebuild: Refreshing cache: --portage-tree|-t path to portage tree that should be parsed - when refreshing cache (default is - /usr/portage) + when refreshing cache (can be specified multiple + times, default is /usr/portage) --refresh-cache|-c refreshes java ebuild cache Common: |