From a6cb6505599a6b8cde350756f8d8734989e70ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Galland?= Date: Fri, 7 Apr 2017 17:02:19 +0200 Subject: [PATCH] [util] Remove the dependency to com.google.inject. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../io.sarl.util/META-INF/MANIFEST.MF | 3 +- .../SarlSpecificationChecker.sarl | 24 +++++++- .../StandardSarlSpecificationChecker.sarl | 59 ------------------- main/features/io.sarl.lib/feature.xml | 3 +- .../StandardSarlSpecificationCheckerTest.java | 6 +- 5 files changed, 26 insertions(+), 69 deletions(-) delete mode 100644 main/apiplugins/io.sarl.util/src/io/sarl/sarlspecification/StandardSarlSpecificationChecker.sarl diff --git a/main/apiplugins/io.sarl.util/META-INF/MANIFEST.MF b/main/apiplugins/io.sarl.util/META-INF/MANIFEST.MF index cec0d14c48..a696390ac6 100644 --- a/main/apiplugins/io.sarl.util/META-INF/MANIFEST.MF +++ b/main/apiplugins/io.sarl.util/META-INF/MANIFEST.MF @@ -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" diff --git a/main/apiplugins/io.sarl.util/src/io/sarl/sarlspecification/SarlSpecificationChecker.sarl b/main/apiplugins/io.sarl.util/src/io/sarl/sarlspecification/SarlSpecificationChecker.sarl index 43f3223e45..119328b21d 100644 --- a/main/apiplugins/io.sarl.util/src/io/sarl/sarlspecification/SarlSpecificationChecker.sarl +++ b/main/apiplugins/io.sarl.util/src/io/sarl/sarlspecification/SarlSpecificationChecker.sarl @@ -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. @@ -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. @@ -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. diff --git a/main/apiplugins/io.sarl.util/src/io/sarl/sarlspecification/StandardSarlSpecificationChecker.sarl b/main/apiplugins/io.sarl.util/src/io/sarl/sarlspecification/StandardSarlSpecificationChecker.sarl deleted file mode 100644 index 47950817b9..0000000000 --- a/main/apiplugins/io.sarl.util/src/io/sarl/sarlspecification/StandardSarlSpecificationChecker.sarl +++ /dev/null @@ -1,59 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2017 the original authors or authors. - * - * Licensed 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 io.sarl.sarlspecification - -import org.osgi.framework.Version - -import io.sarl.lang.^annotation.SarlSpecification - -/** Check if a given agent class follows a specific version of the SARL specifications. - * - * @author $Author: ssgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.5 - */ -class StandardSarlSpecificationChecker implements SarlSpecificationChecker { - - override 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 - } - -} - diff --git a/main/features/io.sarl.lib/feature.xml b/main/features/io.sarl.lib/feature.xml index 06abab4d4c..dad9b63d6d 100644 --- a/main/features/io.sarl.lib/feature.xml +++ b/main/features/io.sarl.lib/feature.xml @@ -223,10 +223,9 @@ - + -