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

Adapting to ServerConfigDocument constructor changes #1848

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: varProcessing_lcls
- 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 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/[email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -673,49 +672,6 @@ private String getWlpOutputDir() throws IOException {
return (String) envvars.get("WLP_OUTPUT_DIR");
}

static public Map<String,File> getLibertyDirectoryPropertyFiles(File installDir, File userDir, File serverDir) throws IOException {
Map<String, File> libertyDirectoryPropertyToFile = new HashMap<String,File>();

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<String,File> 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<String,File> ();
}

protected void setContainerEngine(AbstractContainerSupportUtil util) throws PluginExecutionException {
String LIBERTY_DEV_PODMAN = "liberty.dev.podman";
Object podmanPropValue = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -235,7 +237,7 @@ else if (util == null && !noFeaturesSection) {
Set<String> dependencyFeatures = getDependencyFeatures();
Set<String> serverFeatures = new HashSet<String>();
Set<String> serverPlatforms = new HashSet<String>();
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ private void installSpringBootApp() throws MojoExecutionException, IOException {
File fatArchiveSrc = SpringBootUtil.getSpringBootUberJAR(project, getLog());
File serverXML = new File(serverDirectory, "server.xml");

Map<String, File> 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,9 @@ protected void verifyAppStarted(String appFile) throws MojoExecutionException {
try {
File serverXML = new File(serverDirectory, "server.xml");

Map<String, File> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,9 @@ protected void undeployApp(File file) throws MojoExecutionException {
try {
File serverXML = new File(serverDirectory.getCanonicalPath(), "server.xml");

Map<String, File> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,9 @@ protected Set<String> getAppConfigLocationsFromSourceServerXml() {

if (serverXML != null && serverXML.exists()) {
try {
Map<String, File> 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);
Expand All @@ -384,10 +383,10 @@ protected Set<String> getAppConfigLocationsFromSourceServerXml() {
return scd != null ? scd.getLocations() : new HashSet<String>();
}

protected ServerConfigDocument getServerConfigDocument(CommonLoggerI log, File serverXML, Map<String, File> 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());
}
Expand Down