OpenLiberty / ci.maven

Maven plugins for managing Liberty profile servers #devops
Apache License 2.0
130 stars 91 forks source link

Handle loose app with target directory outside of project root #876

Open ericglau opened 4 years ago

ericglau commented 4 years ago

Maven projects can have the target directory outside of the project root, see here e.g.

<build>
    <directory>/Users/eric/tmp</directory>
</build>

For dev mode with containers, the loose application xml would currently show something like the following, which does not work since the paths are not in the container.

<?xml version="1.0" encoding="UTF-8"?>
<archive>
    <dir sourceOnDisk="${io.openliberty.tools.projectRoot}/src/main/webapp" targetInArchive="/"/>
    <dir sourceOnDisk="/Users/eric/tmp/classes/java/main" targetInArchive="/WEB-INF/classes/"/>
    <file sourceOnDisk="/Users/eric/tmp/tmp/META-INF/MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
</archive>

Consider adding another variable for the build dir in addition to the project root, and use that for variable substitution as well.

If the build dir is outside of the project root, it would also need to be mounted by the docker run command.

(Related Gradle issue: https://github.com/OpenLiberty/ci.gradle/issues/489)

cherylking commented 4 years ago

Just want to add that currently the code uses the following: private final String PROJECT_ROOT_TARGET_LIBS = "target/libs";

which should not be hardcode and needs to change to the path of project.getBuild().getDirectory().