diff --git a/jOOQ-codegen-maven/src/main/java/org/jooq/util/maven/Plugin.java b/jOOQ-codegen-maven/src/main/java/org/jooq/util/maven/Plugin.java index 06348d2165..b8f8733385 100644 --- a/jOOQ-codegen-maven/src/main/java/org/jooq/util/maven/Plugin.java +++ b/jOOQ-codegen-maven/src/main/java/org/jooq/util/maven/Plugin.java @@ -45,6 +45,7 @@ import static org.apache.maven.plugins.annotations.ResolutionScope.TEST; import static org.jooq.Constants.XSD_CODEGEN; import java.io.File; +import java.io.FileInputStream; import java.io.StringWriter; import java.net.URL; import java.net.URLClassLoader; @@ -84,6 +85,12 @@ public class Plugin extends AbstractMojo { ) private MavenProject project; + /** + * An external configuration file that overrides anything in the Maven configuration + */ + @Parameter + private String configurationFile; + /** * Whether to skip the execution of the Maven Plugin for this module. */ @@ -115,6 +122,25 @@ public class Plugin extends AbstractMojo { return; } + if (configurationFile != null) { + getLog().info("Reading external configuration"); + File file = new File(configurationFile); + + if (!file.isAbsolute()) + file = new File(project.getBasedir(), configurationFile); + + FileInputStream in = null; + try { + in = new FileInputStream(file); + Configuration configuration = GenerationTool.load(in); + generator = configuration.getGenerator(); + jdbc = configuration.getJdbc(); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + // [#5286] There are a variety of reasons why the generator isn't set up // correctly at this point. We'll log them all here. if (generator == null) {