From f0ce827b3badad563be2780b95db25b901979fea Mon Sep 17 00:00:00 2001 From: Arun Venmany Date: Fri, 29 Nov 2024 11:10:05 +0530 Subject: [PATCH 1/2] Adapting to ServerConfigDocument constructor changes Signed-off-by: Arun Venmany --- .github/workflows/maven.yml | 5 ++- .../openliberty/tools/maven/BasicSupport.java | 44 ------------------- .../tools/maven/InstallFeatureSupport.java | 4 +- .../tools/maven/applications/DeployMojo.java | 4 +- .../maven/applications/DeployMojoSupport.java | 3 +- .../maven/applications/UndeployAppMojo.java | 3 +- .../tools/maven/server/DevMojo.java | 6 ++- .../maven/server/PluginConfigSupport.java | 7 ++- 8 files changed, 17 insertions(+), 59 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 63de3f555..0d2e8f95f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -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: varProcessing_lcls - name: Checkout ci.ant uses: actions/checkout@v3 with: @@ -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 varProcessing_lcls --single-branch C:/ci.common git clone https://github.com/OpenLiberty/ci.ant.git C:/ci.ant - name: Set up Maven uses: stCarolas/setup-maven@v4.5 diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/BasicSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/BasicSupport.java index 572e7ca25..b6b9d530f 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/BasicSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/BasicSupport.java @@ -46,7 +46,6 @@ import io.openliberty.tools.ant.install.InstallLibertyTask; import io.openliberty.tools.common.plugins.util.AbstractContainerSupportUtil; import io.openliberty.tools.common.plugins.util.PluginExecutionException; -import io.openliberty.tools.common.plugins.util.ServerFeatureUtil; /** * Basic Liberty Mojo Support @@ -673,49 +672,6 @@ private String getWlpOutputDir() throws IOException { return (String) envvars.get("WLP_OUTPUT_DIR"); } - static public Map getLibertyDirectoryPropertyFiles(File installDir, File userDir, File serverDir) throws IOException { - Map libertyDirectoryPropertyToFile = new HashMap(); - - if (serverDir.exists()) { - libertyDirectoryPropertyToFile.put(ServerFeatureUtil.SERVER_CONFIG_DIR, serverDir.getCanonicalFile()); - - libertyDirectoryPropertyToFile.put(ServerFeatureUtil.WLP_INSTALL_DIR, installDir.getCanonicalFile()); - - libertyDirectoryPropertyToFile.put(ServerFeatureUtil.WLP_USER_DIR, userDir.getCanonicalFile()); - - File userExtDir = new File(userDir, "extension"); - libertyDirectoryPropertyToFile.put(ServerFeatureUtil.USR_EXTENSION_DIR, userExtDir.getCanonicalFile()); - - File userSharedDir = new File(userDir, "shared"); - File userSharedAppDir = new File(userSharedDir, "app"); - File userSharedConfigDir = new File(userSharedDir, "config"); - File userSharedResourcesDir = new File(userSharedDir, "resources"); - File userSharedStackGroupsDir = new File(userSharedDir, "stackGroups"); - - libertyDirectoryPropertyToFile.put(ServerFeatureUtil.SHARED_APP_DIR, userSharedAppDir.getCanonicalFile()); - libertyDirectoryPropertyToFile.put(ServerFeatureUtil.SHARED_CONFIG_DIR, userSharedConfigDir.getCanonicalFile()); - libertyDirectoryPropertyToFile.put(ServerFeatureUtil.SHARED_RESOURCES_DIR, userSharedResourcesDir.getCanonicalFile()); - libertyDirectoryPropertyToFile.put(ServerFeatureUtil.SHARED_STACKGROUP_DIR, userSharedStackGroupsDir.getCanonicalFile()); - } - return libertyDirectoryPropertyToFile; - } - - protected Map getLibertyDirectoryPropertyFiles() { - - if (serverDirectory.exists()) { - try { - return getLibertyDirectoryPropertyFiles(installDirectory, userDirectory, serverDirectory); - } catch (Exception e) { - getLog().warn("The properties for directories could not be initialized because an error occurred when accessing the directories."); - getLog().debug("Exception received: "+e.getMessage(), (Throwable) e); - } - } else { - getLog().warn("The " + serverDirectory + " directory cannot be accessed. The properties for directories could not be initialized."); - } - - return new HashMap (); - } - protected void setContainerEngine(AbstractContainerSupportUtil util) throws PluginExecutionException { String LIBERTY_DEV_PODMAN = "liberty.dev.podman"; Object podmanPropValue = null; diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/InstallFeatureSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/InstallFeatureSupport.java index fa5c1855b..5915c2d33 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/InstallFeatureSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/InstallFeatureSupport.java @@ -24,6 +24,8 @@ import java.util.Map; import java.util.Set; +import io.openliberty.tools.common.plugins.util.LibertyPropFilesUtility; +import io.openliberty.tools.maven.utils.CommonLogger; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; @@ -235,7 +237,7 @@ else if (util == null && !noFeaturesSection) { Set dependencyFeatures = getDependencyFeatures(); Set serverFeatures = new HashSet(); Set serverPlatforms = new HashSet(); - FeaturesPlatforms getServerResult = serverDirectory.exists() ? util.getServerFeatures(serverDirectory, getLibertyDirectoryPropertyFiles()) : null; + FeaturesPlatforms getServerResult = serverDirectory.exists() ? util.getServerFeatures(serverDirectory, LibertyPropFilesUtility.getLibertyDirectoryPropertyFiles(new CommonLogger(getLog()), installDirectory, userDirectory, serverDirectory)) : null; if (getServerResult != null) { serverFeatures = getServerResult.getFeatures(); serverPlatforms = getServerResult.getPlatforms(); diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojo.java index a7f487870..933d24cb1 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojo.java @@ -118,10 +118,10 @@ private void installSpringBootApp() throws MojoExecutionException, IOException { File fatArchiveSrc = SpringBootUtil.getSpringBootUberJAR(project, getLog()); File serverXML = new File(serverDirectory, "server.xml"); - Map libertyDirPropertyFiles = getLibertyDirectoryPropertyFiles(); + CommonLogger logger = new CommonLogger(getLog()); setLog(logger.getLog()); - getServerConfigDocument(logger, serverXML, libertyDirPropertyFiles); + getServerConfigDocument(logger, serverXML); // Check if the archiveSrc is executable and then invokeSpringUtilCommand. if (io.openliberty.tools.common.plugins.util.SpringBootUtil.isSpringBootUberJar(fatArchiveSrc)) { diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojoSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojoSupport.java index ed4ac54c5..f890d41ce 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojoSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojoSupport.java @@ -312,10 +312,9 @@ protected void verifyAppStarted(String appFile) throws MojoExecutionException { try { File serverXML = new File(serverDirectory, "server.xml"); - Map libertyDirPropertyFiles = getLibertyDirectoryPropertyFiles(); CommonLogger logger = new CommonLogger(getLog()); setLog(logger.getLog()); - scd = getServerConfigDocument(logger, serverXML, libertyDirPropertyFiles); + scd = getServerConfigDocument(logger, serverXML); //appName will be set to a name derived from appFile if no name can be found. appName = scd.findNameForLocation(appFile); diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/UndeployAppMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/UndeployAppMojo.java index ad1d4cd40..066bd0029 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/UndeployAppMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/UndeployAppMojo.java @@ -133,10 +133,9 @@ protected void undeployApp(File file) throws MojoExecutionException { try { File serverXML = new File(serverDirectory.getCanonicalPath(), "server.xml"); - Map libertyDirPropertyFiles = getLibertyDirectoryPropertyFiles(); CommonLogger logger = new CommonLogger(getLog()); setLog(logger.getLog()); - scd = getServerConfigDocument(logger, serverXML, libertyDirPropertyFiles); + scd = getServerConfigDocument(logger, serverXML); //appName will be set to a name derived from file if no name can be found. appName = scd.findNameForLocation(appName); diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java index 2fb569b54..67e2ed601 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java @@ -41,6 +41,8 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import io.openliberty.tools.common.plugins.util.LibertyPropFilesUtility; +import io.openliberty.tools.maven.utils.CommonLogger; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.execution.MavenSession; @@ -359,8 +361,8 @@ public DevMojoUtil(File installDir, File userDir, File serverDirectory, File sou keepTempContainerfile, mavenCacheLocation, upstreamProjects, recompileDeps, project.getPackaging(), pom, parentPoms, generateFeatures, compileArtifactPaths, testArtifactPaths, webResourceDirs); - this.libertyDirPropertyFiles = BasicSupport.getLibertyDirectoryPropertyFiles(installDir, userDir, - serverDirectory); + this.libertyDirPropertyFiles = LibertyPropFilesUtility.getLibertyDirectoryPropertyFiles(new CommonLogger(getLog()), installDir, userDir, + serverDirectory); ServerFeatureUtil servUtil = getServerFeatureUtil(true, libertyDirPropertyFiles); FeaturesPlatforms fp = servUtil.getServerFeatures(serverDirectory, libertyDirPropertyFiles); if (fp != null) { diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/PluginConfigSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/PluginConfigSupport.java index 4ba41602c..4717e21e4 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/PluginConfigSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/PluginConfigSupport.java @@ -372,10 +372,9 @@ protected Set getAppConfigLocationsFromSourceServerXml() { if (serverXML != null && serverXML.exists()) { try { - Map libertyDirPropertyFiles = getLibertyDirectoryPropertyFiles(); CommonLogger logger = new CommonLogger(getLog()); setLog(logger.getLog()); - scd = getServerConfigDocument(logger, serverXML, libertyDirPropertyFiles); + scd = getServerConfigDocument(logger, serverXML); } catch (Exception e) { getLog().warn(e.getLocalizedMessage()); getLog().debug(e); @@ -384,10 +383,10 @@ protected Set getAppConfigLocationsFromSourceServerXml() { return scd != null ? scd.getLocations() : new HashSet(); } - protected ServerConfigDocument getServerConfigDocument(CommonLoggerI log, File serverXML, Map libertyDirPropertyFiles) throws IOException, MojoExecutionException { + protected ServerConfigDocument getServerConfigDocument(CommonLoggerI log, File serverXML) throws IOException, MojoExecutionException { if (scd == null || !scd.getOriginalServerXMLFile().getCanonicalPath().equals(serverXML.getCanonicalPath())) { try { - scd = new ServerConfigDocument(log, serverXML, libertyDirPropertyFiles); + scd = new ServerConfigDocument(log, serverXML, installDirectory,userDirectory,serverDirectory); } catch (PluginExecutionException e) { throw new MojoExecutionException(e.getMessage()); } From 2213a6e7063f45d5784cd73c623355785f22fcf5 Mon Sep 17 00:00:00 2001 From: Arun Venmany Date: Tue, 3 Dec 2024 10:08:29 +0530 Subject: [PATCH 2/2] update workflow yaml to build ci.common Signed-off-by: Arun Venmany --- .github/workflows/maven.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0d2e8f95f..63de3f555 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -48,9 +48,8 @@ jobs: - name: Checkout ci.common uses: actions/checkout@v3 with: - repository: arunvenmany-ibm/ci.common + repository: OpenLiberty/ci.common path: ci.common - ref: varProcessing_lcls - name: Checkout ci.ant uses: actions/checkout@v3 with: @@ -103,7 +102,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/arunvenmany-ibm/ci.common.git --branch varProcessing_lcls --single-branch C:/ci.common + git clone https://github.com/OpenLiberty/ci.common.git C:/ci.common git clone https://github.com/OpenLiberty/ci.ant.git C:/ci.ant - name: Set up Maven uses: stCarolas/setup-maven@v4.5