diff options
author | 2019-11-02 22:32:16 +0100 | |
---|---|---|
committer | 2019-11-02 22:32:16 +0100 | |
commit | 1673958029040f3368d310341832db6d03c18c9c (patch) | |
tree | 8f09797552ca53a3d95b7b197ff7d61f2df4b7b8 | |
parent | enhanced maven cache so that it also contains main java eclass + added java e... (diff) | |
download | java-ebuilder-1673958029040f3368d310341832db6d03c18c9c.tar.gz java-ebuilder-1673958029040f3368d310341832db6d03c18c9c.tar.bz2 java-ebuilder-1673958029040f3368d310341832db6d03c18c9c.zip |
added option for dumping parsed projects
Signed-off-by: Miroslav Šulc <fordfrog@gentoo.org>
-rw-r--r-- | src/main/java/org/gentoo/java/ebuilder/Config.java | 22 | ||||
-rw-r--r-- | src/main/java/org/gentoo/java/ebuilder/Main.java | 28 | ||||
-rw-r--r-- | src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java | 75 | ||||
-rw-r--r-- | src/main/resources/usage.txt | 2 |
4 files changed, 127 insertions, 0 deletions
diff --git a/src/main/java/org/gentoo/java/ebuilder/Config.java b/src/main/java/org/gentoo/java/ebuilder/Config.java index 9bc98f8..3bf8cb8 100644 --- a/src/main/java/org/gentoo/java/ebuilder/Config.java +++ b/src/main/java/org/gentoo/java/ebuilder/Config.java @@ -25,6 +25,10 @@ public class Config { */ private URI downloadUri; /** + * Whether to output information about parsed projects. + */ + private boolean dumpProjects; + /** * Path to ebuild file that should be generated. */ private Path ebuild; @@ -328,6 +332,24 @@ public class Config { } /** + * Getter for {@link #dumpProjects}. + * + * @return {@link #dumpProjects} + */ + public boolean isDumpProjects() { + return dumpProjects; + } + + /** + * Setter for {@link #dumpProjects}. + * + * @param dumpProjects {@link #dumpProjects} + */ + public void setDumpProjects(final boolean dumpProjects) { + this.dumpProjects = dumpProjects; + } + + /** * Getter for {@link #generateEbuild}. * * @return {@link #generateEbuild} diff --git a/src/main/java/org/gentoo/java/ebuilder/Main.java b/src/main/java/org/gentoo/java/ebuilder/Main.java index bb6fbd7..871ac2a 100644 --- a/src/main/java/org/gentoo/java/ebuilder/Main.java +++ b/src/main/java/org/gentoo/java/ebuilder/Main.java @@ -126,6 +126,9 @@ public class Main { } else if (config.getDownloadUri() != null) { config.getErrorWriter().println("WARNING: Download URI is used " + "only when generating ebuild."); + } else if (config.isDumpProjects()) { + config.getErrorWriter().println("WARNING: Dumping of projects can " + + "be used only when generating ebuild."); } else if (config.getEbuild() != null) { config.getErrorWriter().println( "WARNING: Ebuild is used only when " @@ -155,6 +158,23 @@ public class Main { } } + private static void dumpMavenProjects(final Config config, + final List<MavenProject> mavenProjects) { + int i = 0; + + for (final MavenProject mavenProject : mavenProjects) { + config.getStdoutWriter().println(MessageFormat.format( + "\n===== PROJECT {0} DUMP START =====", i)); + mavenProject.dump(config.getStdoutWriter()); + config.getStdoutWriter().println(MessageFormat.format( + "===== PROJECT {0} DUMP END =====", i)); + + i++; + } + + config.getStdoutWriter().println(); + } + /** * Processed generation of ebuild. * @@ -170,6 +190,10 @@ public class Main { final List<MavenProject> mavenProjects = mavenParser.parsePomFiles(config, mavenCache); + if (config.isDumpProjects()) { + dumpMavenProjects(config, mavenProjects); + } + final MavenEbuilder mavenEbuilder = new MavenEbuilder(); mavenEbuilder.generateEbuild(config, mavenProjects, mavenCache); } @@ -198,6 +222,10 @@ public class Main { } break; + case "--dump-projects": + case "-d": + config.setDumpProjects(true); + break; case "--ebuild": case "-e": i++; diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java index ba575b1..6d0d8ec 100644 --- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java +++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java @@ -1,5 +1,6 @@ package org.gentoo.java.ebuilder.maven; +import java.io.PrintWriter; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; @@ -122,6 +123,80 @@ public class MavenProject { } /** + * Outputs project properties to the writer. + * + * @param writer writer + */ + public void dump(final PrintWriter writer) { + writer.print("POM file: "); + writer.println(pomFile); + writer.print("groupId: "); + writer.println(groupId); + writer.print("artifactId: "); + writer.println(artifactId); + writer.print("version: "); + writer.println(version); + writer.print("description: "); + writer.println(description); + writer.print("homepage: "); + writer.println(homepage); + writer.print("mainClass: "); + writer.println(mainClass); + writer.print("sourceVersion: "); + writer.println(sourceVersion); + writer.print("targetVersion: "); + writer.println(targetVersion); + writer.print("sourceEncoding: "); + writer.println(sourceEncoding); + writer.print("sourceDirectory: "); + writer.println(sourceDirectory); + writer.print("hasResources: "); + writer.println(hasResources); + + writer.print("resourceDirectories:"); + + if (resourceDirectories != null) { + resourceDirectories.forEach((resourceDirectory) -> { + writer.print(" "); + writer.println(resourceDirectory); + }); + } + + writer.print("hasTests: "); + writer.println(hasTests); + writer.print("testSourceDirectory: "); + writer.println(testSourceDirectory); + writer.print("hasTestResources: "); + writer.println(hasTestResources); + + writer.println("testResourceDirectories:"); + + testResourceDirectories.forEach((testResourceDirectory) -> { + writer.print(" "); + writer.println(testResourceDirectory); + }); + + writer.println("dependencies:"); + + if (dependencies != null) { + dependencies.forEach((dependency) -> { + writer.print("\n groupId: "); + writer.println(dependency.getGroupId()); + writer.print(" artifactId: "); + writer.println(dependency.getArtifactId()); + writer.print(" mavenVersion: "); + writer.println(dependency.getMavenVersion()); + writer.print(" scope: "); + writer.println(dependency.getScope()); + writer.print(" systemDependency: "); + writer.println(dependency.getSystemDependency()); + writer.print(" version: "); + writer.println(dependency.getVersion()); + }); + } + } + + /** * Getter for {@link #artifactId}. * * @return {@link #artifactId} diff --git a/src/main/resources/usage.txt b/src/main/resources/usage.txt index 4ad06d7..fc2689f 100644 --- a/src/main/resources/usage.txt +++ b/src/main/resources/usage.txt @@ -2,6 +2,8 @@ Usage: java-ebuilder <args> Generating ebuild: --download-uri|-u <uri> uri that goes to SRC_URI +--dump-projects|-d outputs information about parsed projects (useful + for debugging) --ebuild|-e <file> path to ebuild that should be created --generate-ebuild|-g generates ebuild from pom.xml --keywords|-k <keywords> arch keywords |