Skip to content

Commit

Permalink
Merge pull request #357 from jfdenise/support-ee
Browse files Browse the repository at this point in the history
Fix for Issue #325, [WF28] Support for wildfly-ee-galleon-pack
  • Loading branch information
jfdenise authored Mar 31, 2023
2 parents 2da4385 + da73aa6 commit c3b0c85
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
import org.jboss.galleon.layout.ProvisioningLayout;
import org.jboss.galleon.universe.FeaturePackLocation;
import org.wildfly.plugins.bootablejar.maven.goals.BuildBootableJarMojo;

import static org.wildfly.plugins.bootablejar.maven.goals.AbstractBuildBootableJarMojo.STANDALONE;
import static org.wildfly.plugins.bootablejar.maven.goals.AbstractBuildBootableJarMojo.STANDALONE_XML;
/**
* @author jdenise
*/
Expand Down Expand Up @@ -69,6 +70,22 @@ public static class ProvisioningSpecifics {
public String getHealthLayer() {
return healthLayer;
}

public ConfigId getDefaultConfig(boolean isCloud) {
if (isCloud) {
if (isMicroprofile) {
return new ConfigId(STANDALONE, "standalone-microprofile-ha.xml");
} else {
return new ConfigId(STANDALONE, "standalone-ha.xml");
}
} else {
if (isMicroprofile) {
return new ConfigId(STANDALONE, "standalone-microprofile.xml");
} else {
return new ConfigId(STANDALONE, STANDALONE_XML);
}
}
}
}

