Skip to content

Commit

Permalink
[lang] Error when too old version of SARL is on the classpath.
Browse files Browse the repository at this point in the history
see #363

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Nov 25, 2015
1 parent 763cb9f commit c0cc43a
Show file tree
Hide file tree
Showing 14 changed files with 345 additions and 33 deletions.
3 changes: 2 additions & 1 deletion plugins/io.sarl.lang.core/META-INF/MANIFEST.MF
Expand Up @@ -7,7 +7,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.xtext.xbase.lib;bundle-version="2.8.4";visibility:=reexport,
javax.inject;bundle-version="1.0.0";visibility:=reexport
Export-Package: io.sarl.lang.annotation,
Export-Package: io.sarl.lang,
io.sarl.lang.annotation,
io.sarl.lang.core,
io.sarl.lang.scoping.batch,
io.sarl.lang.util
Expand Down
3 changes: 2 additions & 1 deletion plugins/io.sarl.lang.core/build.properties
@@ -1,4 +1,5 @@
source.. = src/
source.. = src/,\
src-gen/
bin.includes = META-INF/,\
.,\
OSGI-INF/
Expand Down
42 changes: 42 additions & 0 deletions plugins/io.sarl.lang.core/pom.xml
Expand Up @@ -27,6 +27,48 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<basedir>${project.basedir}/src-templates</basedir>
<outputDir>../src-gen</outputDir>
<includes>
<include>**/*.java</include>
</includes>
<replacements>
<replacement>
<token>@sarlspecificationreleaseversion@</token>
<value>${sarlspecificationreleaseversion}</value>
</replacement>
<replacement>
<token>@sarlreleaseversion@</token>
<value>${sarlreleaseversion}</value>
</replacement>
<replacement>
<token>@sarlspecificationreleasestatus@</token>
<value>${sarlspecificationreleasestatus}</value>
</replacement>
<replacement>
<token>@sarlisstableversion@</token>
<value>${sarlisstableversion}</value>
</replacement>
<replacement>
<token>@janusversion@</token>
<value>${janusversion}</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down
71 changes: 71 additions & 0 deletions plugins/io.sarl.lang.core/src-gen/io/sarl/lang/SARLVersion.java
@@ -0,0 +1,71 @@
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2015 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.lang;


/**
* Describes the specification of the SARL language.
*
* @author $Author: sgalland$
* @version $FullVersion$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
* @since 0.3.0
*/
public final class SARLVersion {

/** Version number of the SARL specification.
*
* <p>The version number is usually composed of two digits that
* represent the version of the SARL specification and tools.
*/
public static final String SPECIFICATION_RELEASE_VERSION = "0.3"; //$NON-NLS-1$

/** The version number of the current release of the SARL library.
*
* <p>Usually, the two first digits are the same as the ones of {@link #SPECIFICATION_RELEASE_VERSION}.
*/
public static final String SARL_RELEASE_VERSION = "0.3.0"; //$NON-NLS-1$

/** The status of the SARL specification.
*
* <p>Usually, this status is also displayed in the
* <a href="http://www.sarl.io/docs/suite/io/sarl/docs/SARLDocumentationSuite.html">reference documentation of SARL</a>.
*/
public static final String RELEASE_STATUS = "Draft Release"; //$NON-NLS-1$

/** Flag that indicates if the current SARL libbrary is a stable release.
*
* <p>A stable release is collection of libraries that will be not more compiled and generated.
*/
public static final boolean IS_STABLE = false;

/** The version number of the Janus platform that should support the current version
* of the SARL tools.
*/
public static final String PRECONIZED_JANUS_VERSION = "2.0.3.0-SNAPSHOT"; //$NON-NLS-1$

private SARLVersion() {
//
}

}
@@ -0,0 +1,71 @@
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2015 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.lang;


