Skip to content

Commit

Permalink
[sarl-maven-plugin] Add the configuration options for running the ext…
Browse files Browse the repository at this point in the history
…ra-language generators.

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Aug 5, 2018
1 parent 456ba7e commit e46f256
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main/internalmaven/sarl-maven-plugin/pom.xml
Expand Up @@ -53,6 +53,11 @@
<groupId>io.sarl.maven</groupId>
<artifactId>io.sarl.maven.batchcompiler</artifactId>
</dependency>
<!-- The following dependency is included in order to have extra-language generators -->
<dependency>
<groupId>io.sarl.pythongenerator</groupId>
<artifactId>io.sarl.pythongenerator.generator</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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
Expand All @@ -194,6 +201,7 @@ protected MavenProject getProject() {
* @throws MojoExecutionException if error.
* @throws MojoFailureException if failure.
*/
@SuppressWarnings("checkstyle:npathcomplexity")
protected void compile(List<File> classPath, List<File> sourcePaths, File sarlOutputPath,
File classOutputPath) throws MojoExecutionException, MojoFailureException {
final SarlBatchCompiler compiler = getBatchCompiler();
Expand Down Expand Up @@ -227,6 +235,16 @@ protected void compile(List<File> classPath, List<File> 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);
Expand Down

0 comments on commit e46f256

Please sign in to comment.