Skip to content

Commit

Permalink
SDK-374 - Remove content package hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
mseaton committed Dec 18, 2024
1 parent 7acc8fb commit 0280368
Showing 1 changed file with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ public void installBackendConfig(DistroProperties distroProperties, File install

/**
* The standard content package template places the backend config into a folder within the zip archive at `configuration/backend_configuration`
* However, other initial content packages did not follow this pattern.
* To account for these, this will also attempt to look for backend_config in other directories, if the preferred directories does not exist
* Any text files that contain variable references will have these references populated based on the given vars map
*/
void installBackendConfig(ContentPackage contentPackage, Map<String, String> vars, File installDir) throws MojoExecutionException {
Expand All @@ -125,18 +123,13 @@ void installBackendConfig(ContentPackage contentPackage, Map<String, String> var
try (TempDirectory tempDirectory = TempDirectory.create(artifact.getArtifactId() + "-content-package")) {
mavenEnvironment.getArtifactHelper().downloadArtifact(artifact, tempDirectory.getFile(), true);

// Get the backend directory. If not found, fall back to some alternatives for compatibility with existing artifacts
// Install the backend configuration directory, if it exists
File backendDir = tempDirectory.getPath().resolve("configuration").resolve("backend_configuration").toFile();
if (!backendDir.exists() || !backendDir.isDirectory()) {
backendDir = tempDirectory.getPath().resolve("configs").resolve("backend_config").toFile();
if (backendDir.exists() && backendDir.isDirectory()) {
// Apply variable replacements to the downloaded files and copy into the installDir
applyVariableReplacements(vars, backendDir);
copyDirectory(backendDir, installDir, contentPackage.getNamespace());
}
if (!backendDir.exists() || !backendDir.isDirectory()) {
backendDir = tempDirectory.getFile();
}

// Apply variable replacements to the downloaded files and copy into the installDir
applyVariableReplacements(vars, backendDir);
copyDirectory(backendDir, installDir, contentPackage.getNamespace());
}
catch (IOException e) {
throw new MojoExecutionException("Unable to install backend configuration to " + installDir, e);
Expand All @@ -158,8 +151,6 @@ public void installFrontendConfig(DistroProperties distroProperties, File instal

/**
* The standard content package template places the backend config into a folder within the zip archive at `configuration/frontend_configuration`
* However, other initial content packages did not follow this pattern.
* To account for these, this will also attempt to look for frontend_config, if the preferred directory does not exist
* Any text files that contain variable references will have these references populated based on the given vars map
*/
void installFrontendConfig(ContentPackage contentPackage, Map<String, String> vars, File installDir) throws MojoExecutionException {
Expand All @@ -168,15 +159,13 @@ void installFrontendConfig(ContentPackage contentPackage, Map<String, String> va
try (TempDirectory tempDirectory = TempDirectory.create(artifact.getArtifactId() + "-content-package")) {
mavenEnvironment.getArtifactHelper().downloadArtifact(artifact, tempDirectory.getFile(), true);

// Get the frontend directory. If not found, fall back to some alternatives for compatibility with existing artifacts
// Install the frontend configuration directory, if it exists
File frontendDir = tempDirectory.getPath().resolve("configuration").resolve("frontend_configuration").toFile();
if (!frontendDir.exists() || !frontendDir.isDirectory()) {
frontendDir = tempDirectory.getPath().resolve("configs").resolve("frontend_config").toFile();
if (frontendDir.exists() && frontendDir.isDirectory()) {
// Apply variable replacements to the downloaded files and copy into the installDir
applyVariableReplacements(vars, frontendDir);
copyDirectory(frontendDir, installDir, contentPackage.getNamespace());
}

// Apply variable replacements to the downloaded files and copy into the installDir
applyVariableReplacements(vars, frontendDir);
copyDirectory(frontendDir, installDir, contentPackage.getNamespace());
}
catch (IOException e) {
throw new MojoExecutionException("Unable to install frontend configuration to " + installDir, e);
Expand Down

0 comments on commit 0280368

Please sign in to comment.