diff --git a/plugin/src/main/java/org/wildfly/plugin/common/PropertyNames.java b/plugin/src/main/java/org/wildfly/plugin/common/PropertyNames.java
index a0bbd4f5..f5413ca2 100644
--- a/plugin/src/main/java/org/wildfly/plugin/common/PropertyNames.java
+++ b/plugin/src/main/java/org/wildfly/plugin/common/PropertyNames.java
@@ -33,6 +33,8 @@ public interface PropertyNames {
String BATCH = "wildfly.batch";
+ String CHANNELS = "wildfly.channels";
+
String CHECK_PACKAGING = "wildfly.checkPackaging";
String COMMANDS = "wildfly.commands";
diff --git a/plugin/src/main/java/org/wildfly/plugin/dev/DevMojo.java b/plugin/src/main/java/org/wildfly/plugin/dev/DevMojo.java
index b9325ca6..d5952bd4 100644
--- a/plugin/src/main/java/org/wildfly/plugin/dev/DevMojo.java
+++ b/plugin/src/main/java/org/wildfly/plugin/dev/DevMojo.java
@@ -347,8 +347,39 @@ public class DevMojo extends AbstractServerStartMojo {
/**
* A list of channels used for resolving artifacts while provisioning.
+ *
+ * Defining a channel:
+ *
+ *
+ * <channels>
+ * <channel>
+ * <manifest>
+ * <groupId>org.wildfly.channels</groupId>
+ * <artifactId>wildfly-30.0</artifactId>
+ * </manifest>
+ * </channel>
+ * <channel>
+ * <manifest>
+ * <url>https://example.example.org/channel/30</url>
+ * </manifest>
+ * </channel>
+ * </channels>
+ *
+ *
+ *
+ * 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")
+ @Parameter(property = PropertyNames.CHANNELS)
private List channels;
/**
@@ -479,7 +510,7 @@ public String goal() {
@Override
protected MavenRepoManager createMavenRepoManager() throws MojoExecutionException {
- if (channels == null) {
+ if (channels == null || channels.isEmpty()) {
return offlineProvisioning ? new MavenArtifactRepositoryManager(repoSystem, session)
: new MavenArtifactRepositoryManager(repoSystem, session, repositories);
} else {
diff --git a/plugin/src/main/java/org/wildfly/plugin/provision/AbstractProvisionServerMojo.java b/plugin/src/main/java/org/wildfly/plugin/provision/AbstractProvisionServerMojo.java
index f170e1b9..79a7bf2b 100644
--- a/plugin/src/main/java/org/wildfly/plugin/provision/AbstractProvisionServerMojo.java
+++ b/plugin/src/main/java/org/wildfly/plugin/provision/AbstractProvisionServerMojo.java
@@ -184,7 +184,41 @@ abstract class AbstractProvisionServerMojo extends AbstractMojo {
@Parameter(alias = "layers-configuration-file-name", property = PropertyNames.WILDFLY_LAYERS_CONFIGURATION_FILE_NAME, defaultValue = STANDALONE_XML)
String layersConfigurationFileName;
- @Parameter(alias = "channels", required = false)
+ /**
+ * 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", property = PropertyNames.CHANNELS)
List channels;
/**
@@ -217,7 +251,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
return;
}
enrichRepositories();
- if (channels == null) {
+ if (channels == null || channels.isEmpty()) {
artifactResolver = offlineProvisioning ? new MavenArtifactRepositoryManager(repoSystem, repoSession)
: new MavenArtifactRepositoryManager(repoSystem, repoSession, repositories);
} else {
diff --git a/plugin/src/main/java/org/wildfly/plugin/provision/ChannelConfiguration.java b/plugin/src/main/java/org/wildfly/plugin/provision/ChannelConfiguration.java
index 3aeebefd..d543e304 100644
--- a/plugin/src/main/java/org/wildfly/plugin/provision/ChannelConfiguration.java
+++ b/plugin/src/main/java/org/wildfly/plugin/provision/ChannelConfiguration.java
@@ -16,8 +16,11 @@
*/
package org.wildfly.plugin.provision;
+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;
@@ -32,6 +35,7 @@
* @author jdenise
*/
public class ChannelConfiguration {
+ private static final Pattern FILE_MATCHER = Pattern.compile("^(file|http|https)://.*");
private ChannelManifestCoordinate manifest;
@@ -42,6 +46,28 @@ public ChannelManifestCoordinate getManifest() {
return 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.");
+ }
+ }
+ }
+
void setManifest(ChannelManifestCoordinate manifest) {
this.manifest = manifest;
}