/**
* Describes the specification of the SARL language.
*
* @author $Author: sgalland$
* @version $FullVersion$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
* @since 0.3.0
*/
public final class SARLVersion {

/** Version number of the SARL specification.
*
* <p>The version number is usually composed of two digits that
* represent the version of the SARL specification and tools.
*/
public static final String SPECIFICATION_RELEASE_VERSION = "@sarlspecificationreleaseversion@"; //$NON-NLS-1$

/** The version number of the current release of the SARL library.
*
* <p>Usually, the two first digits are the same as the ones of {@link #SPECIFICATION_RELEASE_VERSION}.
*/
public static final String SARL_RELEASE_VERSION = "@sarlreleaseversion@"; //$NON-NLS-1$

/** The status of the SARL specification.
*
* <p>Usually, this status is also displayed in the
* <a href="http://www.sarl.io/docs/suite/io/sarl/docs/SARLDocumentationSuite.html">reference documentation of SARL</a>.
*/
public static final String RELEASE_STATUS = "@sarlspecificationreleasestatus@"; //$NON-NLS-1$

/** Flag that indicates if the current SARL libbrary is a stable release.
*
* <p>A stable release is collection of libraries that will be not more compiled and generated.
*/
public static final boolean IS_STABLE = @sarlisstableversion@;

/** The version number of the Janus platform that should support the current version
* of the SARL tools.
*/
public static final String PRECONIZED_JANUS_VERSION = "@janusversion@"; //$NON-NLS-1$

private SARLVersion() {
//
}

}
Expand Up @@ -351,6 +351,10 @@ protected void initialize(XtendClass source, JvmGenericType inferredJvmType) {
if (Strings.isNullOrEmpty(source.getName())) {
return;
}
// Issue #363: do not generate the agent if the SARL library is incompatible.
if (!Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) {
return;
}
openContext(inferredJvmType);
try {
super.initialize(source, inferredJvmType);
Expand All @@ -367,6 +371,10 @@ protected void initialize(XtendAnnotationType source, JvmAnnotationType inferred
if (Strings.isNullOrEmpty(source.getName())) {
return;
}
// Issue #363: do not generate the agent if the SARL library is incompatible.
if (!Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) {
return;
}
openContext(inferredJvmType);
try {
super.initialize(source, inferredJvmType);
Expand All @@ -383,6 +391,10 @@ protected void initialize(XtendInterface source, JvmGenericType inferredJvmType)
if (Strings.isNullOrEmpty(source.getName())) {
return;
}
// Issue #363: do not generate the agent if the SARL library is incompatible.
if (!Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) {
return;
}
openContext(inferredJvmType);
try {
super.initialize(source, inferredJvmType);
Expand All @@ -399,6 +411,10 @@ protected void initialize(XtendEnum source, JvmEnumerationType inferredJvmType)
if (Strings.isNullOrEmpty(source.getName())) {
return;
}
// Issue #363: do not generate the agent if the SARL library is incompatible.
if (!Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) {
return;
}
openContext(inferredJvmType);
try {
super.initialize(source, inferredJvmType);
Expand Down Expand Up @@ -451,11 +467,14 @@ public boolean isSupportedMember(XtendMember member) {
// Generate the extended types.
appendConstrainedExtends(context, inferredJvmType, Agent.class, source.getExtends());

// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
// Issue #363: do not generate the agent if the SARL library is incompatible.
if (Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) {
// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
}

// Add the default constructors for the agent, if not already added
if (!context.hasConstructor()) {
Expand Down Expand Up @@ -543,11 +562,14 @@ public boolean isSupportedMember(XtendMember member) {
// Generate the extended types.
appendConstrainedExtends(context, inferredJvmType, Behavior.class, source.getExtends());

// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
// Issue #363: do not generate the agent if the SARL library is incompatible.
if (Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) {
// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
}

// Add the default constructors for the behavior, if not already added

Expand Down Expand Up @@ -619,11 +641,14 @@ public boolean isSupportedMember(XtendMember member) {
// Generate the extended types.
appendConstrainedExtends(context, inferredJvmType, Event.class, source.getExtends());

// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
// Issue #363: do not generate the agent if the SARL library is incompatible.
if (Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) {
// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
}

if (!context.hasConstructor()) {
// Add the default constructors for the behavior, if not already added
Expand Down Expand Up @@ -719,11 +744,14 @@ public boolean isSupportedMember(XtendMember member) {
appendConstrainedExtends(context, inferredJvmType, Skill.class, source.getExtends());
appendConstrainedImplements(context, inferredJvmType, Capacity.class, source.getImplements());

// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
// Issue #363: do not generate the agent if the SARL library is incompatible.
if (Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) {
// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
}

// Add the default constructors for the behavior, if not already added
if (!context.hasConstructor()) {
Expand Down Expand Up @@ -803,11 +831,14 @@ public boolean isSupportedMember(XtendMember member) {
// Generate the extended types.
appendConstrainedExtends(context, inferredJvmType, Capacity.class, source.getExtends());

// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
// Issue #363: do not generate the agent if the SARL library is incompatible.
if (Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) {
// Generate the members of the generated type.
appendSarlMembers(
inferredJvmType,
source,
context);
}

// Resolving any name conflict with the generated JVM type
this.nameClashResolver.resolveNameClashes(inferredJvmType);
Expand Down

0 comments on commit c0cc43a

Please sign in to comment.