diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java index 40f3ccf2..3ddf5d80 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java @@ -138,6 +138,8 @@ public void executeTask() throws MojoExecutionException, MojoFailureException { if (distroFile.exists()) { wizard.showMessage("Building distribution from the distro file at " + distroFile + "...\n"); distroProperties = new DistroProperties(distroFile); + distroArtifact = distroProperties.getParentArtifact(); + distroProperties = handleParentDistroProperties(distroArtifact, buildDirectory, distroProperties); } else if (Project.hasProject(userDir)) { Project config = Project.loadProject(userDir); distroArtifact = DistroHelper @@ -157,6 +159,8 @@ public void executeTask() throws MojoExecutionException, MojoFailureException { } } else if (StringUtils.isNotBlank(distro)) { distroProperties = distroHelper.resolveDistroPropertiesForStringSpecifier(distro, versionsHelper); + distroArtifact = distroProperties.getParentArtifact(); + distroProperties = handleParentDistroProperties(distroArtifact, buildDirectory, distroProperties); } if (distroProperties == null) { @@ -198,6 +202,18 @@ public void executeTask() throws MojoExecutionException, MojoFailureException { + buildDirectory.getAbsolutePath() + "\n"); } + private DistroProperties handleParentDistroProperties(Artifact distroArtifact, File buildDirectory, DistroProperties distroProperties) throws MojoExecutionException { + if (StringUtils.isNotBlank(distroArtifact.getArtifactId()) && StringUtils.isNotBlank(distroArtifact.getGroupId()) && StringUtils.isNotBlank(distroArtifact.getVersion())) { + Server tempServer = new Server.ServerBuilder().build(); + tempServer.setDistroArtifactId(distroArtifact.getArtifactId()); + tempServer.setDistroGroupId(distroArtifact.getGroupId()); + tempServer.setVersion(distroArtifact.getVersion()); + tempServer.setServerDirectory(buildDirectory); + distroProperties = distroHelper.resolveParentArtifact(distroArtifact, tempServer, distroProperties, appShellVersion); + } + return distroProperties; + } + private File getBuildDirectory() throws MojoExecutionException { final File targetDir; if (StringUtils.isBlank(dir)) { diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java index b1019428..00b23e95 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.Properties; import net.lingala.zip4j.core.ZipFile; import net.lingala.zip4j.exception.ZipException; @@ -219,20 +218,7 @@ private DistroProperties resolveDistroProperties(Server server) throws MojoExecu default: // distro properties from current directory Artifact distroArtifact = distroProperties.getParentArtifact(); if (StringUtils.isNotBlank(distroArtifact.getArtifactId()) && StringUtils.isNotBlank(distroArtifact.getGroupId()) && StringUtils.isNotBlank(distroArtifact.getVersion())) { - server.setDistroArtifactId(distroArtifact.getArtifactId()); - server.setDistroGroupId(distroArtifact.getGroupId()); - server.setVersion(distroArtifact.getVersion()); - Properties properties = distroHelper.getArtifactProperties(distroArtifact, server, appShellVersion); - for (Object key : distroProperties.getAllKeys()) { - String keyStr = (String) key; - properties.setProperty(keyStr, distroProperties.getParam(keyStr)); - } - List exclusions = distroProperties.getExclusions(); - - for (String exclusion : exclusions) { - properties.remove(exclusion); - } - distroProperties = new DistroProperties(properties); + distroProperties = distroHelper.resolveParentArtifact(distroArtifact, server, distroProperties, appShellVersion); } else { server.setPlatformVersion( distroProperties.getPlatformVersion(distroHelper, server.getServerTmpDirectory())); diff --git a/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/DistroHelper.java b/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/DistroHelper.java index 4152fd86..e897ab24 100644 --- a/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/DistroHelper.java +++ b/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/DistroHelper.java @@ -517,4 +517,21 @@ public Properties getArtifactProperties(Artifact artifact, Server server, String return properties; } + public DistroProperties resolveParentArtifact(Artifact parentArtifact, Server server, DistroProperties distroProperties, String appShellVersion) throws MojoExecutionException { + server.setDistroArtifactId(parentArtifact.getArtifactId()); + server.setDistroGroupId(parentArtifact.getGroupId()); + server.setVersion(parentArtifact.getVersion()); + Properties properties = getArtifactProperties(parentArtifact, server, appShellVersion); + for (Object key : distroProperties.getAllKeys()) { + String keyStr = (String) key; + properties.setProperty(keyStr, distroProperties.getParam(keyStr)); + } + List exclusions = distroProperties.getExclusions(); + + for (String exclusion : exclusions) { + properties.remove(exclusion); + } + return new DistroProperties(properties); + } + }