commit:     e024794b5f61201fc1db11fdfc40fa05b03125ed
Author:     zongyu <zzy2529420793 <AT> gmail <DOT> com>
AuthorDate: Wed Aug 19 08:02:07 2020 +0000
Commit:     Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
CommitDate: Wed Aug 19 08:07:40 2020 +0000
URL:        https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=e024794b

recognize and write JAVA_NEEDS_TOOLS automatically

Signed-off-by: zongyu <zzy2529420793 <AT> gmail.com>

 .../gentoo/java/ebuilder/maven/MavenEbuilder.java  |  3 +++
 .../gentoo/java/ebuilder/maven/MavenProject.java   | 31 ++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java 
b/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java
index b16a64e..c1e84d1 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java
@@ -749,6 +749,7 @@ public class MavenEbuilder {
         // JAVA_CLASSPATH_EXTRA
         // JAVA_TEST_GENTOO_CLASSPATH
         // JAVA_ENCODING (unless it differs in projects)
+        // JAVA_NEED_TOOLS
         // Compile (jars, doc):
         // JAVA_SRC_DIR
         // JAVA_RESOURCE_DIRS
@@ -878,6 +879,8 @@ public class MavenEbuilder {
             writer.println('"');
         }
 
+        writer.print(mavenProject.getExtraJars(config.getStdoutWriter()));
+
         writer.print("JAVA_SRC_DIR=\"");
         writer.print(replaceWithVars(config.getWorkdir().relativize(
                 mavenProject.getSourceDirectory()).toString(), config));

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 794f992..b7553b0 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
@@ -423,6 +423,37 @@ public class MavenProject {
         this.sourceVersion = sourceVersion;
     }
 
+    /**
+     * deal with scope == "system" dependencies
+     *
+     * @return lines of ebuild variables
+     */
+    @SuppressWarnings("unchecked")
+    public String getExtraJars(final PrintWriter writer) {
+        String ret = "";
+        List<MavenDependency> systemDependencies = getDependencies(new 
String[]{"system"});
+
+        for (final MavenDependency dependency : systemDependencies) {
+            switch (dependency.getGroupId()) {
+                case "com.sun":
+                    switch (dependency.getArtifactId()) {
+                        case "tools":
+                            ret += "JAVA_NEEDS_TOOLS=1\n";
+                            break;
+                        default:
+                            writer.println("Equivalent variable for " +
+                                dependency.getArtifactId() + " not found.");
+                    }
+                    break;
+                default:
+                    writer.println("Equivalent variable for " +
+                            dependency.getGroupId() + " not found.");
+            }
+        }
+
+        return ret;
+    }
+
     /**
      * Getter for {@link #targetVersion}.
      *

Reply via email to