Skip to content

Commit

Permalink
Always compile quarkus:dev
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas authored and geoand committed Feb 3, 2020
1 parent 49b4b00 commit c146b7e
Showing 1 changed file with 35 additions and 28 deletions.
63 changes: 35 additions & 28 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ public class DevMojo extends AbstractMojo {
public void execute() throws MojoFailureException, MojoExecutionException {

mavenVersionEnforcer.ensureMavenVersion(getLog(), session);

//we always want to compile if needed, so if it is run from the parent it will compile dependent projects
handleAutoCompile();

Plugin pluginDef = MojoUtils.checkProjectForMavenBuildPlugin(project);

if (pluginDef == null) {
Expand All @@ -249,34 +253,6 @@ public void execute() throws MojoFailureException, MojoExecutionException {
if (!sourceDir.isDirectory()) {
getLog().warn("The project's sources directory does not exist " + sourceDir);
}
//we check to see if there was a compile (or later) goal before this plugin
boolean compileNeeded = true;
for (String goal : session.getGoals()) {
if (POST_COMPILE_PHASES.contains(goal)) {
compileNeeded = false;
break;
}
if (goal.endsWith("quarkus:dev")) {
break;
}
}

//if the user did not compile we run it for them
if (compileNeeded) {
// compile the Kotlin sources if needed
final String kotlinMavenPluginKey = ORG_JETBRAINS_KOTLIN + ":" + KOTLIN_MAVEN_PLUGIN;
final Plugin kotlinMavenPlugin = project.getPlugin(kotlinMavenPluginKey);
if (kotlinMavenPlugin != null) {
executeCompileGoal(kotlinMavenPlugin, ORG_JETBRAINS_KOTLIN, KOTLIN_MAVEN_PLUGIN);
}

// Compile the Java sources if needed
final String compilerPluginKey = ORG_APACHE_MAVEN_PLUGINS + ":" + MAVEN_COMPILER_PLUGIN;
final Plugin compilerPlugin = project.getPlugin(compilerPluginKey);
if (compilerPlugin != null) {
executeCompileGoal(compilerPlugin, ORG_APACHE_MAVEN_PLUGINS, MAVEN_COMPILER_PLUGIN);
}
}

try {
List<String> args = new ArrayList<>();
Expand Down Expand Up @@ -361,6 +337,37 @@ public void execute() throws MojoFailureException, MojoExecutionException {
}
}

private void handleAutoCompile() throws MojoExecutionException {
//we check to see if there was a compile (or later) goal before this plugin
boolean compileNeeded = true;
for (String goal : session.getGoals()) {
if (POST_COMPILE_PHASES.contains(goal)) {
compileNeeded = false;
break;
}
if (goal.endsWith("quarkus:dev")) {
break;
}
}

//if the user did not compile we run it for them
if (compileNeeded) {
// compile the Kotlin sources if needed
final String kotlinMavenPluginKey = ORG_JETBRAINS_KOTLIN + ":" + KOTLIN_MAVEN_PLUGIN;
final Plugin kotlinMavenPlugin = project.getPlugin(kotlinMavenPluginKey);
if (kotlinMavenPlugin != null) {
executeCompileGoal(kotlinMavenPlugin, ORG_JETBRAINS_KOTLIN, KOTLIN_MAVEN_PLUGIN);
}

// Compile the Java sources if needed
final String compilerPluginKey = ORG_APACHE_MAVEN_PLUGINS + ":" + MAVEN_COMPILER_PLUGIN;
final Plugin compilerPlugin = project.getPlugin(compilerPluginKey);
if (compilerPlugin != null) {
executeCompileGoal(compilerPlugin, ORG_APACHE_MAVEN_PLUGINS, MAVEN_COMPILER_PLUGIN);
}
}
}

private void executeCompileGoal(Plugin plugin, String groupId, String artifactId) throws MojoExecutionException {
Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
if (configuration == null) {
Expand Down

0 comments on commit c146b7e

Please sign in to comment.