karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggrzy...@apache.org
Subject [karaf] 10/13: [KARAF-5468] Adjust JavaVersion enum: supportsEndorsedAndExtLibraries()
Date Tue, 05 Dec 2017 21:58:07 GMT
This is an automated email from the ASF dual-hosted git repository.

ggrzybek pushed a commit to branch KARAF-5376-overrides_v2
in repository https://gitbox.apache.org/repos/asf/karaf.git

commit 40a8e79ae1a3ace90b58f09e76f8d644ee020f2e
Author: Grzegorz Grzybek <gr.grzybek@gmail.com>
AuthorDate: Mon Nov 27 09:01:12 2017 +0100

    [KARAF-5468] Adjust JavaVersion enum: supportsEndorsedAndExtLibraries()
---
 .../main/java/org/apache/karaf/profile/assembly/Builder.java | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index aedc8eb..8a41a76 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -185,12 +185,14 @@ public class Builder {
      * supported versions are defined.</p>
      */
     public enum JavaVersion {
-        Java16("1.6"), Java17("1.7"), Java18("1.8"), Java9("9");
+        Java16("1.6", 1), Java17("1.7", 2), Java18("1.8", 3), Java9("9", 4);
 
         private String version;
+        private int ordinal;
 
-        JavaVersion(String version) {
+        JavaVersion(String version, int ordinal) {
             this.version = version;
+            this.ordinal = ordinal;
         }
 
         public static JavaVersion from(String version) {
@@ -203,6 +205,10 @@ public class Builder {
             }
             return v.get();
         }
+
+        public boolean supportsEndorsedAndExtLibraries() {
+            return this.ordinal < Java9.ordinal;
+        }
     }
 
     /**
@@ -1256,7 +1262,7 @@ public class Builder {
             }
             final String type = clause.getDirective(LIBRARY_CLAUSE_TYPE) != null
                     ? clause.getDirective(LIBRARY_CLAUSE_TYPE) : Library.TYPE_DEFAULT;
-            if (!javase.startsWith("1.") && (Library.TYPE_ENDORSED.equals(type) ||
Library.TYPE_EXTENSION.equals(type))) {
+            if (!javase.supportsEndorsedAndExtLibraries() && (Library.TYPE_ENDORSED.equals(type)
|| Library.TYPE_EXTENSION.equals(type))) {
                 LOGGER.warn("Ignoring library " + library + " of type " + type + " which
is only supported for Java 1.8.");
                 continue;
             }

-- 
To stop receiving notification emails like this one, please contact
"commits@karaf.apache.org" <commits@karaf.apache.org>.

Mime
View raw message