You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by pi...@apache.org on 2012/05/09 06:08:30 UTC

svn commit: r1335919 - /karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java

Author: pieber
Date: Wed May  9 04:08:30 2012
New Revision: 1335919

URL: http://svn.apache.org/viewvc?rev=1335919&view=rev
Log:
[KARAF-1452] Make karaf-maven-plugin compile with jdk7

There where some minor API incompatibilities fixed by this patch between
jdk6 and jdk7.

Signed-off-by: Andreas Pieber <an...@gmail.com>

Modified:
    karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java

Modified: karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java?rev=1335919&r1=1335918&r2=1335919&view=diff
==============================================================================
--- karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java (original)
+++ karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java Wed May  9 04:08:30 2012
@@ -266,7 +266,9 @@ public class InstallKarsMojo extends Moj
         }
 
         // install bundles listed in startup properties that weren't in kars into the system dir
-        for (String key : startupProperties.keySet()) {
+        Set keySet = startupProperties.keySet();
+        for (Object keyObject : keySet) {
+            String key = (String) keyObject;
             String path = MavenUtil.pathFromMaven(key);
             File target = new File(system.resolve(path));
             if (!target.exists()) {
@@ -393,7 +395,7 @@ public class InstallKarsMojo extends Moj
                     } finally {
                         in.close();
                     }
-                    String existingFeatureRepos = properties.containsKey(FEATURES_REPOSITORIES) && !((String) properties.get(FEATURES_REPOSITORIES)).isEmpty() ? properties.get(FEATURES_REPOSITORIES) + "," : "";
+                    String existingFeatureRepos = retrieveProperty(properties, FEATURES_REPOSITORIES);
                     if (!existingFeatureRepos.contains(uri.toString())) {
                         existingFeatureRepos = existingFeatureRepos + uri.toString();
                         properties.put(FEATURES_REPOSITORIES, existingFeatureRepos);
@@ -404,7 +406,7 @@ public class InstallKarsMojo extends Moj
                             installFeature(feature, null);
                         } else if (bootFeatures != null && bootFeatures.contains(feature.getName())) {
                             localRepoFeatures.add(feature);
-                            String existingBootFeatures = properties.containsKey(FEATURES_BOOT) && !((String) properties.get(FEATURES_BOOT)).isEmpty() ? properties.get(FEATURES_BOOT) + "," : "";
+                            String existingBootFeatures = retrieveProperty(properties, FEATURES_BOOT);
                             if (!existingBootFeatures.contains(feature.getName())) {
                                 existingBootFeatures = existingBootFeatures + feature.getName();
                                 properties.put(FEATURES_BOOT, existingBootFeatures);
@@ -429,6 +431,10 @@ public class InstallKarsMojo extends Moj
             }
         }
 
+        private String retrieveProperty(Properties properties, String key) {
+            return properties.containsKey(key) && properties.get(key) != null ?  properties.get(key) + "," : "";
+        }
+
         private Features readFeatures(URI uri) throws XMLStreamException, JAXBException, IOException {
             File repoFile;
             if (uri.toString().startsWith("mvn:")) {
@@ -479,7 +485,7 @@ public class InstallKarsMojo extends Moj
                 String location = bundle.getLocation();
                 String startLevel = Integer.toString(bundle.getStartLevel() == 0 ? defaultStartLevel : bundle.getStartLevel());
                 if (startupProperties.containsKey(location)) {
-                    int oldStartLevel = Integer.decode(startupProperties.get(location));
+                    int oldStartLevel = Integer.decode((String)startupProperties.get(location));
                     if (oldStartLevel > bundle.getStartLevel()) {
                         startupProperties.put(location, startLevel);
                     }