diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java index 68241025a..2f9b54205 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -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) { @@ -249,34 +253,6 @@ public class DevMojo extends AbstractMojo { 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 args = new ArrayList<>(); @@ -361,6 +337,37 @@ public class DevMojo extends AbstractMojo { } } + 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) {