-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to passing a custom spa-build-config.json file #316
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,9 @@ public class BuildDistro extends AbstractTask { | |
@Parameter(property = "appShellVersion") | ||
private String appShellVersion; | ||
|
||
@Parameter(property = "spaConfigFile") | ||
private String spaConfigFile; | ||
|
||
@Override | ||
public void executeTask() throws MojoExecutionException, MojoFailureException { | ||
File buildDirectory = getBuildDirectory(); | ||
|
@@ -165,7 +168,7 @@ else if (StringUtils.isNotBlank(distro)) { | |
case REFAPP_3X_PROMPT: | ||
artifact = wizard.promptForRefApp3xArtifact(versionsHelper); | ||
} | ||
distribution = builder.buildFromArtifact(artifact); | ||
distribution = builder.buildFromArtifact(artifact, spaConfigFile); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having to bolt on this extra property here is an indication that this isn't the way other things work in building the distro, and I'd like to avoid adding these special cases in. |
||
} | ||
|
||
if (distribution == null) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,6 +153,9 @@ public class Setup extends AbstractServerTask { | |
@Parameter(property = "reuseNodeCache") | ||
public Boolean overrideReuseNodeCache; | ||
|
||
@Parameter(property = "spaConfigFile") | ||
public String spaConfigFile; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should revisit the entire set of properties around how O3 is included in the SDK, before we add new properties in. For example - why do we have |
||
|
||
private ServerHelper serverHelper; | ||
|
||
public Setup() { | ||
|
@@ -239,10 +242,11 @@ private DistroProperties resolveDistroProperties(Server server) throws MojoExecu | |
|
||
if (REFAPP_3X_PROMPT.equals(choice)) { | ||
Artifact artifact = wizard.promptForRefApp3xArtifact(versionsHelper); | ||
Distribution distribution = builder.buildFromArtifact(artifact); | ||
return distribution.getEffectiveProperties(); | ||
Distribution distribution = builder.buildFromArtifact(artifact, spaConfigFile); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See earlier comment |
||
return distribution.getEffectiveProperties(); | ||
} | ||
|
||
|
||
// If here, it is because custom distribution was chosen and the choice reflects the Maven coordinates | ||
Distribution distribution = distroHelper.resolveDistributionForStringSpecifier(choice, versionsHelper); | ||
return distribution.getEffectiveProperties(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ | |
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.Objects; | ||
import java.util.Properties; | ||
|
||
|
@@ -47,7 +50,7 @@ public Distribution buildFromFile(File propertiesFile) throws MojoExecutionExcep | |
/** | ||
* Build from a distro properties file bundled in a zip or jar in Maven with the given artifact coordinates | ||
*/ | ||
public Distribution buildFromArtifact(Artifact artifact) throws MojoExecutionException { | ||
public Distribution buildFromArtifact(Artifact artifact, String spaConfigFile) throws MojoExecutionException { | ||
mavenEnvironment.getWizard().showMessage("Building distribution from artifact: " + artifact); | ||
Distribution distribution = new Distribution(); | ||
artifact = DistroHelper.normalizeArtifact(artifact, mavenEnvironment.getVersionsHelper()); | ||
|
@@ -92,11 +95,15 @@ public Distribution buildFromArtifact(Artifact artifact) throws MojoExecutionExc | |
// Special handling for referenceapplication 3.x, which does not define everything needed in the published distro properties file | ||
if (REFAPP_3X_GROUP_ID.equals(artifact.getGroupId()) && REFAPP_3X_ARTIFACT_ID.equals(artifact.getArtifactId())) { | ||
mavenEnvironment.getWizard().showMessage("This is a 3.x refapp distribution"); | ||
populateRefApp3xProperties(distribution, properties); | ||
populateRefApp3xProperties(distribution, properties, spaConfigFile); | ||
} | ||
return populateDistributionFromProperties(distribution, properties); | ||
} | ||
|
||
public Distribution buildFromArtifact(Artifact artifact) throws MojoExecutionException { | ||
return buildFromArtifact(artifact, null); | ||
} | ||
|
||
public void populateRefApp2xProperties(Distribution distribution, Properties properties) { | ||
// Some refapp versions (eg. 2.13.0) include atlas version 2.2.6, which is not published in Maven. Adjust this. | ||
if ("2.2.6".equals(properties.getProperty("omod.atlas"))) { | ||
|
@@ -110,7 +117,7 @@ public void populateRefApp2xProperties(Distribution distribution, Properties pro | |
* This encapsulates these and applies them only for distributions that match the 3.x refapp Maven coordinates | ||
* Ideally this would not be needed | ||
*/ | ||
protected void populateRefApp3xProperties(Distribution distribution, Properties properties) throws MojoExecutionException { | ||
protected void populateRefApp3xProperties(Distribution distribution, Properties properties, String spaConfigFile) throws MojoExecutionException { | ||
|
||
String distroArtifactId = distribution.getArtifact().getArtifactId(); | ||
String distroGroupId = distribution.getArtifact().getGroupId(); | ||
|
@@ -137,7 +144,14 @@ protected void populateRefApp3xProperties(Distribution distribution, Properties | |
// Add spa properties if they are not included explicitly | ||
if (includedProperties.getSpaProperties().isEmpty()) { | ||
Properties frontendProperties; | ||
if (new Version(distroVersion).higher(new Version("3.0.0-beta.16"))) { | ||
if (spaConfigFile != null) { | ||
try { | ||
frontendProperties = PropertiesUtils.getFrontendPropertiesFromJson(Files.newInputStream(Paths.get(spaConfigFile))); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
else if (new Version(distroVersion).higher(new Version("3.0.0-beta.16"))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fate of this will depend on the other decisions we make in the questions I raise above, but we should review the hacks that already exist to support refapp 3.x.x here as we look at how best to support these use cases moving forward. |
||
com.github.zafarkhaja.semver.Version v = com.github.zafarkhaja.semver.Version.parse(distroVersion); | ||
String frontendArtifactId = v.satisfies(">=3.0.0") ? "distro-emr-frontend" : "referenceapplication-frontend"; | ||
Artifact frontendArtifact = new Artifact(frontendArtifactId, distroVersion, distroGroupId, "zip"); | ||
|
@@ -169,6 +183,10 @@ protected void populateRefApp3xProperties(Distribution distribution, Properties | |
} | ||
} | ||
|
||
protected void populateRefApp3xProperties(Distribution distribution, Properties properties) throws MojoExecutionException { | ||
populateRefApp3xProperties(distribution, properties, null); | ||
} | ||
|
||
/** | ||
* Consistently populate the common properties of the distribution from the given properties | ||
* This includes handling parent distributions and building a set of effective properties based on | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand how this would be used in the
build-distro
goal. A distribution is intended to be something that is fully represented in an openmrs-distro.properties file. So any configuration needs to be able to be represented in that file - either as aspa.xxx
property, or as coordinates to an artifact of a known type. This is why/how we have used content packages as this known artifact/type.In fact, I would rather see us remove most of the properties that are currently in this job, rather than add new ones, as I think most are probably ill-advised, and would have been better represented as configuration options inside of the openmrs-distro.properties file itself. @ibacher - thoughts?