Skip to content

Commit

Permalink
Merge pull request #285 from jfdenise/review-stability
Browse files Browse the repository at this point in the history
Fix for WFGP-274, Introduce package and config stability
  • Loading branch information
jfdenise authored Mar 19, 2024
2 parents 8ccb403 + 22637f2 commit bd2950e
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private String isResetEmbeddedSystemProperties() throws ProvisioningException {
}

private String getStabilityLevel() throws ProvisioningException {
final String value = runtime.getLowestStability();
final String value = runtime.getLowestConfigStability();
return value == null ? "" : value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,27 @@ static boolean isProvided(String module) {
@Parameter(alias = "minimum-stability", required = false)
protected String minimumStability;

/**
* The default stability level used at provisioning time to generate
* configuration and provision packages. Can't be used when {@code config-stability} or {@code package-stability} is set.
*/
@Parameter(alias = "stability", required = false)
protected String stability;

/**
* The default stability level used at provisioning time to generate
* configuration. Can't be used when {@code stability} is set.
*/
@Parameter(alias = "config-stability", required = false)
protected String configStatibility;

/**
* The default stability level used at provisioning time when installing packages/JBoss Modules modules.
* Can't be used when {@code stability} is set.
*/
@Parameter(alias = "package-stability", required = false)
protected String packageStatibility;

private MavenProjectArtifactVersions artifactVersions;

private Map<String, FeaturePackDescription> fpDependencies = Collections.emptyMap();
Expand All @@ -224,12 +245,27 @@ static boolean isProvided(String module) {
private Path resourcesWildFly;
private Path fpResourcesDir;
private Path resourcesDir;
private Stability stability;
private Stability buildTimestability;
private Stability defaultConfigStability;
private Stability defaultPackageStability;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
stability = minimumStability == null ? null : Stability.fromString(minimumStability);
buildTimestability = minimumStability == null ? null : Stability.fromString(minimumStability);
if (stability == null) {
defaultConfigStability = configStatibility == null ? null : Stability.fromString(configStatibility);
defaultPackageStability = packageStatibility == null ? null : Stability.fromString(packageStatibility);
} else {
if (configStatibility != null) {
throw new MojoExecutionException("stability option can't be set when config-stability option is set");
}
if (packageStatibility != null) {
throw new MojoExecutionException("stability option can't be set when package-stability option is set");
}
defaultConfigStability = Stability.fromString(stability);
defaultPackageStability = Stability.fromString(stability);
}
artifactVersions = MavenProjectArtifactVersions.getInstance(project);
doExecute();
} catch (RuntimeException | Error | MojoExecutionException | MojoFailureException e) {
Expand Down Expand Up @@ -380,7 +416,8 @@ protected void buildFeaturePack(FeaturePackDescription.Builder fpBuilder, WildFl

final FeaturePackDescription fpLayout;
try {
fpBuilder.getSpecBuilder().setMinStability(stability);
fpBuilder.getSpecBuilder().setConfigStability(defaultConfigStability);
fpBuilder.getSpecBuilder().setPackageStability(defaultPackageStability);
fpLayout = fpBuilder.build();
FeaturePackXmlWriter.getInstance().write(fpLayout.getSpec(), getFpDir().resolve(Constants.FEATURE_PACK_XML));
} catch (XMLStreamException | IOException | ProvisioningDescriptionException e) {
Expand Down Expand Up @@ -489,10 +526,10 @@ private void addConfigPackages(final Path configDir, final Path packagesDir, fin
}
Stability packageStability = pkgSpec.getStability();
if (packageStability != null) {
if (stability != null && !stability.enables(packageStability)) {
if (buildTimestability != null && !buildTimestability.enables(packageStability)) {
getLog().warn("Package " + pkgSpec.getName() + " is not included in the feature-pack. "
+ "Package stability '"
+ packageStability + "' is not enabled by the '" + stability
+ packageStability + "' is not enabled by the '" + buildTimestability
+ "' stability level that is the feature-pack minimum stability level.");
continue;
}
Expand Down Expand Up @@ -533,10 +570,10 @@ private void addFeatures(final Path configDir, final Path featuresDir) throws Mo
}
Stability featureStability = featureSpec.getStability();
if (featureStability != null) {
if (stability != null && !stability.enables(featureStability)) {
if (buildTimestability != null && !buildTimestability.enables(featureStability)) {
getLog().warn("Feature " + featureSpec.getName() + " is not included in the feature-pack. "
+ "Feature stability '"
+ featureStability + "' is not enabled by the '" + stability
+ featureStability + "' is not enabled by the '" + buildTimestability
+ "' stability level that is the feature-pack minimum stability level.");
continue;
}
Expand Down Expand Up @@ -776,10 +813,10 @@ private void packageModules(FeaturePackDescription.Builder fpBuilder,
String packageStability = parsedModule.getProperty(WfConstants.JBOSS_STABILITY);
if (packageStability != null) {
Stability stab = Stability.fromString(packageStability);
if (stability != null && !stability.enables(stab)) {
if (buildTimestability != null && !buildTimestability.enables(stab)) {
getLog().warn("JBoss Modules module " + parsedModule.getIdentifier() + " is not included in the feature-pack. "
+ "Package stability '" +
packageStability + "' is not enabled by the '" + stability +
packageStability + "' is not enabled by the '" + buildTimestability +
"' stability level that is the feature-pack minimum stability level.");
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<version.org.codehaus.mojo.xml-maven-plugin>1.0.1</version.org.codehaus.mojo.xml-maven-plugin>
<version.org.codehaus.plexus.plexus-utils>3.1.0</version.org.codehaus.plexus.plexus-utils>
<version.org.eclipse.aether>1.1.0</version.org.eclipse.aether>
<version.org.jboss.galleon>6.0.0.Beta3</version.org.jboss.galleon>
<version.org.jboss.galleon>6.0.0.Beta4</version.org.jboss.galleon>
<version.org.jboss.dmr>1.5.0.Final</version.org.jboss.dmr>

<version.org.wildfly.channel>1.0.5.Final</version.org.wildfly.channel>
Expand Down
2 changes: 2 additions & 0 deletions testsuite/test-feature-packs/community-feature-pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
<configuration>
<config-file>target/resources/build/wildfly-feature-pack-build.xml</config-file>
<minimumStability>community</minimumStability>
<config-stability>community</config-stability>
<package-stability>community</package-stability>
<release-name>Test</release-name>
</configuration>
</execution>
Expand Down
2 changes: 2 additions & 0 deletions testsuite/test-feature-packs/default-feature-pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
<configuration>
<config-file>target/resources/build/wildfly-feature-pack-build.xml</config-file>
<minimumStability>default</minimumStability>
<config-stability>default</config-stability>
<package-stability>default</package-stability>
<release-name>Test</release-name>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<configuration>
<config-file>target/resources/build/wildfly-feature-pack-build.xml</config-file>
<minimumStability>experimental</minimumStability>
<stability>experimental</stability>
<release-name>Test</release-name>
</configuration>
</execution>
Expand Down
1 change: 1 addition & 0 deletions testsuite/test-feature-packs/preview-feature-pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<configuration>
<config-file>target/resources/build/wildfly-feature-pack-build.xml</config-file>
<minimumStability>preview</minimumStability>
<stability>preview</stability>
<release-name>Test</release-name>
</configuration>
</execution>
Expand Down
12 changes: 8 additions & 4 deletions testsuite/tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@
<phase>compile</phase>
<configuration>
<plugin-options>
<stability-level>experimental</stability-level>
<config-stability-level>experimental</config-stability-level>
<package-stability-level>experimental</package-stability-level>
</plugin-options>
<feature-packs>
<feature-pack>
Expand Down Expand Up @@ -275,7 +276,8 @@
<phase>compile</phase>
<configuration>
<plugin-options>
<stability-level>preview</stability-level>
<config-stability-level>preview</config-stability-level>
<package-stability-level>preview</package-stability-level>
</plugin-options>
<feature-packs>
<feature-pack>
Expand Down Expand Up @@ -318,7 +320,8 @@
<phase>compile</phase>
<configuration>
<plugin-options>
<stability-level>community</stability-level>
<config-stability-level>community</config-stability-level>
<package-stability-level>community</package-stability-level>
</plugin-options>
<feature-packs>
<feature-pack>
Expand Down Expand Up @@ -361,7 +364,8 @@
<phase>compile</phase>
<configuration>
<plugin-options>
<stability-level>default</stability-level>
<config-stability-level>default</config-stability-level>
<package-stability-level>default</package-stability-level>
</plugin-options>
<feature-packs>
<feature-pack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@
import org.junit.Test;

/**
* Check stability. 1) Check that the content of the feature-pack is valid
* according to its minimum stability. It must not contain features and packages
* at a lower stability level. 2) Check that what has been provisioned is
* Check stability. Check that what has been provisioned is
* correct according to the stability level set at provisioning time. If no
* stability level is provided, then the minimum stability level of the
* stability level is provided, then the default provisioning stability level of the
* feature-pack has to be used.
*
* @author jdenise
Expand Down Expand Up @@ -93,9 +91,13 @@ private void checkContent(Path home) throws Exception {
Set<String> expectedFeatures = new HashSet<>();
System.out.println("Scanning " + fl.getFPID());
foundFP = true;
Stability minStability = fl.getSpec().getMinStability();
System.out.println("Feature-pack minimum stability " + minStability);
Stability defaultConfigStability = fl.getSpec().getConfigStability();
System.out.println("Feature-pack config stability " + defaultConfigStability);
Stability defaultPackageStability = fl.getSpec().getPackageStability();
System.out.println("Feature-pack package stability " + defaultPackageStability);
Path dir = fl.getDir();
// The test expect that these are always equal.
Stability minStability = defaultPackageStability;
Path packages = dir.resolve(Constants.PACKAGES);
try (DirectoryStream<Path> stream = Files.newDirectoryStream(packages)) {
for (Path packageDir : stream) {
Expand Down

0 comments on commit bd2950e

Please sign in to comment.