diff --git a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBuildBootableJarMojo.java b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBuildBootableJarMojo.java
index 789627c4..d73f696b 100644
--- a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBuildBootableJarMojo.java
+++ b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBuildBootableJarMojo.java
@@ -323,9 +323,40 @@ public abstract class AbstractBuildBootableJarMojo extends AbstractMojo {
String installArtifactClassifier;
/**
- * List of channel URL and/or Maven coordinates (version being optional).
+ * A list of channels used for resolving artifacts while provisioning.
+ *
+ * Defining a channel:
+ *
+ *
+ *
+ *
+ *
+ * org.wildfly.channels
+ * wildfly-30.0
+ *
+ *
+ *
+ *
+ * https://example.example.org/channel/30
+ *
+ *
+ *
+ *
+ *
+ *
+ * The {@code wildfly.channels} property can be used pass a comma delimited string for the channels. The channel
+ * can be a URL or a Maven GAV. If a Maven GAV is used, the groupId and artifactId are required.
+ *
+ * Examples:
+ *
+ *
+ * -Dwildfly.channels="https://channels.example.org/30"
+ * -Dwildfly.channels="https://channels.example.org/30,org.example.channel:updates-30"
+ * -Dwildfly.channels="https://channels.example.org/30,org.example.channel:updates-30:1.0.2"
+ *
+ *
*/
- @Parameter(alias = "channels", required = false)
+ @Parameter(alias = "channels", property = "wildfly.channels")
List channels;
MavenProjectArtifactVersions artifactVersions;
@@ -472,7 +503,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
private boolean isChannelsProvisioning() {
- return channels != null;
+ return channels != null && !channels.isEmpty();
}
protected boolean isPackageDev() {
diff --git a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelConfiguration.java b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelConfiguration.java
index 01507663..88a38650 100644
--- a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelConfiguration.java
+++ b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelConfiguration.java
@@ -16,8 +16,12 @@
*/
package org.wildfly.plugins.bootablejar.maven.goals;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Pattern;
+
import org.apache.maven.plugin.MojoExecutionException;
import org.eclipse.aether.repository.RemoteRepository;
import org.wildfly.channel.Channel;
@@ -31,6 +35,7 @@
* @author jdenise
*/
public class ChannelConfiguration {
+ private static final Pattern FILE_MATCHER = Pattern.compile("^(file:|http://|https://).*");
private ChannelManifestCoordinate manifest;
@@ -45,6 +50,28 @@ void setManifest(ChannelManifestCoordinate manifest) {
this.manifest = manifest;
}
+ public void set(final String channel) {
+ // Is this a URL?
+ if (FILE_MATCHER.matcher(channel).matches()) {
+ try {
+ this.manifest = new ChannelManifestCoordinate(new URL(channel));
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException("Failed to parse URL for " + channel, e);
+ }
+ } else {
+ // Treat as a Maven GAV
+ final String[] coords = channel.split(":");
+ if (coords.length > 2) {
+ this.manifest = new ChannelManifestCoordinate(coords[0], coords[1], coords[2]);
+ } else if (coords.length == 2) {
+ this.manifest = new ChannelManifestCoordinate(coords[0], coords[1]);
+ } else {
+ throw new IllegalArgumentException(
+ "A channel must be a Maven GAV in the format groupId:artifactId:version. The groupId and artifactId are both required.");
+ }
+ }
+ }
+
private void validate() throws MojoExecutionException {
if (getManifest() == null) {
throw new MojoExecutionException("Invalid Channel. No manifest specified.");
diff --git a/plugin/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelConfigurationTestCase.java b/plugin/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelConfigurationTestCase.java
new file mode 100644
index 00000000..10f80224
--- /dev/null
+++ b/plugin/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelConfigurationTestCase.java
@@ -0,0 +1,75 @@
+package org.wildfly.plugins.bootablejar.maven.goals;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.wildfly.channel.Channel;
+
+import java.util.Collections;
+
+public class ChannelConfigurationTestCase {
+
+ @Test
+ public void testFileUrlFromString() throws Exception {
+ {
+ // Make sure that the notation "file:relative/path" is handled like a file URL, rather than a Maven G:A.
+
+ String url = "file:path/to/manifest.yaml";
+ ChannelConfiguration configuration = new ChannelConfiguration();
+ configuration.set(url);
+ Channel channel = configuration.toChannel(Collections.emptyList());
+
+ Assert.assertNotNull(channel.getManifestCoordinate().getUrl());
+ Assert.assertEquals(url, channel.getManifestCoordinate().getUrl().toExternalForm());
+ }
+
+ {
+ // The notation "file://relative/path" should still be handled like a file URL too.
+
+ String url = "file://path/to/manifest.yaml";
+ ChannelConfiguration configuration = new ChannelConfiguration();
+ configuration.set(url);
+ Channel channel = configuration.toChannel(Collections.emptyList());
+
+ Assert.assertNotNull(channel.getManifestCoordinate().getUrl());
+ Assert.assertEquals(url, channel.getManifestCoordinate().getUrl().toExternalForm());
+ }
+ }
+
+ @Test
+ public void testHttpUrlFromString() throws Exception {
+ String url = "http://wildfly.org/path/to/manifest";
+ ChannelConfiguration configuration = new ChannelConfiguration();
+ configuration.set(url);
+ Channel channel = configuration.toChannel(Collections.emptyList());
+
+ Assert.assertNotNull(channel.getManifestCoordinate().getUrl());
+ Assert.assertEquals(url, channel.getManifestCoordinate().getUrl().toExternalForm());
+ }
+
+ @Test
+ public void testMavenGavFromString() throws Exception {
+ {
+ String gav = "g:a:v";
+ ChannelConfiguration configuration = new ChannelConfiguration();
+ configuration.set(gav);
+ Channel channel = configuration.toChannel(Collections.emptyList());
+
+ Assert.assertNotNull(channel.getManifestCoordinate().getMaven());
+ Assert.assertEquals("g", channel.getManifestCoordinate().getMaven().getGroupId());
+ Assert.assertEquals("a", channel.getManifestCoordinate().getMaven().getArtifactId());
+ Assert.assertEquals("v", channel.getManifestCoordinate().getMaven().getVersion());
+ }
+
+ {
+ String gav = "g:a";
+ ChannelConfiguration configuration = new ChannelConfiguration();
+ configuration.set(gav);
+ Channel channel = configuration.toChannel(Collections.emptyList());
+
+ Assert.assertNotNull(channel.getManifestCoordinate().getMaven());
+ Assert.assertEquals("g", channel.getManifestCoordinate().getMaven().getGroupId());
+ Assert.assertEquals("a", channel.getManifestCoordinate().getMaven().getArtifactId());
+ Assert.assertNull(channel.getManifestCoordinate().getMaven().getVersion());
+ }
+ }
+}