From c32ddba23d15df950a2673e94f35897cf5c01b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Galland?= Date: Tue, 24 Jul 2018 10:35:05 +0200 Subject: [PATCH] [all] Upgrade to AFC 15.0. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This version of AFC provides extension modules for SLF4J and Bootique. Signed-off-by: Stéphane Galland --- .../io.sarl.maven.bqextension/pom.xml | 77 ------- .../io/sarl/maven/bqextension/Constants.java | 50 ----- .../maven/bqextension/configs/Config.java | 47 ---- .../maven/bqextension/configs/Configs.java | 201 ------------------ .../modules/AbstractConfigModule.java | 201 ------------------ .../modules/ApplicationMetadataModule.java | 55 ----- .../modules/ApplicationMetadataUpdater.java | 54 ----- .../bqextension/modules/BQConfigTypes.java | 50 ----- .../maven/bqextension/modules/BQModule.java | 48 ----- .../modules/BQModuleOverrides.java | 50 ----- .../modules/DocumentedModuleProvider.java | 154 -------------- .../maven/bqextension/modules/Messages.java | 45 ---- .../bqextension/modules/messages.properties | 1 - main/internalmaven/pom.xml | 1 - pom.xml | 33 ++- 15 files changed, 27 insertions(+), 1040 deletions(-) delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/pom.xml delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/Constants.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/configs/Config.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/configs/Configs.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/AbstractConfigModule.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/ApplicationMetadataModule.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/ApplicationMetadataUpdater.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQConfigTypes.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQModule.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQModuleOverrides.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/DocumentedModuleProvider.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/Messages.java delete mode 100644 main/internalmaven/io.sarl.maven.bqextension/src/main/resources/io/sarl/maven/bqextension/modules/messages.properties diff --git a/main/internalmaven/io.sarl.maven.bqextension/pom.xml b/main/internalmaven/io.sarl.maven.bqextension/pom.xml deleted file mode 100644 index 740158f33d..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ - - 4.0.0 - - io.sarl.maven - io.sarl.maven.internal - 0.8.0-SNAPSHOT - - - io.sarl.maven.bqextension - Extension of Bootique - Extension of the Bootique API. - - - - io.bootique - bootique - - - org.eclipse - osgi - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - ${project.basedir}/src/main/java - - - - - - - - - - - - maven-release-of-sarl-maven-plugin - - - performRelease - true - - - - - - - org.arakhne.afc.maven - tag-replacer - - - ${project.basedir}/src/main/java - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - ${project.build.directory}/generated-sources/java - - - - - - - - - diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/Constants.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/Constants.java deleted file mode 100644 index f56365981c..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/Constants.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension; - -/** Main entry point for the SARL batch compiler. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.5 - */ -public final class Constants { - - /** A conversion pattern for the logger. - */ - public static final String LOGGER_PATTERN = "%-5p %m%n"; //$NON-NLS-1$ - - /** Return code when success. - */ - public static final int SUCCESS_CODE = 0; - - /** Return code when failure. - */ - public static final int ERROR_CODE = 255; - - private Constants() { - // - } - -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/configs/Config.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/configs/Config.java deleted file mode 100644 index 9a7d4f1c10..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/configs/Config.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.configs; - -import io.bootique.annotation.BQConfig; - -/** - * Represents a config that could provide an object representation of itself that - * could be serialized with Yaml exporter. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.8 - */ -@BQConfig("Configuration of the class paths") -public interface Config { - - /** Replies the identifier of the Yaml section. - * - * @return the section name. - */ - default String getSectionName() { - return Configs.getSectionName(getClass()); - } - -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/configs/Configs.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/configs/Configs.java deleted file mode 100644 index b57f4ce7c4..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/configs/Configs.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.configs; - -import java.io.File; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.net.URI; -import java.net.URL; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.google.common.base.Strings; - -/** - * Constants and utilities for all factories. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.8 - */ -public final class Configs { - - /** Prefix {@code sarl.} for properties. - */ - public static final String SARL_ROOT_PROPERTY_PREFIX = "sarl."; //$NON-NLS-1$ - - /** Prefix {@code bq.} for properties. - */ - public static final String BOOTIQUE_PROPERTY_PREFIX = "bq."; //$NON-NLS-1$ - - private Configs() { - // - } - - /** Replies the name of an property that corresponds to the name of a bootique variable. - * - * @param bootiqueVariable the name of the bootique variable. - * @return the name of the property. - */ - public static String toPropertyName(String bootiqueVariable) { - if (Strings.isNullOrEmpty(bootiqueVariable)) { - return null; - } - return BOOTIQUE_PROPERTY_PREFIX + bootiqueVariable; - } - - /** Replies the name of an environment variable that corresponds to the name of a bootique variable. - * - * @param bootiqueVariable the name of the bootique variable. - * @return the name of the environment variable. - */ - public static String toEnvironmentVariableName(String bootiqueVariable) { - if (Strings.isNullOrEmpty(bootiqueVariable)) { - return null; - } - return bootiqueVariable.toUpperCase().replaceAll("[^a-zA-Z0-9_]+", "_"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** Replies the name of an property that corresponds to the name of a bootique variable. - * - * @param bootiqueVariable the name of the bootique variable. - * @return the name of the property. - */ - public static String basename(String bootiqueVariable) { - final int idx = bootiqueVariable.lastIndexOf('.'); - if (idx >= 0) { - return bootiqueVariable.substring(idx + 1); - } - return bootiqueVariable; - } - - /** Add a config to a Yaml configuration map. - * - * @param content the Yaml configuration map. - * @param config the configuration. - */ - public static void defineConfig(Map content, Config config) { - assert content != null; - assert config != null; - final Class type = config.getClass(); - final String sectionName = config.getSectionName(); - final Pattern setPattern = Pattern.compile("^set([A-Z])([a-zA-Z0-9]+)$"); //$NON-NLS-1$ - for (final Method setterMethod : type.getMethods()) { - final Matcher matcher = setPattern.matcher(setterMethod.getName()); - if (matcher.matches()) { - final String firstLetter = matcher.group(1); - final String rest = matcher.group(2); - final String getterName = "get" + firstLetter + rest; //$NON-NLS-1$ - Method getterMethod = null; - try { - getterMethod = type.getMethod(getterName); - } catch (Throwable exception) { - // - } - if (getterMethod != null && Modifier.isPublic(getterMethod.getModifiers()) - && !Modifier.isAbstract(getterMethod.getModifiers()) - && !Modifier.isStatic(getterMethod.getModifiers())) { - try { - final Object value = filterValue(getterMethod.getReturnType(), getterMethod.invoke(config)); - final String id = sectionName + "." + firstLetter.toLowerCase() + rest; //$NON-NLS-1$ - defineScalar(content, id, value); - } catch (Throwable exception) { - // - } - } - } - } - } - - private static Object filterValue(Class type, Object value) { - if (value == null) { - return ""; //$NON-NLS-1$ - } - if (File.class.isAssignableFrom(type)) { - return ((File) value).getAbsolutePath(); - } - if (URI.class.isAssignableFrom(type)) { - return ((URI) value).toString(); - } - if (URL.class.isAssignableFrom(type)) { - return ((URL) value).toExternalForm(); - } - return value; - } - - /** Add a scalar to a Yaml configuration map. - * - * @param content the Yaml configuration map. - * @param bootiqueVariable the name of the bootique variable. - * @param value the value. - * @throws Exception if a map cannot be created internally. - */ - public static void defineScalar(Map content, String bootiqueVariable, Object value) throws Exception { - final String[] elements = bootiqueVariable.split("\\."); //$NON-NLS-1$ - final Map entry = getScalarParent(content, elements); - entry.put(elements[elements.length - 1], value); - } - - @SuppressWarnings("unchecked") - private static Map getScalarParent(Map content, String[] elements) throws Exception { - Map entry = content; - for (int i = 0; i < elements.length - 1; ++i) { - final Object val = entry.get(elements[i]); - if (val instanceof Map) { - entry = (Map) val; - } else { - final Map newElement = content.getClass().newInstance(); - entry.put(elements[i], newElement); - entry = newElement; - } - } - assert entry != null; - return entry; - } - - /** Replies the identifier of the Yaml section. - * - * @param type the configuration type. - * @return the section name. - */ - public static String getSectionName(Class type) { - assert type != null; - try { - final Field field = type.getDeclaredField("PREFIX"); //$NON-NLS-1$ - if (Modifier.isPublic(field.getModifiers()) && String.class.equals(field.getType())) { - final Object value = field.get(null); - if (value != null) { - return value.toString(); - } - } - } catch (Throwable exception) { - // - } - throw new IllegalStateException(); - } - -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/AbstractConfigModule.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/AbstractConfigModule.java deleted file mode 100644 index a5822aa2eb..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/AbstractConfigModule.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.modules; - -import static io.bootique.BQCoreModule.extend; - -import com.google.common.util.concurrent.Service; -import com.google.inject.Binder; -import com.google.inject.Module; -import com.google.inject.binder.AnnotatedBindingBuilder; -import com.google.inject.multibindings.Multibinder; -import io.bootique.ConfigModule; -import io.bootique.command.Command; -import io.bootique.config.ConfigurationFactory; -import io.bootique.meta.application.OptionMetadata; - -import io.sarl.maven.bqextension.configs.Config; -import io.sarl.maven.bqextension.configs.Configs; - -/** Abstract module that has access to its bootique configuration of "sarl.*". - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.8 - */ -public abstract class AbstractConfigModule extends ConfigModule { - - private Binder binder; - - @Override - protected String defaultConfigPrefix() { - return Configs.SARL_ROOT_PROPERTY_PREFIX + CONFIG_PREFIX_BUILDER.toName(getClass()); - } - - /** Replies the configuration accessor. - * - * @param the type of the configuration. - * @param configFactory accessor to the bootique factory. - * @param type the type of the configuration. - * @return the configuration accessor. - */ - protected final T get(ConfigurationFactory configFactory, Class type) { - assert configFactory != null; - assert type != null; - return configFactory.config(type, this.configPrefix); - } - - @Override - public final void configure(Binder builder) { - assert this.binder == null; - assert builder != null; - this.binder = builder; - try { - configure(); - // Automatic registration of the config types. - for (final BQConfigTypes type : getClass().getAnnotationsByType(BQConfigTypes.class)) { - for (final Class configType : type.value()) { - registerConfig(configType); - } - } - } finally { - this.binder = null; - } - } - - /** Configure a binder via the exposed methods. - */ - protected abstract void configure(); - - /** Get the underlying {@code Binder}. - * - * @return the binder. - */ - protected final Binder binder() { - assert this.binder != null : "The binder can only be used inside configure()"; //$NON-NLS-1$ - return this.binder; - } - - /** Adds a dependency from this module to {@code type}. When the injector is - * created, Guice will report an error if {@code type} cannot be injected. - * Note that this requirement may be satisfied by implicit binding, such as - * a public no-arguments constructor. - * - * @param type the required binded type. - */ - protected final void requireBinding(Class type) { - binder().getProvider(type); - } - - /** Adds a dependency from this module to {@code type}. When the injector is - * created, Guice will report an error if {@code type} cannot be injected. - * Note that this requirement may be satisfied by implicit binding, such as - * a public no-arguments constructor. - * The given binder for the set of services is updated with the given {@code type}. - * - * @param type the type of service to bind. - * @param serviceSetBinder the set of services to update. - */ - protected final void requireServiceBinding(Class type, Multibinder serviceSetBinder) { - requireBinding(type); - serviceSetBinder.addBinding().to(type); - } - - /** - * Create an module's instance of the given type and install it. - * - * @param type the type of the module to install. - */ - protected final void install(Class type) { - assert type != null; - try { - install(type.newInstance()); - } catch (InstantiationException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - /** Install the given module. - * - * @param module the module to install. - */ - protected final void install(Module module) { - binder().install(module); - } - - /** Binds the given type. - * - * @param the type to binder. - * @param clazz the type to binder. - * @return the binding builder. - */ - protected final AnnotatedBindingBuilder bind(Class clazz) { - return binder().bind(clazz); - } - - /** Associate the Bootique configuration variable to an environment variable. - * - * @param bootiqueVariable the name of the bootique configuration variable. - */ - protected void associateEnvironmentVariable(String bootiqueVariable) { - extend(binder()).declareVar(bootiqueVariable, Configs.toEnvironmentVariableName(bootiqueVariable)); - } - - /** Associate the Bootique configuration variable to an command line option. - * - * @param opt the description of the option. - */ - protected void associateOption(OptionMetadata.Builder opt) { - extend(binder()).addOption(opt.build()); - } - - /** Associate the Bootique configuration variable to an command line option. - * - * @param bootiqueVariable the name of the bootique configuration variable. - * @param cliOption name of the command line option. - * @param defaultValue the default value. - */ - protected void associateOption(String bootiqueVariable, String cliOption, String defaultValue) { - extend(binder()).addOption(bootiqueVariable, defaultValue, cliOption); - } - - /** Add a command to the bootique. - * - * @param command the command to add. - */ - protected void associateCommand(Class command) { - extend(binder()).addCommand(command); - } - - /** Register a configuration into the set of configs. - * - * @param config the type of the configuration to register. - */ - protected void registerConfig(Class config) { - assert config != null; - final Multibinder exporterBinder = Multibinder.newSetBinder(binder(), Config.class); - exporterBinder.addBinding().to(config); - } - -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/ApplicationMetadataModule.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/ApplicationMetadataModule.java deleted file mode 100644 index 794d368f2c..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/ApplicationMetadataModule.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.modules; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.Singleton; - -/** Module for the compiler application metadata. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.8 - */ -@BQModule("The tools for updating the application metadata.") -public class ApplicationMetadataModule extends AbstractModule { - - @Override - protected void configure() { - // - } - - /** Replies an updater of application metadata. - * - * @return the updater. - */ - @SuppressWarnings("static-method") - @Provides - @Singleton - public ApplicationMetadataUpdater getApplicationMetadataSetter() { - return new ApplicationMetadataUpdater(); - } - -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/ApplicationMetadataUpdater.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/ApplicationMetadataUpdater.java deleted file mode 100644 index 0d0b25b8a4..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/ApplicationMetadataUpdater.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.modules; - -import java.lang.reflect.Field; - -import io.bootique.meta.application.ApplicationMetadata; - -/** Setter of application metadata. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.8 - */ -public class ApplicationMetadataUpdater { - - /** Change the application name. - * - * @param metadata the metadata to change. - * @param name the new name. - */ - @SuppressWarnings("static-method") - public void setName(ApplicationMetadata metadata, String name) { - try { - final Field field = ApplicationMetadata.class.getDeclaredField("name"); //$NON-NLS-1$ - field.setAccessible(true); - field.set(metadata, name); - } catch (Exception exception) { - // - } - } - -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQConfigTypes.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQConfigTypes.java deleted file mode 100644 index b5d7493336..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQConfigTypes.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.modules; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import io.sarl.maven.bqextension.configs.Config; - -/** Annotation for specifying the types of the configs. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.8 - */ -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface BQConfigTypes { - - /** - * The types of the configurations that are linked to the annoted type. - * - * @return the types. - */ - Class[] value() default {}; - -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQModule.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQModule.java deleted file mode 100644 index a602b6aef6..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQModule.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.modules; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Annotation for description of Bootique module. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.8 - */ -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface BQModule { - - /** - * Human-readable module description. - * - * @return a String representing a human-readable module description. - */ - String value() default ""; - -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQModuleOverrides.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQModuleOverrides.java deleted file mode 100644 index e253a87c45..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/BQModuleOverrides.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.modules; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import com.google.inject.Module; - -/** Annotation for specifying the overrides of modules. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.8 - */ -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface BQModuleOverrides { - - /** - * The types of the configurations that are linked to the annoted type. - * - * @return the types. - */ - Class[] value() default {}; - -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/DocumentedModuleProvider.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/DocumentedModuleProvider.java deleted file mode 100644 index b3db5d0cb1..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/DocumentedModuleProvider.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.modules; - -import java.lang.reflect.Type; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.TreeMap; - -import com.google.common.base.Strings; -import com.google.inject.Module; -import io.bootique.BQModule; -import io.bootique.BQModuleProvider; -import io.bootique.Bootique; - -import io.sarl.maven.bqextension.configs.Config; -import io.sarl.maven.bqextension.configs.Configs; - -/** A provider of a BQ module that enables to extract documentation from the module definition itself. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @since 0.8 - */ -public final class DocumentedModuleProvider implements BQModuleProvider { - - private final Class type; - - private String description; - - private Map configs; - - private Collection> overrides; - - private DocumentedModuleProvider(Class type) { - this.type = type; - } - - private DocumentedModuleProvider(Class type, String description) { - this.type = type; - this.description = Strings.nullToEmpty(description); - } - - /** Add the given modules to the provided Bootique instance. - * - * @param bootique the bootique instance. - * @param modules the modules to add. - * @return the bootique instance. - */ - @SafeVarargs - public static Bootique modules(Bootique bootique, Class... modules) { - for (final Class module : modules) { - bootique.module(new DocumentedModuleProvider(module)); - } - return bootique; - } - - /** Add the given module to the provided Bootique instance. - * - * @param bootique the bootique instance. - * @param module the module to add. - * @param description the module's description. - * @return the bootique instance. - */ - public static Bootique module(Bootique bootique, Class module, String description) { - bootique.module(new DocumentedModuleProvider(module, description)); - return bootique; - } - - @Override - public Module module() { - try { - return this.type.getDeclaredConstructor().newInstance(); - } catch (Exception exception) { - throw new RuntimeException(MessageFormat.format(Messages.DocumentedModuleProvider_0, - this.type.getName()), exception); - } - } - - @Override - public BQModule.Builder moduleBuilder() { - return BQModule - .builder(module()) - .overrides(overrides()) - .providerName(name()) - .description(description()) - .configs(configs()); - } - - @Override - public Map configs() { - if (this.configs == null) { - this.configs = new TreeMap<>(); - for (final BQConfigTypes anno : this.type.getAnnotationsByType(BQConfigTypes.class)) { - for (final Class configType : anno.value()) { - this.configs.put(Configs.getSectionName(configType), configType); - } - } - } - return this.configs; - } - - @Override - public Collection> overrides() { - if (this.overrides == null) { - this.overrides = new ArrayList<>(); - for (final BQModuleOverrides anno : this.type.getAnnotationsByType(BQModuleOverrides.class)) { - this.overrides.addAll(Arrays.asList(anno.value())); - } - } - return this.overrides; - } - - /** Replies the description of the module. - * - * @return the description. - */ - public String description() { - if (this.description == null) { - final io.sarl.maven.bqextension.modules.BQModule anno = this.type.getAnnotation( - io.sarl.maven.bqextension.modules.BQModule.class); - String str = null; - if (anno != null) { - str = anno.value(); - } - this.description = Strings.nullToEmpty(str); - } - return this.description.isEmpty() ? null : this.description; - } -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/Messages.java b/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/Messages.java deleted file mode 100644 index b8fb488668..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/java/io/sarl/maven/bqextension/modules/Messages.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * $Id$ - * - * SARL is an general-purpose agent programming language. - * More details on http://www.sarl.io - * - * Copyright (C) 2014-2018 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.maven.bqextension.modules; - -import org.eclipse.osgi.util.NLS; - -/** Messages for the SARL batch compiler. - * - * @author $Author: sgalland$ - * @version $FullVersion$ - * @mavengroupid $GroupId$ - * @mavenartifactid $ArtifactId$ - * @ExcludeFromApidoc - */ -@SuppressWarnings("all") -public class Messages extends NLS { - private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$ - public static String DocumentedModuleProvider_0; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/main/internalmaven/io.sarl.maven.bqextension/src/main/resources/io/sarl/maven/bqextension/modules/messages.properties b/main/internalmaven/io.sarl.maven.bqextension/src/main/resources/io/sarl/maven/bqextension/modules/messages.properties deleted file mode 100644 index d2296f33b6..0000000000 --- a/main/internalmaven/io.sarl.maven.bqextension/src/main/resources/io/sarl/maven/bqextension/modules/messages.properties +++ /dev/null @@ -1 +0,0 @@ -DocumentedModuleProvider_0 = Error instantiating Module of type: {0} diff --git a/main/internalmaven/pom.xml b/main/internalmaven/pom.xml index faa8dc1688..7a0c84a518 100644 --- a/main/internalmaven/pom.xml +++ b/main/internalmaven/pom.xml @@ -20,7 +20,6 @@ io.sarl.maven.baselib io.sarl.maven.batchcompiler - io.sarl.maven.bqextension sarl-maven-plugin diff --git a/pom.xml b/pom.xml index 6a65a85b83..3d93ac7ae6 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ 3.10.0-v20140606-1445 - 14.0 + 15.0 18.0 @@ -296,11 +296,6 @@ io.sarl.lang.sarlc ${sarl.version} - - io.sarl.maven - io.sarl.maven.bqextension - ${sarl.version} - io.sarl.maven io.sarl.maven.docs.generator @@ -351,6 +346,32 @@ slf4j-maven ${afc.version} + + org.arakhne.afc.bootique + bootique-synopsishelp + ${afc.version} + + + org.arakhne.afc.bootique + bootique-log4j + ${afc.version} + + + org.arakhne.afc.bootique + bootique-variables + ${afc.version} + + + org.arakhne.afc.bootique + bootique-applicationdata2 + ${afc.version} + + + org.arakhne.afc.bootique + bootique-printconfig + ${afc.version} + + org.arakhne.afc.core util ${afc.version}