88
99import java .io .File ;
1010import java .io .FileInputStream ;
11+ import java .io .IOException ;
12+ import java .nio .file .Files ;
13+ import java .nio .file .Paths ;
1114import java .util .Objects ;
1215import java .util .Properties ;
1316
@@ -47,7 +50,7 @@ public Distribution buildFromFile(File propertiesFile) throws MojoExecutionExcep
4750 /**
4851 * Build from a distro properties file bundled in a zip or jar in Maven with the given artifact coordinates
4952 */
50- public Distribution buildFromArtifact (Artifact artifact ) throws MojoExecutionException {
53+ public Distribution buildFromArtifact (Artifact artifact , String spaConfigFile ) throws MojoExecutionException {
5154 mavenEnvironment .getWizard ().showMessage ("Building distribution from artifact: " + artifact );
5255 Distribution distribution = new Distribution ();
5356 artifact = DistroHelper .normalizeArtifact (artifact , mavenEnvironment .getVersionsHelper ());
@@ -92,11 +95,15 @@ public Distribution buildFromArtifact(Artifact artifact) throws MojoExecutionExc
9295 // Special handling for referenceapplication 3.x, which does not define everything needed in the published distro properties file
9396 if (REFAPP_3X_GROUP_ID .equals (artifact .getGroupId ()) && REFAPP_3X_ARTIFACT_ID .equals (artifact .getArtifactId ())) {
9497 mavenEnvironment .getWizard ().showMessage ("This is a 3.x refapp distribution" );
95- populateRefApp3xProperties (distribution , properties );
98+ populateRefApp3xProperties (distribution , properties , spaConfigFile );
9699 }
97100 return populateDistributionFromProperties (distribution , properties );
98101 }
99102
103+ public Distribution buildFromArtifact (Artifact artifact ) throws MojoExecutionException {
104+ return buildFromArtifact (artifact , null );
105+ }
106+
100107 public void populateRefApp2xProperties (Distribution distribution , Properties properties ) {
101108 // Some refapp versions (eg. 2.13.0) include atlas version 2.2.6, which is not published in Maven. Adjust this.
102109 if ("2.2.6" .equals (properties .getProperty ("omod.atlas" ))) {
@@ -110,7 +117,7 @@ public void populateRefApp2xProperties(Distribution distribution, Properties pro
110117 * This encapsulates these and applies them only for distributions that match the 3.x refapp Maven coordinates
111118 * Ideally this would not be needed
112119 */
113- protected void populateRefApp3xProperties (Distribution distribution , Properties properties ) throws MojoExecutionException {
120+ protected void populateRefApp3xProperties (Distribution distribution , Properties properties , String spaConfigFile ) throws MojoExecutionException {
114121
115122 String distroArtifactId = distribution .getArtifact ().getArtifactId ();
116123 String distroGroupId = distribution .getArtifact ().getGroupId ();
@@ -137,7 +144,14 @@ protected void populateRefApp3xProperties(Distribution distribution, Properties
137144 // Add spa properties if they are not included explicitly
138145 if (includedProperties .getSpaProperties ().isEmpty ()) {
139146 Properties frontendProperties ;
140- if (new Version (distroVersion ).higher (new Version ("3.0.0-beta.16" ))) {
147+ if (spaConfigFile != null ) {
148+ try {
149+ frontendProperties = PropertiesUtils .getFrontendPropertiesFromJson (Files .newInputStream (Paths .get (spaConfigFile )));
150+ } catch (IOException e ) {
151+ throw new RuntimeException (e );
152+ }
153+ }
154+ else if (new Version (distroVersion ).higher (new Version ("3.0.0-beta.16" ))) {
141155 com .github .zafarkhaja .semver .Version v = com .github .zafarkhaja .semver .Version .parse (distroVersion );
142156 String frontendArtifactId = v .satisfies (">=3.0.0" ) ? "distro-emr-frontend" : "referenceapplication-frontend" ;
143157 Artifact frontendArtifact = new Artifact (frontendArtifactId , distroVersion , distroGroupId , "zip" );
@@ -169,6 +183,10 @@ protected void populateRefApp3xProperties(Distribution distribution, Properties
169183 }
170184 }
171185
186+ protected void populateRefApp3xProperties (Distribution distribution , Properties properties ) throws MojoExecutionException {
187+ populateRefApp3xProperties (distribution , properties , null );
188+ }
189+
172190 /**
173191 * Consistently populate the common properties of the distribution from the given properties
174192 * This includes handling parent distributions and building a set of effective properties based on
0 commit comments