From a3883e886ec2fe75b35fba6567362e6d8029dc62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per-=C3=85ke=20Minborg?= Date: Sat, 25 Mar 2017 17:35:29 -0700 Subject: [PATCH] maven-plugin: Add command line options --- .../maven/abstractmojo/AbstractClearMojo.java | 14 +++++------ .../abstractmojo/AbstractGenerateMojo.java | 18 +++++++------ .../abstractmojo/AbstractReloadMojo.java | 16 ++++++------ .../maven/abstractmojo/AbstractToolMojo.java | 14 +++++------ .../speedment/maven/typemapper/Mapping.java | 25 +++++++++++++------ .../runtime/field/predicate/Inclusion.java | 2 +- 6 files changed, 51 insertions(+), 38 deletions(-) diff --git a/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractClearMojo.java b/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractClearMojo.java index dbb87f06d9..1f8bf33363 100644 --- a/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractClearMojo.java +++ b/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractClearMojo.java @@ -41,15 +41,15 @@ public abstract class AbstractClearMojo extends AbstractSpeedmentMojo { @Parameter(defaultValue = "${project}", required = true, readonly = true) private MavenProject mavenProject; - private @Parameter(defaultValue = "false") boolean debug; + private @Parameter(defaultValue = "${debug}") Boolean debug; private @Parameter(defaultValue = "${dbms.host}") String dbmsHost; private @Parameter(defaultValue = "${dbms.port}") int dbmsPort; private @Parameter(defaultValue = "${dbms.username}") String dbmsUsername; private @Parameter(defaultValue = "${dbms.password}") String dbmsPassword; - private @Parameter String[] components; - private @Parameter Mapping[] typeMappers; + private @Parameter(defaultValue = "${components}") String[] components; + private @Parameter(defaultValue = "${typeMappers}") Mapping[] typeMappers; private @Parameter ConfigParam[] parameters; - private @Parameter(defaultValue = DEFAULT_CONFIG_LOCATION) File configFile; + private @Parameter(defaultValue = "${configFile}") File configFile; protected AbstractClearMojo() {} @@ -57,7 +57,7 @@ protected AbstractClearMojo() {} @Override public void execute(Speedment speedment) throws MojoExecutionException, MojoFailureException { - getLog().info("Clear any unmodified files generated using configuration file: '" + configFile.getAbsolutePath() + "'."); + getLog().info("Clear any unmodified files generated using configuration file: '" + configLocation().getAbsolutePath() + "'."); if (hasConfigFile()) { try { @@ -97,12 +97,12 @@ protected ConfigParam[] parameters() { @Override protected File configLocation() { - return configFile; + return configFile == null ? new File(DEFAULT_CONFIG_LOCATION) : configFile; } @Override protected boolean debug() { - return debug; + return debug == null ? false: debug; } @Override diff --git a/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractGenerateMojo.java b/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractGenerateMojo.java index 7414a9d60e..1b2a5429e6 100644 --- a/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractGenerateMojo.java +++ b/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractGenerateMojo.java @@ -45,15 +45,15 @@ public abstract class AbstractGenerateMojo extends AbstractSpeedmentMojo { @Parameter(defaultValue = "${project}", required = true, readonly = true) private MavenProject mavenProject; - private @Parameter(defaultValue = "false") boolean debug; + private @Parameter(defaultValue = "${debug}") Boolean debug; private @Parameter(defaultValue = "${dbms.host}") String dbmsHost; private @Parameter(defaultValue = "${dbms.port}") int dbmsPort; private @Parameter(defaultValue = "${dbms.username}") String dbmsUsername; private @Parameter(defaultValue = "${dbms.password}") String dbmsPassword; - private @Parameter String[] components; - private @Parameter Mapping[] typeMappers; + private @Parameter(defaultValue = "${components}") String[] components; + private @Parameter(defaultValue = "${typeMappers}") Mapping[] typeMappers; private @Parameter ConfigParam[] parameters; - private @Parameter(defaultValue = DEFAULT_CONFIG_LOCATION) File configFile; + private @Parameter(defaultValue = "${configFile}") File configFile; protected AbstractGenerateMojo() {} @@ -61,7 +61,7 @@ protected AbstractGenerateMojo() {} @Override public void execute(Speedment speedment) throws MojoExecutionException, MojoFailureException { - getLog().info("Generating code using JSON configuration file: '" + configFile.getAbsolutePath() + "'."); + getLog().info("Generating code using JSON configuration file: '" + configLocation().getAbsolutePath() + "'."); if (hasConfigFile()) { try { @@ -102,12 +102,12 @@ protected ConfigParam[] parameters() { @Override protected File configLocation() { - return configFile; + return configFile == null ? new File(DEFAULT_CONFIG_LOCATION) : configFile; } @Override protected boolean debug() { - return debug; + return debug == null ? false: debug; } @Override @@ -129,5 +129,9 @@ protected String dbmsUsername() { protected String dbmsPassword() { return dbmsPassword; } + + public void setTypeMappers(Mapping[] typeMappers) { + this.typeMappers = typeMappers; + } } \ No newline at end of file diff --git a/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractReloadMojo.java b/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractReloadMojo.java index 9504a74b83..1f4866d13f 100644 --- a/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractReloadMojo.java +++ b/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractReloadMojo.java @@ -41,23 +41,23 @@ public abstract class AbstractReloadMojo extends AbstractSpeedmentMojo { @Parameter(defaultValue = "${project}", required = true, readonly = true) private MavenProject mavenProject; - private @Parameter(defaultValue = "false") boolean debug; + private @Parameter(defaultValue = "${debug}") Boolean debug; private @Parameter(defaultValue = "${dbms.host}") String dbmsHost; private @Parameter(defaultValue = "${dbms.port}") int dbmsPort; private @Parameter(defaultValue = "${dbms.username}") String dbmsUsername; private @Parameter(defaultValue = "${dbms.password}") String dbmsPassword; - private @Parameter String[] components; - private @Parameter Mapping[] typeMappers; + private @Parameter(defaultValue = "${components}") String[] components; + private @Parameter(defaultValue = "${typeMappers}") Mapping[] typeMappers; private @Parameter ConfigParam[] parameters; - private @Parameter(defaultValue = DEFAULT_CONFIG_LOCATION) File configFile; - + private @Parameter(defaultValue = "${configFile}") File configFile; + protected AbstractReloadMojo() {} protected AbstractReloadMojo(Consumer> configurer) { super(configurer);} @Override protected void execute(Speedment speedment) throws MojoExecutionException, MojoFailureException { - getLog().info("Saving default configuration from database to '" + configFile.getAbsolutePath() + "'."); + getLog().info("Saving default configuration from database to '" + configLocation().getAbsolutePath() + "'."); final ConfigFileHelper helper = speedment.getOrThrow(ConfigFileHelper.class); @@ -78,12 +78,12 @@ protected MavenProject project() { @Override protected boolean debug() { - return debug; + return debug == null ? false: debug; } @Override protected File configLocation() { - return configFile; + return configFile == null ? new File(DEFAULT_CONFIG_LOCATION) : configFile; } @Override diff --git a/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractToolMojo.java b/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractToolMojo.java index 5fa017504e..1e9325ddb4 100644 --- a/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractToolMojo.java +++ b/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractToolMojo.java @@ -41,15 +41,15 @@ public abstract class AbstractToolMojo extends AbstractSpeedmentMojo { @Parameter(defaultValue = "${project}", required = true, readonly = true) private MavenProject mavenProject; - private @Parameter(defaultValue = "false") boolean debug; + private @Parameter(defaultValue = "${debug}") Boolean debug; private @Parameter(defaultValue = "${dbms.host}") String dbmsHost; private @Parameter(defaultValue = "${dbms.port}") int dbmsPort; private @Parameter(defaultValue = "${dbms.username}") String dbmsUsername; private @Parameter(defaultValue = "${dbms.password}") String dbmsPassword; - private @Parameter String[] components; - private @Parameter Mapping[] typeMappers; + private @Parameter(defaultValue = "${components}") String[] components; + private @Parameter(defaultValue = "${typeMappers}") Mapping[] typeMappers; private @Parameter ConfigParam[] parameters; - private @Parameter(defaultValue = DEFAULT_CONFIG_LOCATION) File configFile; + private @Parameter(defaultValue = "${configFile}") File configFile; protected AbstractToolMojo() {} @@ -61,7 +61,7 @@ public void execute(Speedment speedment) throws MojoExecutionException, MojoFail MainApp.setInjector(injector); if (hasConfigFile()) { - Application.launch(MainApp.class, configFile.getAbsolutePath()); + Application.launch(MainApp.class, configLocation().getAbsolutePath()); } else { Application.launch(MainApp.class); } @@ -89,12 +89,12 @@ protected ConfigParam[] parameters() { @Override protected File configLocation() { - return configFile; + return configFile == null ? new File(DEFAULT_CONFIG_LOCATION) : configFile; } @Override protected boolean debug() { - return debug; + return debug == null ? false: debug; } @Override diff --git a/build-parent/maven-plugin/src/main/java/com/speedment/maven/typemapper/Mapping.java b/build-parent/maven-plugin/src/main/java/com/speedment/maven/typemapper/Mapping.java index 498c3690b7..60ceae1419 100644 --- a/build-parent/maven-plugin/src/main/java/com/speedment/maven/typemapper/Mapping.java +++ b/build-parent/maven-plugin/src/main/java/com/speedment/maven/typemapper/Mapping.java @@ -17,20 +17,21 @@ package com.speedment.maven.typemapper; import com.speedment.runtime.typemapper.TypeMapper; +import static java.util.Objects.requireNonNull; /** - * A mapping between a particular database type and a {@link TypeMapper}. - * This class is intended to be instantiated by the maven plugin when parsing - * the pom.xml-file. - * - * @author Emil Forslund - * @since 3.0.0 + * A mapping between a particular database type and a {@link TypeMapper}. This + * class is intended to be instantiated by the maven plugin when parsing the + * pom.xml-file. + * + * @author Emil Forslund + * @since 3.0.0 */ public final class Mapping { - + private String databaseType; private String implementation; - + public String getDatabaseType() { return databaseType; } @@ -38,4 +39,12 @@ public String getDatabaseType() { public String getImplementation() { return implementation; } + + public void setDatabaseType(String databaseType) { + this.databaseType = requireNonNull(databaseType); + } + + public void setImplementation(String implementation) { + this.implementation = requireNonNull(implementation); + } } diff --git a/runtime-parent/runtime-field/src/main/java/com/speedment/runtime/field/predicate/Inclusion.java b/runtime-parent/runtime-field/src/main/java/com/speedment/runtime/field/predicate/Inclusion.java index 26ddc8f901..c5d690601d 100644 --- a/runtime-parent/runtime-field/src/main/java/com/speedment/runtime/field/predicate/Inclusion.java +++ b/runtime-parent/runtime-field/src/main/java/com/speedment/runtime/field/predicate/Inclusion.java @@ -24,7 +24,7 @@ /** - * Determines if a range of resuls should be start and/or end-inclusive. + * Determines if a range of results should be start and/or end-inclusive. *

* For an example, take the series {@code [1 2 3 4 5]}. If we select the range * {@code (2, 4)} from this series, we will get the following results: