From 0ca23d7d0b5bf3ede39b02b569e2749e0d9ebb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Mon, 17 Nov 2014 13:36:37 -0800 Subject: [PATCH] use Druid version as the default version for extensions --- .../druid/initialization/Initialization.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/io/druid/initialization/Initialization.java b/server/src/main/java/io/druid/initialization/Initialization.java index 76786946cde..735391558ba 100644 --- a/server/src/main/java/io/druid/initialization/Initialization.java +++ b/server/src/main/java/io/druid/initialization/Initialization.java @@ -93,6 +93,9 @@ import java.util.Set; */ public class Initialization { + // default version to use for extensions without version info + private static final String DEFAULT_VERSION = Initialization.class.getPackage().getImplementationVersion(); + private static final Logger log = new Logger(Initialization.class); private static final Map loadersMap = Maps.newHashMap(); @@ -166,7 +169,22 @@ public class Initialization URLClassLoader loader = loadersMap.get(coordinate); if (loader == null) { final CollectRequest collectRequest = new CollectRequest(); - collectRequest.setRoot(new Dependency(new DefaultArtifact(coordinate), JavaScopes.RUNTIME)); + + DefaultArtifact versionedArtifact; + try { + // this will throw an exception if no version is specified + versionedArtifact = new DefaultArtifact(coordinate); + } + catch (IllegalArgumentException e) { + // try appending the default version so we can specify artifacts without versions + if (DEFAULT_VERSION != null) { + versionedArtifact = new DefaultArtifact(coordinate + ":" + DEFAULT_VERSION); + } else { + throw e; + } + } + + collectRequest.setRoot(new Dependency(versionedArtifact, JavaScopes.RUNTIME)); DependencyRequest dependencyRequest = new DependencyRequest( collectRequest, DependencyFilterUtils.andFilter(