Elffuss BraidHub

kikocis/java-driver public

Merge pull request #494 from datastax/osgiExampleUpdate-3.0

Update OSGi example guava versions. Refine bundle version detection.
Changeset82f0202f1f0c71a63728e56009765173d5bb14775324316dcd08022f33f2f659
AuthorAlexandre Dutra <alexdut@gmail.com> · 2015-10-28 11:59 +01:00
CommitterAlexandre Dutra <alexdut@gmail.com> · 2015-10-28 11:59 +01:00
Parents52598c92fd08, 85df6a78b838

Browse the files at this changeset

2 files changed

modified driver-examples/osgi/src/test/java/com/datastax/driver/osgi/MailboxServiceIT.java +1 −21
@@ -54,7 +54,7 @@
5454 }
5555
5656 private MavenArtifactProvisionOption guavaBundle() {
57- return mavenBundle("com.google.guava", "guava", "14.0.1");
57+ return mavenBundle("com.google.guava", "guava", "16.0.1");
5858 }
5959
6060 private CompositeOption nettyBundles() {
@@ -109,26 +109,6 @@
109109 );
110110 }
111111
112- @Configuration
113- public Option[] guava15Config() {
114- return options(
115- driverBundle(),
116- nettyBundles(),
117- guavaBundle().version("15.0"),
118- defaultOptions()
119- );
120- }
121-
122- @Configuration
123- public Option[] guava16Config() {
124- return options(
125- driverBundle(),
126- nettyBundles(),
127- guavaBundle().version("16.0.1"),
128- defaultOptions()
129- );
130- }
131-
132112 @Configuration
133113 public Option[] guava17Config() {
134114 return options(
modified driver-examples/osgi/src/test/java/com/datastax/driver/osgi/VersionProvider.java +19 −2
@@ -15,6 +15,9 @@
1515 */
1616 package com.datastax.driver.osgi;
1717
18+import java.util.regex.Matcher;
19+import java.util.regex.Pattern;
20+
1821 import com.jcabi.manifests.Manifests;
1922
2023 /**
@@ -25,11 +28,25 @@
2528 */
2629 public class VersionProvider {
2730
28- private static String PROJECT_VERSION;
31+ private static final Pattern versionPattern = Pattern.compile(("(\\d+.\\d+\\.\\d+)(.*)"));
32+
33+ private static final String PROJECT_VERSION;
2934 static {
3035 String bundleName = Manifests.read("Bundle-SymbolicName");
3136 if (bundleName.equals("com.datastax.driver.osgi")) {
32- PROJECT_VERSION = Manifests.read("Bundle-Version").replaceAll("\\.SNAPSHOT", "-SNAPSHOT");
37+ String bundleVersion = Manifests.read("Bundle-Version");
38+ Matcher matcher = versionPattern.matcher(bundleVersion);
39+ if(matcher.matches()) {
40+ String majorVersion = matcher.group(1);
41+ // Replace all instances of '.' after the main version with '-' to properly
42+ // resolve the correct version.
43+ String rest = matcher.group(2).replaceAll("\\.", "-");
44+ PROJECT_VERSION = majorVersion + rest;
45+ } else {
46+ // This should never happen, but if we are using a non X.Y.Z version number
47+ // we'll just back off to the bundle version.
48+ PROJECT_VERSION = bundleVersion;
49+ }
3350 } else {
3451 throw new RuntimeException("Couldn't resolve bundle manifest (try building with mvn compile)");
3552 }