diff --git a/scriptbuilder/pom.xml b/scriptbuilder/pom.xml index b4e7084928..02f747f714 100644 --- a/scriptbuilder/pom.xml +++ b/scriptbuilder/pom.xml @@ -34,8 +34,20 @@ org.jclouds.scriptbuilder.functionloader.osgi.Activator - org.jclouds.scriptbuilder*;version="${project.version}" - org.jclouds*;version="${project.version}",* + org.jclouds.scriptbuilder*;version="${project.version}";-noimport:=true + + + javax.inject*;resolution:=optional, + org.jclouds.domain*;version="${project.version}";resolution:=optional, + org.jclouds.javax.annotation*;version="${project.version}";resolution:=optional, + org.jclouds*;version="${project.version}", + * + diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/util/Utils.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/util/Utils.java index 4c20dff569..bbada9118a 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/util/Utils.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/util/Utils.java @@ -24,7 +24,6 @@ import java.util.regex.Pattern; import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.scriptbuilder.domain.ShellToken; import org.jclouds.scriptbuilder.functionloader.CurrentFunctionLoader; -import org.jclouds.util.Maps2; import com.google.common.base.CaseFormat; import com.google.common.base.Function; @@ -32,6 +31,8 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Utilities used to build init scripts. * @@ -112,7 +113,7 @@ public class Utils { * @see VariableNameForOsFamily */ public static String writeVariableExporters(Map exports, final OsFamily family) { - exports = Maps2.transformKeys(exports, new VariableNameForOsFamily(family)); + exports = transformKeys(exports, new VariableNameForOsFamily(family)); return replaceTokens(writeVariableExporters(exports), ShellToken.tokenValueMap(family)); } @@ -207,4 +208,23 @@ public class Utils { public static String writeComment(String comment, OsFamily family) { return String.format("%s%s%s", ShellToken.REM.to(family), comment, ShellToken.LF.to(family)); } + + /** + * change the keys but keep the values in-tact. + * + * @param input key type + * @param output key type + * @param value type + * @param in input map to transform + * @param fn how to transform the values + * @return immutableMap with the new keys. + */ + public static Map transformKeys(Map in, Function fn) { + checkNotNull(in, "input map"); + checkNotNull(fn, "function"); + ImmutableMap.Builder returnVal = ImmutableMap.builder(); + for (Entry entry : in.entrySet()) + returnVal.put(fn.apply(entry.getKey()), entry.getValue()); + return returnVal.build(); + } }