From e46f2568c11d2a3a67934528f404843b53287430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Galland?= Date: Sun, 5 Aug 2018 11:32:48 +0200 Subject: [PATCH] [sarl-maven-plugin] Add the configuration options for running the extra-language generators. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Galland --- main/internalmaven/sarl-maven-plugin/pom.xml | 5 +++++ .../maven/compiler/AbstractCompileMojo.java | 15 +++++++++++++++ .../AbstractSarlBatchCompilerMojo.java | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/main/internalmaven/sarl-maven-plugin/pom.xml b/main/internalmaven/sarl-maven-plugin/pom.xml index afd997896a..93f3e62603 100644 --- a/main/internalmaven/sarl-maven-plugin/pom.xml +++ b/main/internalmaven/sarl-maven-plugin/pom.xml @@ -53,6 +53,11 @@ io.sarl.maven io.sarl.maven.batchcompiler + + + io.sarl.pythongenerator + io.sarl.pythongenerator.generator + diff --git a/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractCompileMojo.java b/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractCompileMojo.java index 15116f6125..9833e5fb13 100644 --- a/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractCompileMojo.java +++ b/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractCompileMojo.java @@ -124,6 +124,21 @@ public abstract class AbstractCompileMojo extends AbstractSarlBatchCompilerMojo @Parameter(defaultValue = "false", required = false) private boolean tycho; + /** Indicates if the extra-language generators to be enabled. + * + * @since 0.8 + */ + @Parameter(required = false) + private String[] extraGenerators; + + @Override + protected String[] getExtraGenerators() { + if (this.extraGenerators == null) { + this.extraGenerators = new String[0]; + } + return this.extraGenerators; + } + @Override protected String getSourceVersion() { return this.source; diff --git a/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractSarlBatchCompilerMojo.java b/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractSarlBatchCompilerMojo.java index 4b8b5bfbee..67e22beaa1 100644 --- a/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractSarlBatchCompilerMojo.java +++ b/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractSarlBatchCompilerMojo.java @@ -185,6 +185,13 @@ protected MavenProject getProject() { */ protected abstract boolean getGenerateSerialNumberFields(); + /** Replies the list of the extra-language generators' identifiers that should be enabled. + * + * @return the list of extra-language generators' identifiers. + * @since 0.8 + */ + protected abstract String[] getExtraGenerators(); + /** Run compilation. * * @param classPath the classpath @@ -194,6 +201,7 @@ protected MavenProject getProject() { * @throws MojoExecutionException if error. * @throws MojoFailureException if failure. */ + @SuppressWarnings("checkstyle:npathcomplexity") protected void compile(List classPath, List sourcePaths, File sarlOutputPath, File classOutputPath) throws MojoExecutionException, MojoFailureException { final SarlBatchCompiler compiler = getBatchCompiler(); @@ -227,6 +235,16 @@ protected void compile(List classPath, List sourcePaths, File sarlOu compiler.setGenerateToStringFunctions(getGenerateToStringFunctions()); compiler.setGenerateCloneFunctions(getGenerateCloneFunctions()); compiler.setGenerateSerialNumberFields(getGenerateSerialNumberFields()); + + final StringBuilder builder = new StringBuilder(); + for (final String identifier : getExtraGenerators()) { + if (builder.length() > 0) { + builder.append(File.pathSeparator); + } + builder.append(identifier); + } + compiler.setExtraLanguageGenerators(builder.toString()); + StaticLoggerBinder.getSingleton().registerMavenLogger(getLog()); final Logger logger = LoggerFactory.getLogger(getClass()); compiler.setLogger(logger);