Skip to content

Commit

Permalink
Fix dependency conflict "InjectionManagerFactory not found"
Browse files Browse the repository at this point in the history
Fix #9

Change-Id: I83f2074c431994f72a62e37ab4a6086c3142a1b5
  • Loading branch information
Linary authored and zhoney committed Dec 24, 2018
1 parent 476bb78 commit 6f20cb8
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 3 deletions.
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.baidu.hugegraph</groupId>
<artifactId>hugegraph-common</artifactId>
<version>1.5.3</version>
<version>1.5.4</version>

<name>hugegraph-common</name>
<url>https://github.com/hugegraph/hugegraph-common</url>
Expand Down Expand Up @@ -67,6 +67,7 @@
<jsr305.version>3.0.1</jsr305.version>
<javassist.version>3.21.0-GA</javassist.version>
<jersey.version>2.25.1</jersey.version>
<jersey.hk2.version>2.27</jersey.hk2.version>
<junit.version>4.12</junit.version>
</properties>

Expand Down Expand Up @@ -155,6 +156,11 @@
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey.hk2.version}</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -192,7 +198,7 @@
<manifestEntries>
<!-- Must be on one line, otherwise the automatic
upgrade script cannot replace the version number -->
<Implementation-Version>1.5.3.0</Implementation-Version>
<Implementation-Version>1.5.4.0</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/com/baidu/hugegraph/util/VersionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

package com.baidu.hugegraph.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
Expand Down Expand Up @@ -86,6 +88,38 @@ public static String getImplementationVersion(Class<?> clazz) {
.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
}

/**
* Get version from pom.xml
* @return The pom version
*/
public static String getPomVersion() {
String cmd = "mvn help:evaluate -Dexpression=project.version " +
"-q -DforceStdout";
Process process = null;
InputStreamReader isr = null;
try {
process = Runtime.getRuntime().exec(cmd);
process.waitFor();

isr = new InputStreamReader(process.getInputStream());
BufferedReader br = new BufferedReader(isr);
return br.readLine();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (isr != null) {
try {
isr.close();
} catch (Exception ignored) {}
}

// Destroy child process
if (process != null) {
process.destroy();
}
}
}

/**
* class Version for compare
* https://stackoverflow.com/questions/198431/how-do-you-compare-two-version-strings-in-java
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/baidu/hugegraph/version/CommonVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ public class CommonVersion {

public static final String NAME = "hugegraph-common";

public static final Version VERSION = Version.of(CommonVersion.class);
// The second parameter of Version.of() is for all-in-one JAR
public static final Version VERSION = Version.of(CommonVersion.class,
"1.5.4");
}
37 changes: 37 additions & 0 deletions src/test/java/com/baidu/hugegraph/unit/version/VersionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2017 HugeGraph Authors
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

package com.baidu.hugegraph.unit.version;

import org.junit.Test;

import com.baidu.hugegraph.testutil.Assert;
import com.baidu.hugegraph.util.VersionUtil;
import com.baidu.hugegraph.version.CommonVersion;

public class VersionTest {

@Test
public void testGetCommonVersion() {
String version = CommonVersion.VERSION.get();
Assert.assertNotNull(version);
String pomVersion = VersionUtil.getPomVersion();
Assert.assertEquals(version, pomVersion);
}
}

0 comments on commit 6f20cb8

Please sign in to comment.