Skip to content

Commit

Permalink
changes for showing option to restart or recompile when a change is …
Browse files Browse the repository at this point in the history
…detected in build.gradle

Signed-off-by: Arun Venmany <[email protected]>
  • Loading branch information
arunvenmany-ibm committed Nov 4, 2024
1 parent 8a321b4 commit 30a0cc4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -499,13 +499,23 @@ class DevTask extends AbstractFeatureTask {
@Override
public boolean updateArtifactPaths(ProjectModule projectModule, boolean redeployCheck, boolean generateFeatures, ThreadPoolExecutor executor)
throws PluginExecutionException {
// not supported for Gradle, only used for multi module Maven projects
// unable to identify the changes made, showing option for user. always return false because action is invoked manually
if (isMultiModuleProject()) {
info("We detected a change in build.gradle, but we cannot identify whether it’s a runtime or dependency change");
info("r - to restart server, type 'r' and press Enter.");
info("Press Enter to recompile the project and run tests manually");
}
return false;
}

@Override
public boolean updateArtifactPaths(File parentBuildFile) {
// not supported for Gradle, only used for multi module Maven projects
// unable to identify the changes made, showing option for user. always return false because action is invoked manually
if (isMultiModuleProject()) {
info("We detected a change in build.gradle, but we cannot identify whether it’s a runtime or dependency change");
info("r - to restart server, type 'r' and press Enter.");
info("Press Enter to recompile the project and run tests manually");
}
return false;
}

Expand Down Expand Up @@ -535,6 +545,13 @@ class DevTask extends AbstractFeatureTask {
boolean installFeatures = false;
boolean optimizeGenerateFeatures = false;

if (isMultiModuleProject()) {
info("We detected a change in build.gradle, but we cannot identify whether it’s a runtime or dependency change");
info("r - to restart server, type 'r' and press Enter.");
info("Press Enter to recompile the project and run tests manually");
return false;
}

ProjectBuilder builder = ProjectBuilder.builder();
Project newProject;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ class TestMultiModuleLooseEarAppDevMode extends BaseDevTest {

}

@Test
public void modifyUpdateGradleTest() throws Exception {

// modify a java file
File srcHelloWorld = new File(buildDir, "build.gradle");
assertTrue(srcHelloWorld.exists());

waitLongEnough();
String str = "// testing";
BufferedWriter javaWriter = new BufferedWriter(new FileWriter(srcHelloWorld, true));
javaWriter.append(' ');
javaWriter.append(str);
javaWriter.close();
if (!verifyLogMessage(2000, "We detected a change in build.gradle, but we cannot identify whether it’s a runtime or dependency change")) {
assertTrue(verifyLogMessage(2000, "We detected a change in build.gradle, but we cannot identify whether it’s a runtime or dependency change"));
}
}

@AfterClass
public static void cleanUpAfterClass() throws Exception {
String stdout = getContents(logFile, "Dev mode std output");
Expand All @@ -64,4 +82,5 @@ class TestMultiModuleLooseEarAppDevMode extends BaseDevTest {
System.out.println(stderr);
cleanUpAfterClass(true);
}

}

0 comments on commit 30a0cc4

Please sign in to comment.