private static final Pattern WHITESPACE_IF_NOT_QUOTED = Pattern.compile("(\\S+\"[^\"]+\")|\\S+");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ public abstract class AbstractBuildBootableJarMojo extends AbstractMojo {

private static final String BOOT_ARTIFACT_ID = "wildfly-jar-boot";

private static final String STANDALONE = "standalone";
private static final String STANDALONE_XML = "standalone.xml";
private static final String STANDALONE_MICROPROFILE_XML = "standalone-microprofile.xml";
public static final String STANDALONE = "standalone";
public static final String STANDALONE_XML = "standalone.xml";
private static final String SERVER_CONFIG = "--server-config";
private static final String MAVEN_REPO_PLUGIN_OPTION = "jboss-maven-repo";

Expand Down Expand Up @@ -860,7 +859,8 @@ protected List<String> getExcludedLayers() {
return excludedLayers;
}

private GalleonConfig buildFeaturePacksConfig(ProvisioningManager pm, boolean hasLayers) throws ProvisioningException, MojoExecutionException {
private GalleonConfig buildFeaturePacksConfig(ProvisioningManager pm, boolean hasLayers,
ConfigId defaultConfig) throws ProvisioningException, MojoExecutionException {
ProvisioningConfig.Builder state = ProvisioningConfig.builder();
ConfigId provisionedConfigId = null;
for (FeaturePack fp : featurePacks) {
Expand Down Expand Up @@ -899,7 +899,7 @@ private GalleonConfig buildFeaturePacksConfig(ProvisioningManager pm, boolean ha
} else {
// We don't have an explicit default config and we have no layers, must include the default one.
if (!hasLayers && provisionedConfigId == null) {
provisionedConfigId = getDefaultConfig();
provisionedConfigId =defaultConfig;
fpConfig.includeDefaultConfig(provisionedConfigId);
}
}
Expand Down Expand Up @@ -1015,7 +1015,6 @@ public AbstractLayersConfig() throws ProvisioningDescriptionException, Provision
}
}


/**
* Galleon layers based config that uses the set of feature-packs.
*/
Expand Down Expand Up @@ -1137,7 +1136,7 @@ private String formatLocation(String location) {
return location;
}

private GalleonConfig buildGalleonConfig(ProvisioningManager pm) throws ProvisioningException, MojoExecutionException {
private GalleonConfig buildGalleonConfig(ProvisioningManager pm, ConfigId defaultConfig) throws ProvisioningException, MojoExecutionException {
boolean isLayerBasedConfig = !layers.isEmpty();
boolean hasFeaturePack = !featurePacks.isEmpty();
boolean hasProvisioningFile = Files.exists(getProvisioningFile());
Expand All @@ -1154,13 +1153,13 @@ private GalleonConfig buildGalleonConfig(ProvisioningManager pm) throws Provisio
if (!hasFeaturePack) {
throw new ProvisioningException("No server feature-pack location to provision layers, you must set a feature-pack-location");
}
return buildFeaturePacksConfig(pm, true);
return buildFeaturePacksConfig(pm, true, defaultConfig);
}

// Based on default config
if (!featurePacks.isEmpty()) {
getLog().info("Provisioning server using feature-packs");
return buildFeaturePacksConfig(pm, isLayerBasedConfig);
return buildFeaturePacksConfig(pm, isLayerBasedConfig, defaultConfig);
}

if (hasProvisioningFile) {
Expand All @@ -1170,13 +1169,13 @@ private GalleonConfig buildGalleonConfig(ProvisioningManager pm) throws Provisio
throw new ProvisioningException("Invalid Galleon configuration");
}

private void willProvision(List<FeaturePack> featurePacks, ProvisioningManager pm)
private ConfigId willProvision(List<FeaturePack> featurePacks, ProvisioningManager pm)
throws MojoExecutionException, ProvisioningException, IOException {
ProvisioningSpecifics specifics = Utils.getSpecifics(featurePacks, pm);
willProvision(specifics);
return willProvision(specifics);
}

protected abstract void willProvision(ProvisioningSpecifics specifics) throws MojoExecutionException;
protected abstract ConfigId willProvision(ProvisioningSpecifics specifics) throws MojoExecutionException;

private Artifact provisionServer(Path home, Path outputProvisioningFile, Path workDir) throws ProvisioningException,
MojoExecutionException, IOException, XMLStreamException {
Expand All @@ -1190,8 +1189,8 @@ private Artifact provisionServer(Path home, Path outputProvisioningFile, Path wo
// Prior to build the config, sub classes could have to inject content to the config according to the
// provisioned FP.
normalizeFeaturePackList();
willProvision(featurePacks, pm);
ProvisioningConfig config = buildGalleonConfig(pm).buildConfig();
ConfigId defaultConfig = willProvision(featurePacks, pm);
ProvisioningConfig config = buildGalleonConfig(pm, defaultConfig).buildConfig();
IoUtils.recursiveDelete(home);
getLog().info("Building server based on " + config.getFeaturePackDeps() + " galleon feature-packs");
MavenUpgrade mavenUpgrade = null;
Expand Down Expand Up @@ -1312,10 +1311,6 @@ private Artifact provisionServer(Path home, Path outputProvisioningFile, Path wo
}
}

protected ConfigId getDefaultConfig() {
return new ConfigId(STANDALONE, STANDALONE_MICROPROFILE_XML);
}

// Get Artifact, syntax comply with WildFly feature-pack versions file.
static Artifact getArtifact(String str) {
final String[] parts = str.split(":");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ protected boolean updateManifest(Manifest manifest) {
return false;
}

@Override
protected void willProvision(ProvisioningSpecifics specifics) throws
protected ConfigId willProvision(ProvisioningSpecifics specifics) throws
MojoExecutionException {
if (!isPackageDev()) {
if (cloud != null) {
Expand All @@ -76,6 +75,7 @@ protected void willProvision(ProvisioningSpecifics specifics) throws
}
}
}
return specifics.getDefaultConfig(cloud != null);
}

@Override
Expand All @@ -89,15 +89,6 @@ protected void configureCli(List<String> commands) {
}
}

@Override
protected ConfigId getDefaultConfig() {
if(cloud == null) {
return super.getDefaultConfig();
} else {
return new ConfigId("standalone", "standalone-microprofile-ha.xml");
}
}

@Override
protected void copyExtraContentInternal(Path wildflyDir, Path contentDir) throws Exception {
if (cloud != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright 2023 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.plugins.bootablejar.maven.goals;

import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jboss.galleon.ProvisioningException;
import org.jboss.galleon.ProvisioningManager;
import org.jboss.galleon.config.ConfigId;
import org.jboss.galleon.config.FeaturePackConfig;
import org.jboss.galleon.config.ProvisioningConfig;
import org.jboss.galleon.layout.FeaturePackLayout;
import org.jboss.galleon.layout.ProvisioningLayout;
import org.jboss.galleon.universe.FeaturePackLocation;
import org.wildfly.plugins.bootablejar.maven.common.FeaturePack;
import static org.wildfly.plugins.bootablejar.maven.goals.AbstractBuildBootableJarMojo.STANDALONE;
import static org.wildfly.plugins.bootablejar.maven.goals.AbstractBuildBootableJarMojo.STANDALONE_XML;

/**
*
* @author jdenise
*/
public class FeaturePacksUtil {

private static final String HEALTH = "health";
private static final String MP_HEALTH = "microprofile-health";

public static class ProvisioningSpecifics {

private final boolean isMicroprofile;
private final String healthLayer;

ProvisioningSpecifics(Set<String> allLayers) {
if (allLayers.contains(MP_HEALTH)) {
healthLayer = MP_HEALTH;
isMicroprofile = true;
} else {
if (allLayers.contains(HEALTH)) {
healthLayer = HEALTH;
} else {
healthLayer = null;
}
isMicroprofile = false;
}
}

ConfigId getDefaultConfig(boolean isCloud) {
if (isCloud) {
if (isMicroprofile) {
return new ConfigId(STANDALONE, "standalone-microprofile-ha.xml");
} else {
return new ConfigId(STANDALONE, "standalone-ha.xml");
}
} else {
if (isMicroprofile) {
return new ConfigId(STANDALONE, "standalone-microprofile.xml");
} else {
return new ConfigId(STANDALONE, STANDALONE_XML);
}
}
}

String getHealthLayer() {
return healthLayer;
}
}

static ProvisioningSpecifics getSpecifics(List<FeaturePack> fps, ProvisioningManager pm) throws ProvisioningException, IOException {
return new ProvisioningSpecifics(getAllLayers(fps, pm));
}

private static Set<String> getAllLayers(List<FeaturePack> fps, ProvisioningManager pm) throws ProvisioningException, IOException {
Set<String> allLayers = new HashSet<>();
for (FeaturePack fp : fps) {
final FeaturePackLocation fpl;
if (fp.getNormalizedPath() != null) {
fpl = pm.getLayoutFactory().addLocal(fp.getNormalizedPath(), false);
} else if (fp.getGroupId() != null && fp.getArtifactId() != null) {
String coords = fp.getMavenCoords();
fpl = FeaturePackLocation.fromString(coords);
} else {
fpl = FeaturePackLocation.fromString(fp.getLocation());
}
ProvisioningConfig pConfig = ProvisioningConfig.builder().
addFeaturePackDep(FeaturePackConfig.builder(fpl).build()).build();
try (ProvisioningLayout<FeaturePackLayout> layout = pm.
getLayoutFactory().newConfigLayout(pConfig)) {
allLayers.addAll(getAllLayers(layout));
}
}
return allLayers;
}

private static Set<String> getAllLayers(ProvisioningLayout<FeaturePackLayout> pLayout)
throws ProvisioningException, IOException {
Set<String> layers = new HashSet<>();
for (FeaturePackLayout fp : pLayout.getOrderedFeaturePacks()) {
for (ConfigId layer : fp.loadLayers()) {
layers.add(layer.getName());
}
}
return layers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ if (outcome == success) of /socket-binding-group=standard-sockets/socket-binding
/socket-binding-group=standard-sockets/socket-binding=https:write-attribute(name=interface,value=bindall)
end-if

#remove ajp
#remove ajp and modcluster
if (outcome == success) of /subsystem=modcluster:read-resource
/subsystem=modcluster:remove
end-if
if (outcome == success) of /subsystem=undertow/server=default-server/ajp-listener=ajp:read-resource
/subsystem=undertow/server=default-server/ajp-listener=ajp:remove
end-if

if (outcome == success) of /socket-binding-group=standard-sockets/socket-binding=ajp:read-resource
/socket-binding-group=standard-sockets/socket-binding=ajp:remove
end-if
14 changes: 9 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<!-- Require Java 11 -->
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<version.wildfly>27.0.0.Final</version.wildfly>
<version.wildfly>28.0.0.Beta1</version.wildfly>
<!-- docs properties -->
<docs.project.branch>main</docs.project.branch>
<docs.wildfly.major>27.0</docs.wildfly.major>
Expand All @@ -64,7 +64,7 @@
<version.org.apache.maven.plugin-tools>3.6.4</version.org.apache.maven.plugin-tools>
<version.org.apache.maven.plugin-plugin>3.6.4</version.org.apache.maven.plugin-plugin>
<version.org.asciidoctor>2.0.0</version.org.asciidoctor>
<version.org.jboss.galleon>5.0.8.Final</version.org.jboss.galleon>
<version.org.jboss.galleon>5.0.9.Final</version.org.jboss.galleon>
<version.org.wildfly.core.wildfly-core>20.0.0.Beta8</version.org.wildfly.core.wildfly-core>
<version.org.wildfly.common>1.5.4.Final</version.org.wildfly.common>
<version.org.wildfly.plugins.wildfly-maven-plugin>4.1.0.Beta4</version.org.wildfly.plugins.wildfly-maven-plugin>
Expand All @@ -87,11 +87,15 @@

<maven.test.skip>false</maven.test.skip>
<skipTests>${maven.test.skip}</skipTests>

<test.ee.fpl>wildfly-ee@maven(org.jboss.universe:community-universe)#${version.wildfly}</test.ee.fpl>

<test.default.ee.config>standalone.xml</test.default.ee.config>
<test.default.ee.cloud.config>standalone-ha.xml</test.default.ee.cloud.config>
<test.default.config>standalone-microprofile.xml</test.default.config>
<test.default.cloud.config>standalone-microprofile-ha.xml</test.default.cloud.config>
<test.fpl>wildfly@maven(org.jboss.universe:community-universe)#${version.wildfly}</test.fpl>
<test.ee.fpl>wildfly-ee@maven(org.jboss.universe:community-universe)#${version.wildfly}</test.ee.fpl>
<test.version.wildfly>${version.wildfly}</test.version.wildfly>
<test.version.wildfly-ee.upgrade>27.0.0.Beta1</test.version.wildfly-ee.upgrade>
<test.version.wildfly-ee.upgrade>27.0.1.Final</test.version.wildfly-ee.upgrade>
<test.patch.ee.product>WildFly EE</test.patch.ee.product>
<test.patch.product>WildFly Full</test.patch.product>
<test.patch.version>${version.wildfly}</test.patch.version>
Expand Down
Loading

0 comments on commit c3b0c85

Please sign in to comment.