Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server multi restart issue fix #1853

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ jobs:
- name: Checkout ci.common
uses: actions/checkout@v3
with:
repository: OpenLiberty/ci.common
repository: arunvenmany-ibm/ci.common
path: ci.common
ref: server_multi_restart_issue_fix
- name: Checkout ci.ant
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -102,7 +103,7 @@ jobs:
- name: Clone ci.ant, ci.common, ci.maven repos to C drive
run: |
cp -r D:/a/ci.maven/ci.maven C:/ci.maven
git clone https://github.com/OpenLiberty/ci.common.git C:/ci.common
git clone https://github.com/arunvenmany-ibm/ci.common.git --branch server_multi_restart_issue_fix --single-branch C:/ci.common
git clone https://github.com/OpenLiberty/ci.ant.git C:/ci.ant
- name: Set up Maven
uses: stCarolas/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion liberty-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<dependency>
<groupId>io.openliberty.tools</groupId>
<artifactId>ci.common</artifactId>
<version>1.8.36</version>
<version>1.8.37-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.twdata.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void updateDependencyTest() throws Exception {
assertTrue(verifyLogMessageExists("mpHealth-2.2", 10000)); // should appear in the message "CWWKF0012I: The server installed the following features:"

int generateFeaturesCount = countOccurrences("Running liberty:generate-features", logFile);
assertTrue(verifyLogMessageExists("Source compilation was successful.", 10000));
assertTrue(verifyLogMessageExists("Recompile dev-sample-proj due to an earlier compilation error", 10000));

// modify MicroProfile umbrella dependency in pom.xml
replaceString("<dependency>\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,18 @@ public void updatePomsTest() throws Exception {
// Wait until the last module (ear) finishes compiling during dev mode startup
// TODO: this can be removed if dev mode does not recompile after first starting up
verifyLogMessageExists("guide-maven-multimodules-ear tests compilation was successful", 10000);
// verify that generated-features.xml file exists
File newFeatureFile = getGeneratedFeaturesFile("ear");
assertTrue(getLogTail(), verifyFileExists(newFeatureFile, 1000));
long newFeatureFileLastModified = newFeatureFile.lastModified();
waitLongEnough();

int jarSourceCount = countOccurrences("guide-maven-multimodules-jar source compilation was successful.", logFile);
int jarTestsCount = countOccurrences("guide-maven-multimodules-jar tests compilation was successful.", logFile);
int warSourceCount = countOccurrences("guide-maven-multimodules-war source compilation was successful.", logFile);
int warTestsCount = countOccurrences("guide-maven-multimodules-war tests compilation was successful.", logFile);
int earTestsCount = countOccurrences("guide-maven-multimodules-ear tests compilation was successful.", logFile);

// verify that generated-features.xml file exists
File newFeatureFile = getGeneratedFeaturesFile("ear");
assertTrue(getLogTail(), verifyFileExists(newFeatureFile, 1000));
long newFeatureFileLastModified = newFeatureFile.lastModified();
waitLongEnough();

touchFileTwice("jar/pom.xml");

// Give time for recompile to occur
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public void setKeepTempDockerfile(Boolean keepTempDockerfile) {

private boolean isExplodedLooseWarApp = false;
private boolean isNewInstallation = true;
private static Map<String,Boolean> compileMojoError = new HashMap<>();

/**
* Set the container option.
Expand Down Expand Up @@ -359,7 +360,7 @@ public DevMojoUtil(File installDir, File userDir, File serverDirectory, File sou
((long) (compileWait * 1000L)), libertyDebug, false, false, pollingTest, container, containerfile,
containerBuildContext, containerRunOpts, containerBuildTimeout, skipDefaultPorts, compilerOptions,
keepTempContainerfile, mavenCacheLocation, upstreamProjects, recompileDeps, project.getPackaging(),
pom, parentPoms, generateFeatures, compileArtifactPaths, testArtifactPaths, webResourceDirs);
pom, parentPoms, generateFeatures, compileArtifactPaths, testArtifactPaths, webResourceDirs, compileMojoError);

this.libertyDirPropertyFiles = LibertyPropFilesUtility.getLibertyDirectoryPropertyFiles(new CommonLogger(getLog()), installDir, userDir,
serverDirectory);
Expand Down Expand Up @@ -492,7 +493,7 @@ public void libertyDeploy() throws PluginExecutionException {
@Override
public void stopServer() {
super.serverFullyStarted.set(false);

compileMojoError.clear();
if (container) {
// TODO stop the container instead
return;
Expand Down Expand Up @@ -1355,7 +1356,6 @@ private void doDevMode() throws MojoExecutionException {
if (project.getPackaging().equals("ear")) {
isEar = true;
}

// If there are downstream projects (e.g. other modules depend on this module in the Maven Reactor build order),
// then skip dev mode on this module but only run compile.
List<MavenProject> upstreamMavenProjects = new ArrayList<MavenProject>();
Expand Down Expand Up @@ -1386,7 +1386,19 @@ private void doDevMode() throws MojoExecutionException {
getLog().debug("Skipping compile/resources on module with pom packaging type");
} else {
runMojo("org.apache.maven.plugins", "maven-resources-plugin", "resources");
runCompileMojoLogWarning();
try {
runCompileMojoLogWarningWithException("compile");
} catch (MojoExecutionException e) {
// set init recompile necessary in case any module fail
compileMojoError.put(project.getName(),Boolean.TRUE);
}
if(hotTests) {
try {
runCompileMojoLogWarningWithException("testCompile");
} catch (MojoExecutionException e) {
compileMojoError.put(project.getName(),Boolean.TRUE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have FALSE entries in this compileMojoError Map for projects that do not contain compile errors? What will cause the TRUE entries to get removed or changed to FALSE when the compile is done successfully?

}
}
}
return;
} else {
Expand Down Expand Up @@ -1456,13 +1468,27 @@ private void doDevMode() throws MojoExecutionException {
if (isEar) {
runMojo("org.apache.maven.plugins", "maven-ear-plugin", "generate-application-xml");
runMojo("org.apache.maven.plugins", "maven-resources-plugin", "resources");
// for test classes in ear
try {
runCompileMojoLogWarningWithException("testCompile");
} catch (MojoExecutionException e) {
compileMojoError.put(project.getName(),Boolean.TRUE);
}
} else if (project.getPackaging().equals("pom")) {
getLog().debug("Skipping compile/resources on module with pom packaging type");
} else {
runMojo("org.apache.maven.plugins", "maven-resources-plugin", "resources");
runCompileMojoLogWarning();
runMojo("org.apache.maven.plugins", "maven-resources-plugin", "testResources");
runTestCompileMojoLogWarning();
try {
runCompileMojoLogWarningWithException("compile");
} catch (MojoExecutionException e) {
compileMojoError.put(project.getName(),Boolean.TRUE);
}
runMojo("org.apache.maven.plugins", "maven-resources-plugin", "testResources");
try {
runCompileMojoLogWarningWithException("testCompile");
} catch (MojoExecutionException e) {
compileMojoError.put(project.getName(),Boolean.TRUE);
}
}

sourceDirectory = new File(sourceDirectoryString.trim());
Expand Down Expand Up @@ -2024,6 +2050,20 @@ private void runCompileMojo(String goal, MavenProject mavenProject) throws MojoE
executeMojo(plugin, goal(goal), config, executionEnvironment(tempProject, tempSession, pluginManager));
}

private void runCompileMojoLogWarningWithException(String goal) throws MojoExecutionException {
Plugin plugin = getPluginForProject("org.apache.maven.plugins", "maven-compiler-plugin", project);
MavenSession tempSession = session.clone();
tempSession.setCurrentProject(project);
MavenProject tempProject = project;
Xpp3Dom config = ExecuteMojoUtil.getPluginGoalConfig(plugin, goal, getLog());
config = Xpp3Dom.mergeXpp3Dom(configuration(element(name("failOnError"), "true")), config);
getLog().info("Running maven-compiler-plugin:" + goal + " on " + tempProject.getFile());
getLog().debug("configuration:\n" + config);
executeMojo(plugin, goal(goal), config, executionEnvironment(tempProject, tempSession, pluginManager));

updateArtifactPathToOutputDirectory(project);
}

/**
* Executes maven:compile but logs errors as warning messages
*
Expand Down
Loading