diff --git a/docs/guide/intro/index.adoc b/docs/guide/intro/index.adoc
index 8ac9fad5..4ab0a985 100644
--- a/docs/guide/intro/index.adoc
+++ b/docs/guide/intro/index.adoc
@@ -310,6 +310,8 @@ CLI configuration example:
The configuration item `````` allows to build a bootable JAR for cloud environment. By default the server is configured to run inside an OpenShift context.
Set the cloud child element ```openshift|kubernetes``` to select the targeted cloud platform.
+Adding the `````` element to the plugin configuration automatically enables the cloud support. Set the cloud child element ```false``` to disable the cloud support.
+
The sever configuration is updated in order to properly operate in a cloud environment:
* If no Galleon layers are provisioned, the provisioned configuration is ```standalone-microprofile-ha.xml``` instead of ```standalone-microprofile.xml```.
diff --git a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/cloud/CloudConfig.java b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/cloud/CloudConfig.java
index aef9253a..c8789f62 100644
--- a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/cloud/CloudConfig.java
+++ b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/cloud/CloudConfig.java
@@ -61,6 +61,16 @@ public class CloudConfig {
//Can be openshift or kubernetes
String type = OPENSHIFT;
+ private boolean enabled = true;
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
public boolean getEnableJGroupsPassword() {
return enableJgroupsPassword;
}
diff --git a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/BuildBootableJarMojo.java b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/BuildBootableJarMojo.java
index 96a75995..d1482279 100644
--- a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/BuildBootableJarMojo.java
+++ b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/BuildBootableJarMojo.java
@@ -37,6 +37,8 @@ public class BuildBootableJarMojo extends AbstractBuildBootableJarMojo {
/**
* To enable cloud support. When cloud support is enabled, the created bootable JAR will operate properly in context such as openshift.
+ * Adding the <cloud/> element to the plugin configuration automatically enables the cloud support.
+ * You can set the cloud child element <enabled>false</enabled> to disable the cloud support.
*
* In order to enable authenticated cluster jgroups protocol,
* set <enable-jgroups-password>true</enable-jgroups-password>. The environment variable JGROUPS_CLUSTER_PASSWORD
@@ -45,6 +47,10 @@ public class BuildBootableJarMojo extends AbstractBuildBootableJarMojo {
@Parameter(alias = "cloud")
CloudConfig cloud;
+ boolean isCloudEnabled() {
+ return cloud != null && cloud.isEnabled();
+ }
+
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
@@ -52,7 +58,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
return;
}
if (!isPackageDev()) {
- if (cloud != null) {
+ if (isCloudEnabled()) {
getLog().info("Cloud support is enabled");
cloud.validate();
for (String layer : cloud.getExtraLayers(this)) {
@@ -65,7 +71,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
@Override
protected void configureCli(List commands) {
- if (cloud != null) {
+ if (isCloudEnabled()) {
try {
cloud.addCLICommands(this, commands);
} catch (Exception ex) {
@@ -76,7 +82,7 @@ protected void configureCli(List commands) {
@Override
protected ConfigId getDefaultConfig() {
- if(cloud == null) {
+ if(!isCloudEnabled()) {
return super.getDefaultConfig();
} else {
return new ConfigId("standalone", "standalone-microprofile-ha.xml");
@@ -85,7 +91,7 @@ protected ConfigId getDefaultConfig() {
@Override
protected void copyExtraContentInternal(Path wildflyDir, Path contentDir) throws Exception {
- if (cloud != null) {
+ if (isCloudEnabled()) {
cloud.copyExtraContent(this, wildflyDir, contentDir);
}
}
diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/OpenShiftConfigurationTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/OpenShiftConfigurationTestCase.java
index fdd6d6c5..c8e32e17 100644
--- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/OpenShiftConfigurationTestCase.java
+++ b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/OpenShiftConfigurationTestCase.java
@@ -35,6 +35,7 @@ public void testOpenshiftConfiguration() throws Exception {
assertNotNull(mojo);
assertFalse(mojo.layers.isEmpty());
assertNotNull(mojo.cloud);
+ assertTrue(mojo.cloud.isEnabled());
assertEquals(1, mojo.layers.size());
assertEquals("jaxrs", mojo.layers.get(0));
mojo.recordState = true;
diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/OpenShiftDisabledConfigurationTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/OpenShiftDisabledConfigurationTestCase.java
new file mode 100644
index 00000000..c9dad4b5
--- /dev/null
+++ b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/OpenShiftDisabledConfigurationTestCase.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2021 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.nio.file.Path;
+
+import org.junit.Test;
+
+/**
+ * @author jdenise
+ */
+public class OpenShiftDisabledConfigurationTestCase extends AbstractBootableJarMojoTestCase {
+
+ public OpenShiftDisabledConfigurationTestCase() {
+ super("test-cloud-disabled-pom.xml", true, null);
+ }
+
+ @Test
+ public void testOpenshiftConfiguration() throws Exception {
+ BuildBootableJarMojo mojo = lookupMojo("package");
+ assertNotNull(mojo);
+ assertFalse(mojo.layers.isEmpty());
+ assertNotNull(mojo.cloud);
+ assertFalse(mojo.cloud.isEnabled());
+ assertEquals(2, mojo.layers.size());
+ assertEquals("jaxrs", mojo.layers.get(0));
+ assertEquals("management", mojo.layers.get(1));
+ mojo.recordState = true;
+ mojo.execute();
+ String[] layers = {"jaxrs", "management"};
+ final Path dir = getTestDir();
+ checkJar(dir, true, true, layers, null);
+ checkDeployment(dir, true);
+ }
+}
diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ServerModeOpenShiftConfigurationTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ServerModeOpenShiftConfigurationTestCase.java
index c110b0fe..4475e159 100644
--- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ServerModeOpenShiftConfigurationTestCase.java
+++ b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ServerModeOpenShiftConfigurationTestCase.java
@@ -35,6 +35,7 @@ public void testOpenshiftConfiguration() throws Exception {
assertNotNull(mojo);
assertFalse(mojo.layers.isEmpty());
assertNotNull(mojo.cloud);
+ assertTrue(mojo.cloud.isEnabled());
assertEquals(1, mojo.layers.size());
assertEquals("jaxrs", mojo.layers.get(0));
mojo.recordState = true;
diff --git a/tests/src/test/resources/poms/test-cloud-disabled-pom.xml b/tests/src/test/resources/poms/test-cloud-disabled-pom.xml
new file mode 100644
index 00000000..06280549
--- /dev/null
+++ b/tests/src/test/resources/poms/test-cloud-disabled-pom.xml
@@ -0,0 +1,33 @@
+
+
+
+ 4.0.0
+ org.wildfly.plugins.tests
+ 1.0.0.Final-SNAPSHOT
+ test2
+ war
+
+ WildFly bootable jar Example for tests
+
+
+ test
+
+
+ wildfly-jar-maven-plugin
+
+ TEST_REPLACE
+
+ jaxrs
+ management
+
+
+ deployment-scanner
+
+ false
+
+
+
+
+
+
diff --git a/tests/src/test/resources/poms/test-servermode5-pom.xml b/tests/src/test/resources/poms/test-servermode5-pom.xml
index ba704174..acd45f5b 100644
--- a/tests/src/test/resources/poms/test-servermode5-pom.xml
+++ b/tests/src/test/resources/poms/test-servermode5-pom.xml
@@ -24,7 +24,7 @@
deployment-scanner
-
+ true