Skip to content

Commit

Permalink
maven-plugin: Add command line options
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Mar 26, 2017
1 parent 6cf343e commit a3883e8
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 38 deletions.
Expand Up @@ -41,23 +41,23 @@ 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() {}

protected AbstractClearMojo(Consumer<ApplicationBuilder<?, ?>> configurer) { super(configurer);}

@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 {
Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -45,23 +45,23 @@ 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() {}

protected AbstractGenerateMojo(Consumer<ApplicationBuilder<?, ?>> configurer) { super(configurer); }

@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 {
Expand Down Expand Up @@ -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
Expand All @@ -129,5 +129,9 @@ protected String dbmsUsername() {
protected String dbmsPassword() {
return dbmsPassword;
}

public void setTypeMappers(Mapping[] typeMappers) {
this.typeMappers = typeMappers;
}

}
Expand Up @@ -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<ApplicationBuilder<?, ?>> 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);

Expand All @@ -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
Expand Down
Expand Up @@ -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() {}

Expand All @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -17,25 +17,34 @@
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;
}

public String getImplementation() {
return implementation;
}

public void setDatabaseType(String databaseType) {
this.databaseType = requireNonNull(databaseType);
}

public void setImplementation(String implementation) {
this.implementation = requireNonNull(implementation);
}
}
Expand Up @@ -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.
* <p>
* 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:
Expand Down

0 comments on commit a3883e8

Please sign in to comment.