Skip to content

Commit

Permalink
[util] Remove the dependency to com.google.inject.
Browse files Browse the repository at this point in the history
This dependency introduces the Guava version 19.0.0, and the other SARL
libraries depends on Guava 18.0.0.

This issue may be solved by Issue #572 indirectly.

close #638.

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Apr 7, 2017
1 parent e36c5ac commit a6cb650
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 69 deletions.
3 changes: 1 addition & 2 deletions main/apiplugins/io.sarl.util/META-INF/MANIFEST.MF
Expand Up @@ -9,6 +9,5 @@ Export-Package: io.sarl.eventdispatching,
io.sarl.sarlspecification,
io.sarl.util
Require-Bundle: io.sarl.lang.core;bundle-version="0.6.0";visibility:=reexport,
org.eclipse.osgi;bundle-version="3.11.3",
com.google.inject;bundle-version="4.1.0"
org.eclipse.osgi;bundle-version="3.11.3"

Expand Up @@ -21,8 +21,9 @@

package io.sarl.sarlspecification

import com.google.inject.ImplementedBy
import org.osgi.framework.Version

import io.sarl.lang.^annotation.SarlSpecification
import io.sarl.lang.SARLVersion

/** Check if a given agent class follows a specific version of the SARL specifications.
Expand All @@ -33,7 +34,6 @@ import io.sarl.lang.SARLVersion
* @mavenartifactid $ArtifactId$
* @since 0.5
*/
@ImplementedBy(typeof(StandardSarlSpecificationChecker))
interface SarlSpecificationChecker {

/** Replies the supported SARL specification version of the given type.
Expand All @@ -43,7 +43,25 @@ interface SarlSpecificationChecker {
* {@link SARLVersion#SPECIFICATION_RELEASE_VERSION}. The value {@link Float#NaN} is replied
* if the given type has no marker related to the SARL specification version.
*/
def getSarlSpecificationVersion(type : Class<?>) : float
def getSarlSpecificationVersion(type : Class<?>) : float {
if (type !== null) {
var annotationInstance = type.getAnnotation(typeof(SarlSpecification))
if (annotationInstance !== null) {
val versionString = annotationInstance.value
val version = Version::parseVersion(versionString)
if (Version::emptyVersion != version) {
var minor = version.minor
var factor = 1f
while (minor > 0) {
factor *= 10
minor /= 10
}
return version.major + version.minor / factor
}
}
}
return Float::NaN
}

/** Compare the SARL specification version associated to the given type to the version of the
* current SARL.
Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions main/features/io.sarl.lib/feature.xml
Expand Up @@ -223,10 +223,9 @@

<requires>
<import plugin="io.sarl.lang.core" version="0.6.0" match="greaterOrEqual"/>
<import plugin="com.google.inject" version="4.1.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.osgi" version="3.11.3" match="greaterOrEqual"/>
<import plugin="org.eclipse.xtext.xbase.lib" version="2.11.0" match="greaterOrEqual"/>
<import plugin="javax.inject" version="1.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.osgi" version="3.11.3" match="greaterOrEqual"/>
</requires>

<plugin
Expand Down
Expand Up @@ -29,7 +29,7 @@

import io.sarl.lang.SARLVersion;
import io.sarl.lang.annotation.SarlSpecification;
import io.sarl.sarlspecification.StandardSarlSpecificationChecker;
import io.sarl.sarlspecification.SarlSpecificationChecker;

/**
* @author $Author: sgalland$
Expand All @@ -40,11 +40,11 @@
@SuppressWarnings("all")
public class StandardSarlSpecificationCheckerTest {

private StandardSarlSpecificationChecker checker;
private SarlSpecificationChecker checker;

@Before
public void setUp() {
this.checker = new StandardSarlSpecificationChecker();
this.checker = new SarlSpecificationChecker() {};
}

@After
Expand Down

0 comments on commit a6cb650

Please sign in to comment.