@@ -457,17 +457,17 @@ private static boolean artifactsToCompareAreInvalid(Artifact previous, Artifact
457
457
|| !isSameArtifact (previous , next );
458
458
}
459
459
460
- public Properties getFrontendProperties (Server server ) throws MojoExecutionException {
461
- com .github .zafarkhaja .semver .Version v = com .github .zafarkhaja .semver .Version .parse (server .getVersion ());
460
+ public Properties getFrontendProperties (Artifact distroArtifact , File directory ) throws MojoExecutionException {
461
+ com .github .zafarkhaja .semver .Version v = com .github .zafarkhaja .semver .Version .parse (distroArtifact .getVersion ());
462
462
463
463
Artifact artifact ;
464
464
if (v .satisfies (">=3.0.0" )) {
465
- artifact = new Artifact ("distro-emr-frontend" , server .getVersion (), server . getDistroGroupId (), "zip" );
465
+ artifact = new Artifact ("distro-emr-frontend" , distroArtifact .getVersion (), distroArtifact . getGroupId (), "zip" );
466
466
} else {
467
- artifact = new Artifact ("referenceapplication-frontend" , server .getVersion (), server . getDistroGroupId (), "zip" );
467
+ artifact = new Artifact ("referenceapplication-frontend" , distroArtifact .getVersion (), distroArtifact . getGroupId (), "zip" );
468
468
}
469
469
470
- File frontendDistroFile = downloadDistro (server . getServerDirectory () , artifact , "frontend.zip" );
470
+ File frontendDistroFile = downloadDistro (directory , artifact , "frontend.zip" );
471
471
Properties frontendProperties = new Properties ();
472
472
473
473
try (ZipFile zipFile = new ZipFile (frontendDistroFile )) {
@@ -479,7 +479,7 @@ public Properties getFrontendProperties(Server server) throws MojoExecutionExcep
479
479
frontendProperties = PropertiesUtils .getFrontendPropertiesFromJson (inputStream );
480
480
}
481
481
break ;
482
- }
482
+ }
483
483
}
484
484
}
485
485
catch (IOException e ) {
@@ -493,20 +493,30 @@ public Properties getFrontendProperties(Server server) throws MojoExecutionExcep
493
493
return frontendProperties ;
494
494
}
495
495
496
+ public Properties getFrontendProperties (Server server ) throws MojoExecutionException {
497
+ Artifact artifact = new Artifact (server .getDistroArtifactId (), server .getVersion (), server .getDistroGroupId ());
498
+ return getFrontendProperties (artifact , server .getServerDirectory ());
499
+ }
500
+
501
+ public Properties getFrontendPropertiesForServer (Artifact artifact , File directory ) throws MojoExecutionException {
502
+ if (new Version (artifact .getVersion ()).higher (new Version ("3.0.0-beta.16" ))) {
503
+ return getFrontendProperties (artifact , directory );
504
+ } else {
505
+ return PropertiesUtils .getFrontendPropertiesFromSpaConfigUrl (
506
+ "https://raw.githubusercontent.com/openmrs/openmrs-distro-referenceapplication/" + artifact .getVersion () + "/frontend/spa-build-config.json" );
507
+ }
508
+ }
509
+
496
510
public Properties getFrontendPropertiesForServer (Server server ) throws MojoExecutionException {
497
- if (new Version (server .getVersion ()).higher (new Version ("3.0.0-beta.16" ))) {
498
- return getFrontendProperties (server );
499
- } else {
500
- return PropertiesUtils .getFrontendPropertiesFromSpaConfigUrl (
501
- "https://raw.githubusercontent.com/openmrs/openmrs-distro-referenceapplication/" + server .getVersion () + "/frontend/spa-build-config.json" );
502
- }
511
+ Artifact artifact = new Artifact (server .getDistroArtifactId (), server .getVersion (), server .getDistroGroupId ());
512
+ return getFrontendPropertiesForServer (artifact , server .getServerDirectory ());
503
513
}
504
514
505
- public Properties getArtifactProperties (Artifact artifact , Server server , String appShellVersion ) throws MojoExecutionException {
506
- File file = downloadDistro (server . getServerDirectory () , artifact );
515
+ public Properties getArtifactProperties (Artifact artifact , File directory , String appShellVersion ) throws MojoExecutionException {
516
+ File file = downloadDistro (directory , artifact );
507
517
Properties properties = new Properties ();
508
518
properties .putAll (PropertiesUtils .getDistroProperties (file ));
509
- properties .putAll (getFrontendPropertiesForServer (server ));
519
+ properties .putAll (getFrontendPropertiesForServer (artifact , directory ));
510
520
properties .putAll (PropertiesUtils .getConfigurationProperty (artifact ));
511
521
properties .put (PROPERTY_DISTRO_GROUP_ID , artifact .getGroupId ());
512
522
properties .put (PROPERTY_DISTRO_ARTIFACT_ID , artifact .getArtifactId ());
@@ -517,4 +527,30 @@ public Properties getArtifactProperties(Artifact artifact, Server server, String
517
527
return properties ;
518
528
}
519
529
530
+
531
+ public Properties getArtifactProperties (Artifact artifact , Server server , String appShellVersion ) throws MojoExecutionException {
532
+ return getArtifactProperties (artifact , server .getServerDirectory (), appShellVersion );
533
+ }
534
+
535
+ public DistroProperties resolveParentArtifact (Artifact parentArtifact , File directory , DistroProperties distroProperties , String appShellVersion ) throws MojoExecutionException {
536
+ Properties properties = getArtifactProperties (parentArtifact , directory , appShellVersion );
537
+ for (Object key : distroProperties .getAllKeys ()) {
538
+ String keyStr = (String ) key ;
539
+ properties .setProperty (keyStr , distroProperties .getParam (keyStr ));
540
+ }
541
+ List <String > exclusions = distroProperties .getExclusions ();
542
+
543
+ for (String exclusion : exclusions ) {
544
+ properties .remove (exclusion );
545
+ }
546
+ return new DistroProperties (properties );
547
+ }
548
+
549
+ public DistroProperties resolveParentArtifact (Artifact parentArtifact , Server server , DistroProperties distroProperties , String appShellVersion ) throws MojoExecutionException {
550
+ server .setDistroArtifactId (parentArtifact .getArtifactId ());
551
+ server .setDistroGroupId (parentArtifact .getGroupId ());
552
+ server .setVersion (parentArtifact .getVersion ());
553
+ return resolveParentArtifact (parentArtifact , server .getServerDirectory (), distroProperties , appShellVersion );
554
+ }
555
+
520
556
}
0 commit comments