diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java index ce635e0b..b863dd9c 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java @@ -441,6 +441,7 @@ private enum FileTrackMode { private File modifiedSrcBuildFile; protected boolean skipInstallFeature; + boolean compileMojoError; public DevUtil(File buildDirectory, File serverDirectory, File sourceDirectory, File testSourceDirectory, File configDirectory, File projectDirectory, File multiModuleProjectDirectory, List resourceDirs, boolean changeOnDemandTestsAction, @@ -451,7 +452,8 @@ public DevUtil(File buildDirectory, File serverDirectory, File sourceDirectory, boolean skipDefaultPorts, JavaCompilerOptions compilerOptions, boolean keepTempContainerfile, String mavenCacheLocation, List upstreamProjects, boolean recompileDependencies, String packagingType, File buildFile, Map> parentBuildFiles, boolean generateFeatures, - Set compileArtifactPaths, Set testArtifactPaths, List monitoredWebResourceDirs) { + Set compileArtifactPaths, Set testArtifactPaths, List monitoredWebResourceDirs, + boolean compileMojoError) { this.buildDirectory = buildDirectory; this.serverDirectory = serverDirectory; this.sourceDirectory = sourceDirectory; @@ -491,6 +493,7 @@ public DevUtil(File buildDirectory, File serverDirectory, File sourceDirectory, this.containerfile = containerfile; this.containerBuildContext = containerBuildContext; this.containerRunOpts = containerRunOpts; + this.compileMojoError=compileMojoError; if (projectDirectory != null) { //Use Containerfile if it exists, but default to Dockerfile if both present or neither exist File defaultDockerFile = new File(projectDirectory, "Dockerfile"); @@ -4021,15 +4024,25 @@ private void initWatchLoop() throws IOException { // initial source and test compile of upstream projects if (isMultiModuleProject()) { for (ProjectModule project : upstreamProjects) { - triggerUpstreamModuleCompile(project, false); + if (compileMojoError) { + info("Recompile "+project.getProjectName()+ " due to an earlier compilation error"); + triggerUpstreamModuleCompile(project, false); + } else { + info("Recompile skipped for "+project.getProjectName()+ " since earlier compilation is successful"); + } // build file tracking of upstream projects lastBuildFileChange.put(project.getBuildFile(), System.currentTimeMillis()); } } // initial source and test compile - triggerMainModuleCompile(false); - // build file tracking of main project + if (compileMojoError) { + info("Recompile "+getProjectName()+ " due to an earlier compilation error"); + triggerMainModuleCompile(false); + // build file tracking of main project + } else { + info("Recompile skipped for "+getProjectName()+ " since earlier compilation is successful"); + } lastBuildFileChange.put(buildFile, System.currentTimeMillis()); } diff --git a/src/test/java/io/openliberty/tools/common/plugins/util/BaseDevUtilTest.java b/src/test/java/io/openliberty/tools/common/plugins/util/BaseDevUtilTest.java index 0600ffb8..6eb80ee5 100644 --- a/src/test/java/io/openliberty/tools/common/plugins/util/BaseDevUtilTest.java +++ b/src/test/java/io/openliberty/tools/common/plugins/util/BaseDevUtilTest.java @@ -40,13 +40,13 @@ public DevTestUtil(File serverDirectory, File sourceDirectory, File testSourceDi List resourceDirs, List webResourceDirs, boolean hotTests, boolean skipTests) throws IOException { super(temp.newFolder(), serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, null, null, resourceDirs, false, hotTests, skipTests, false, false, false, null, 30, 30, 5, 500, true, false, false, false, - false, null, null, null, 0, false, null, false, null, null, false, null, null, null, false, null, null, webResourceDirs); + false, null, null, null, 0, false, null, false, null, null, false, null, null, null, false, null, null, webResourceDirs,true); } public DevTestUtil(File serverDirectory, File buildDir) { super(buildDir, serverDirectory, null, null, null, null, null, null, false, false, false, false, false, false, null, 30, 30, 5, 500, true, false, false, false, - false, null, null, null, 0, false, null, false, null, null, false, null, null, null, false, null, null, null); + false, null, null, null, 0, false, null, false, null, null, false, null, null, null, false, null, null, null,true); } @Override