Skip to content

Commit

Permalink
Merge pull request #539 from scottkurz/add-gradle-liberty-plugin-conf…
Browse files Browse the repository at this point in the history
…ig-xml-detection

Use Maven vs Gradle-aware build dir
  • Loading branch information
scottkurz authored Feb 6, 2025
2 parents d05f7b8 + de7b74a commit 7c8df29
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -992,11 +992,40 @@ public static Path getMavenIntegrationTestReportPath(String projectPath, String
return path1.toFile().exists() ? path1 : path2;
}

public Path getLibertyPluginConfigXmlPath(String projectPath) {
Path path = Paths.get(projectPath, "target", "liberty-plugin-config.xml");

public Path getLibertyPluginConfigXmlPath(Project project) throws Exception {

Project serverProj = getLibertyServerProject(project);
String buildDir = serverProj.getBuildType() == BuildType.GRADLE ? "build" : "target";

Path path = Paths.get(serverProj.getPath(), buildDir, "liberty-plugin-config.xml");
return path;
}


/**
* Returns the liberty server module project associated with the input project.
*
* @param project The project to process.
*
* @return The liberty server module project associated with the input project.
*
* @throws Exception
*/
private Project getLibertyServerProject(Project project) throws Exception {
if (project.isParentOfServerModule()) {
List<Project> mmps = project.getChildLibertyServerProjects();
switch (mmps.size()) {
case 0:
throw new Exception("Unable to find a child project that contains the Liberty server configuration.");
case 1:
return mmps.get(0);
default:
throw new Exception("Multiple child projects containing Liberty server configuration were found.");
}
}

return project;
}

/**
* Returns the path of the HTML file containing the unit test report.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,9 @@ private void openDebugPerspective() {
*/
private Path getServerEnvFile(Project project) throws Exception {

Project serverProj = getLibertyServerProject(project);
String projectPath = serverProj.getPath();


Path libertyPluginConfigXmlPath = devModeOps.getLibertyPluginConfigXmlPath(projectPath);
Path libertyPluginConfigXmlPath = devModeOps.getLibertyPluginConfigXmlPath(project);

// Read server.env path from liberty-plugin-config.xml

Expand Down Expand Up @@ -642,30 +641,6 @@ public void run() {
+ ". If the server starts later you might try to manually create a Remote Java Application debug configuration and attach to the server. You can confirm the debug port used in the terminal output looking for a message like 'Liberty debug port: [ 63624 ]'.");
}

/**
* Returns the liberty server module project associated with the input project.
*
* @param project The project to process.
*
* @return The liberty server module project associated with the input project.
*
* @throws Exception
*/
private Project getLibertyServerProject(Project project) throws Exception {
if (project.isParentOfServerModule()) {
List<Project> mmps = project.getChildLibertyServerProjects();
switch (mmps.size()) {
case 0:
throw new Exception("Unable to find a child project that contains the Liberty server configuration.");
case 1:
return mmps.get(0);
default:
throw new Exception("Multiple child projects containing Liberty server configuration were found.");
}
}

return project;
}

private class DataHolder {
boolean closed;
Expand Down

0 comments on commit 7c8df29

Please sign in to comment.