Display an error message if container mode and copyLibsDirectory parameter ...
indicates directory outside the Maven project and hence not visible in container.
@@ -114,9 +114,13 @@ public class DeployMojoSupport extends PluginConfigSupport {
config.setProjectRoot(proj.getBasedir().getAbsolutePath());
config.setSourceOnDiskName("${"+PROJECT_ROOT_NAME+"}");
// Set the property to include the variable definition in liberty-plugin-variable-config.xml
- proj.getProperties().setProperty("liberty.var."+PROJECT_ROOT_NAME, proj.getBasedir().getAbsolutePath());
+ String projectPath = proj.getBasedir().getAbsolutePath();
+ proj.getProperties().setProperty("liberty.var."+PROJECT_ROOT_NAME, projectPath);
if (copyLibsDirectory == null) { // in container mode, copy dependencies from .m2 dir to the target dir to mount in container
copyLibsDirectory = new File(proj.getBasedir(), PROJECT_ROOT_TARGET_LIBS);
+ } else if (!copyLibsDirectory.getAbsolutePath().startsWith(projectPath)) {
+ // Flag an error but allow processing to continue in case dependencies, if any, are not actually referenced by the app.
+ log.error("The directory indicated by the copyLibsDirectory parameter must be within the Maven project directory when the container option is specified.");
}
}
