Skip to content

Commit

Permalink
SDK-347 - Follow-up fix to support distro paths in build-distro goal
Browse files Browse the repository at this point in the history
  • Loading branch information
mseaton committed Nov 26, 2024
1 parent e46df8c commit 1a79cfe
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ else if (Project.hasProject(userDir)) {
}
}
else if (StringUtils.isNotBlank(distro)) {
Artifact distroArtifact = DistroHelper.parseDistroArtifact(distro, versionsHelper);
distribution = builder.buildFromArtifact(distroArtifact);
distribution = distroHelper.resolveDistributionForStringSpecifier(distro, versionsHelper);
}

if (distribution == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ public DistroProperties createDistroForPlatform(Server server) {

/**
* Saves all custom properties from distroProperties starting with "property." to server
*
* @param properties
* @param server
*/
public void savePropertiesToServer(DistroProperties properties, Server server) throws MojoExecutionException {
if (properties != null) {
Expand Down Expand Up @@ -245,7 +242,6 @@ public File extractFileFromDistro(File path, Artifact artifact, String filename)
FileUtils.copyInputStreamToFile(zipFile.getInputStream(zipEntry), resultFile);
}
}
zipFile.close();
}
catch (IOException e) {
throw new MojoExecutionException("Could not read \"" + distroFile.getAbsolutePath() + "\" to temp folder " + e.getMessage(), e);
Expand All @@ -257,37 +253,9 @@ public File extractFileFromDistro(File path, Artifact artifact, String filename)
return resultFile;
}

public DistroProperties downloadDistroProperties(File path, Artifact artifact) throws MojoExecutionException {
File file = downloadDistro(path, artifact);
DistroProperties distroProperties = null;
try (ZipFile zipFile = new ZipFile(file)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();

while (entries.hasMoreElements()) {
ZipEntry zipEntry = entries.nextElement();
if ("openmrs-distro.properties".equals(zipEntry.getName()) || "distro.properties".equals(zipEntry.getName())) {
Properties properties = new Properties();
properties.load(zipFile.getInputStream(zipEntry));
distroProperties = new DistroProperties(properties);
}
}
}
catch (IOException e) {
throw new MojoExecutionException("Could not read \"" + file.getAbsolutePath() + "\" " + e.getMessage(), e);
}
finally {
file.delete();
}

return distroProperties;
}

/**
* Distro can be passed in two ways: either as maven artifact identifier or path to distro file
* Returns null if string is invalid as path or identifier
*
* @param distro
* @return
*/
public Distribution resolveDistributionForStringSpecifier(String distro, VersionsHelper versionsHelper) throws MojoExecutionException {
DistributionBuilder builder = new DistributionBuilder(mavenEnvironment);
Expand All @@ -310,9 +278,6 @@ public Distribution resolveDistributionForStringSpecifier(String distro, Version
/**
* Distro can be passed in two ways: either as maven artifact identifier or path to distro file
* Returns null if string is invalid as path or identifier
*
* @param distro
* @return
*/
public DistroProperties resolveDistroPropertiesForStringSpecifier(String distro, VersionsHelper versionsHelper) throws MojoExecutionException {
Distribution distribution = resolveDistributionForStringSpecifier(distro, versionsHelper);
Expand Down

0 comments on commit 1a79cfe

Please sign in to comment.