Skip to content

Commit

Permalink
Merge pull request #1089 from ericglau/1084
Browse files Browse the repository at this point in the history
Use separate folder for devc specific loose app
  • Loading branch information
ericglau authored Feb 1, 2021
2 parents bd96edc + 5b07d1b commit 2e215e5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.openliberty.tools.common.plugins.config.ApplicationXmlDocument;
import io.openliberty.tools.common.plugins.config.LooseConfigData;
import io.openliberty.tools.common.plugins.config.ServerConfigDocument;
import io.openliberty.tools.common.plugins.util.DevUtil;

/**
* Copy applications to the specified directory of the Liberty server.
Expand Down Expand Up @@ -190,14 +191,24 @@ private void installLooseApplication(MavenProject proj) throws Exception {
String application = looseConfigFileName.substring(0, looseConfigFileName.length() - 4);
File destDir = new File(serverDirectory, getAppsDirectory());
File looseConfigFile = new File(destDir, looseConfigFileName);

File devcDestDir = new File(new File(project.getBuild().getDirectory(), DevUtil.DEVC_HIDDEN_FOLDER), getAppsDirectory());
File devcLooseConfigFile = new File(devcDestDir, looseConfigFileName);

LooseConfigData config = new LooseConfigData();

switch (proj.getPackaging()) {
case "war":
validateAppConfig(application, proj.getArtifactId());
log.info(MessageFormat.format(messages.getString("info.install.app"), looseConfigFileName));
installLooseConfigWar(proj, config);
installLooseConfigWar(proj, config, false);
installAndVerifyApp(config, looseConfigFile, application);
if (proj.getProperties().containsKey("container")) {
// install another copy that is container specific
config = new LooseConfigData();
installLooseConfigWar(proj, config, true);
config.toXmlFile(devcLooseConfigFile);
}
break;
case "ear":
validateAppConfig(application, proj.getArtifactId());
Expand All @@ -209,8 +220,14 @@ private void installLooseApplication(MavenProject proj) throws Exception {
if (mavenWarPluginExists(proj) || new File(proj.getBasedir(), "src/main/webapp").exists()) {
validateAppConfig(application, proj.getArtifactId());
log.info(MessageFormat.format(messages.getString("info.install.app"), looseConfigFileName));
installLooseConfigWar(proj, config);
installLooseConfigWar(proj, config, false);
installAndVerifyApp(config, looseConfigFile, application);
if (proj.getProperties().containsKey("container")) {
// install another copy that is container specific
config = new LooseConfigData();
installLooseConfigWar(proj, config, true);
config.toXmlFile(devcLooseConfigFile);
}
} else {
log.debug("The liberty-assembly project does not contain the maven-war-plugin or src/main/webapp does not exist.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ protected void installApp(Artifact artifact) throws Exception {
}

// install war project artifact using loose application configuration file
protected void installLooseConfigWar(MavenProject proj, LooseConfigData config) throws Exception {
protected void installLooseConfigWar(MavenProject proj, LooseConfigData config, boolean container) throws Exception {
// return error if webapp contains java source but it is not compiled yet.
File dir = new File(proj.getBuild().getOutputDirectory());
if (!dir.exists() && containsJavaSource(proj)) {
throw new MojoExecutionException(
MessageFormat.format(messages.getString("error.project.not.compile"), proj.getId()));
}

if (proj.getProperties().containsKey("container")) {
if (container) {
try {
// Set up the config to replace the absolute path names with ${variable}/target type references
config.setProjectRoot(proj.getBasedir().getCanonicalPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private class DevMojoUtil extends DevUtil {

public DevMojoUtil(File installDir, File userDir, File serverDirectory, File sourceDirectory, File testSourceDirectory, File configDirectory, File projectDirectory,
List<File> resourceDirs, JavaCompilerOptions compilerOptions, String mavenCacheLocation) throws IOException {
super(serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, projectDirectory, resourceDirs, hotTests,
super(new File(project.getBuild().getDirectory()), serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, projectDirectory, resourceDirs, hotTests,
skipTests, skipUTs, skipITs, project.getArtifactId(), serverStartTimeout, verifyTimeout, verifyTimeout,
((long) (compileWait * 1000L)), libertyDebug, false, false, pollingTest, container, dockerfile, dockerRunOpts,
dockerBuildTimeout, skipDefaultPorts, compilerOptions, keepTempDockerfile, mavenCacheLocation);
Expand Down Expand Up @@ -348,9 +348,6 @@ public ServerTask getServerTask() throws Exception {
// Setup server task
serverTask = initializeJava();
copyConfigFiles();
if (container) {
generateDevModeConfig(project.getBasedir().getCanonicalPath(), HEADER);
}
serverTask.setClean(clean);
if (libertyDebug) {
setLibertyDebugPort(libertyDebugPort);
Expand Down

0 comments on commit 2e215e5

Please sign in to comment.