29 | * If defined this overrides the {@code filename} and {@code targetDir} configuration parameters.
30 | *
31 | */
32 | @Parameter(alias = "content-url", property = PropertyNames.DEPLOYMENT_CONTENT_URL)
33 | private URL contentUrl;
34 |
35 | @Override
36 | public String goal() {
37 | return "redeploy";
38 | }
39 |
40 | @Override
41 | protected Deployment createDeployment() {
42 | if (contentUrl == null) {
43 | return super.createDeployment();
44 | }
45 | return Deployment.of(contentUrl);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/package-glow-no-deployment-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 | true
20 | packaged-glow-no-deployment-server
21 |
22 |
23 | openapi
24 |
25 | true
26 | WF_VERSION
27 |
28 |
29 |
30 | true
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/provision-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 |
23 |
24 |
25 | jaxrs-server
26 |
27 | false
28 | provisioned-server
29 |
30 |
31 | true
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/image-server-config-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 |
23 |
24 | image-server-config
25 | test.war
26 | wildfly-image-server-config-maven-plugin
27 | standalone-microprofile.xml
28 |
29 |
30 | true
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/plugin/src/main/java/org/wildfly/plugin/deployment/RedeployMojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | package org.wildfly.plugin.deployment;
7 |
8 | import java.io.IOException;
9 |
10 | import org.apache.maven.plugins.annotations.Execute;
11 | import org.apache.maven.plugins.annotations.LifecyclePhase;
12 | import org.apache.maven.plugins.annotations.Mojo;
13 | import org.apache.maven.plugins.annotations.ResolutionScope;
14 | import org.wildfly.plugin.tools.Deployment;
15 | import org.wildfly.plugin.tools.DeploymentManager;
16 | import org.wildfly.plugin.tools.DeploymentResult;
17 |
18 | /**
19 | * Redeploys the application to the WildFly Application Server.
20 | *
21 | * @author James R. Perkins
22 | */
23 | @Mojo(name = "redeploy", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true)
24 | @Execute(phase = LifecyclePhase.PACKAGE)
25 | public class RedeployMojo extends AbstractAppDeployment {
26 |
27 | @Override
28 | public String goal() {
29 | return "redeploy";
30 | }
31 |
32 | @Override
33 | protected DeploymentResult executeDeployment(final DeploymentManager deploymentManager, final Deployment deployment)
34 | throws IOException, MojoDeploymentException {
35 | // Ensure the deployment exists before attempting to redeploy it
36 | if (!deploymentManager.hasDeployment(deployment.getName())) {
37 | throw new MojoDeploymentException(
38 | "The deployment %s does not exist in the content repository and cannot be redeployed.",
39 | deployment.getName());
40 | }
41 | return deploymentManager.redeploy(deployment);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/add-resource-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 | subsystem=datasources
20 |
21 |
22 | data-source=java:/ds-name1
23 |
24 | java:jboss/ds-name1
25 | true
26 | jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
27 | org.h2.Driver
28 | h2
29 | sa
30 | sa
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/image-unknown-docker-binary-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 |
23 |
24 |
25 | jaxrs-server
26 |
27 | image-server
28 | wildfly-maven-plugin
29 | focker-is-not-docker
30 |
31 |
32 | true
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Reporting of CVEs and Security Issues
2 |
3 | ## The WildFly community and our sponsor, Red Hat, take security bugs very seriously
4 |
5 | We aim to take immediate action to address serious security-related problems that involve our projects.
6 |
7 | Note that we will only fix such issues in the most recent minor release of WildFly.
8 |
9 | ## Reporting of Security Issues
10 |
11 | When reporting a security vulnerability it is important to not accidentally broadcast to the world that the issue exists, as this makes it easier for people to exploit it. The software industry uses the term embargo to describe the time a security issue is known internally until it is public knowledge.
12 |
13 | Our preferred way of reporting security issues in WildFly and its related projects is listed below.
14 |
15 | ### Email the mailing list
16 |
17 | The list at security@wildfly.org is the preferred mechanism for outside users to report security issues. A member of the WildFly team will open the required issues.
18 |
19 | ### Other considerations
20 |
21 | If you would like to work with us on a fix for the security vulnerability, please include your GitHub username in the above email, and we will provide you access to a temporary private fork where we can collaborate on a fix without it being disclosed publicly, **including in your own publicly visible git repository**.
22 |
23 | Do not open a public issue, send a pull request, or disclose any information about the suspected vulnerability publicly, **including in your own publicly visible git repository**. If you discover any publicly disclosed security vulnerabilities, please notify us immediately through security@wildfly.org
24 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/java/org/wildfly/plugin/deployment/resources/AddResourceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | package org.wildfly.plugin.deployment.resources;
7 |
8 | import static org.junit.Assert.*;
9 |
10 | import org.junit.Test;
11 | import org.wildfly.plugin.deployment.resource.AddResourceMojo;
12 | import org.wildfly.plugin.tests.AbstractWildFlyServerMojoTest;
13 |
14 | /**
15 | * AddResource test case
16 | *
17 | * @author Dave Heath
18 | */
19 | // @Ignore("Composite operations don't seem to be working with datasources")
20 | public class AddResourceTest extends AbstractWildFlyServerMojoTest {
21 |
22 | @Test
23 | public void testCanAddCompositeResource() throws Exception {
24 |
25 | final AddResourceMojo addResourceMojo = lookupMojoAndVerify("add-resource", "add-resource-with-composite-pom.xml");
26 | try {
27 | addResourceMojo.execute();
28 | } catch (Exception ex) {
29 | fail(ex.getMessage());
30 | }
31 |
32 | }
33 |
34 | @Test
35 | public void testCanAddResource() throws Exception {
36 |
37 | final AddResourceMojo addResourceMojo = lookupMojoAndVerify("add-resource", "add-resource-pom.xml");
38 | try {
39 | addResourceMojo.execute();
40 | } catch (Exception ex) {
41 | fail(ex.getMessage());
42 | }
43 |
44 | }
45 |
46 | @Test
47 | public void testCanAddXaDataSource() throws Exception {
48 |
49 | final AddResourceMojo addResourceMojo = lookupMojoAndVerify("add-resource", "add-resource-xa-datasource.xml");
50 | try {
51 | addResourceMojo.execute();
52 | } catch (Exception ex) {
53 | fail(ex.getMessage());
54 | }
55 |
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/tests/domain-tests/src/test/resources/test-project/add-resource-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 | full
21 |
22 | subsystem=datasources
23 |
24 |
25 | data-source=java:/ds-name1
26 |
27 | java:jboss/ds-name1
28 | true
29 | jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
30 | org.h2.Driver
31 | h2
32 | sa
33 | sa
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/.github/workflows/generate-and-deploy-site.yml:
--------------------------------------------------------------------------------
1 | # Simple workflow for deploying static content to GitHub Pages
2 | name: Generate and deploy the site
3 |
4 | on:
5 | # Runs on pushes version tags
6 | push:
7 | tags:
8 | - v*
9 |
10 | # Allows you to run this workflow manually from the Actions tab
11 | workflow_dispatch:
12 |
13 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14 | permissions:
15 | contents: read
16 | pages: write
17 | id-token: write
18 |
19 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
20 | # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
21 | concurrency:
22 | group: 'pages'
23 | cancel-in-progress: false
24 |
25 | jobs:
26 | # Generate the site
27 | generate-site:
28 | runs-on: ubuntu-latest
29 | steps:
30 | - name: Checkout
31 | uses: actions/checkout@v6
32 | - name: Setup Pages
33 | id: pages
34 | uses: actions/configure-pages@v5
35 | - name: Set up JDK 21
36 | uses: actions/setup-java@v5
37 | with:
38 | java-version: 21
39 | cache: 'maven'
40 | distribution: 'temurin'
41 | - name: Generate JavaDoc
42 | run: |
43 | cd plugin
44 | mvn -B -ntp clean -Pjboss-release site
45 | - name: Upload artifact
46 | uses: actions/upload-pages-artifact@v4
47 | with:
48 | # Upload the site
49 | path: 'plugin/target/site/'
50 | # Single deploy job since we're just deploying
51 | deploy:
52 | environment:
53 | name: github-pages
54 | url: ${{ steps.deployment.outputs.page_url }}
55 | runs-on: ubuntu-latest
56 | needs: generate-site
57 | steps:
58 | - name: Deploy to GitHub Pages
59 | id: deployment
60 | uses: actions/deploy-pages@v4
61 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/image-layers-server-config-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 |
23 |
24 |
25 | jaxrs-server
26 |
27 | image-layers-server-config
28 | test.war
29 | wildfly-image-layers-server-config-maven-plugin
30 | standalone-core.xml
31 |
32 |
33 | true
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/tests/bootable-tests/src/test/resources/test-project/package-bootable-root-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 |
23 |
24 |
25 | jaxrs-server
26 |
27 | ROOT.war
28 | true
29 | packaged-root-bootable-server
30 | true
31 | jar-root.jar
32 |
33 |
34 | true
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | 4.0.0
9 |
10 | org.wildfly.plugins
11 | wildfly-maven-plugin-parent
12 | 6.0.0.Beta1-SNAPSHOT
13 |
14 |
15 | wildfly-plugin-core
16 | WildFly Plugin Core Utilities
17 |
18 |
19 | Utilities for Maven plugins to interact with WildFly.
20 |
21 |
22 |
23 |
24 | org.apache.maven
25 | maven-core
26 | provided
27 |
28 |
29 | org.jboss.logging
30 | jboss-logging
31 |
32 |
33 | org.apache.maven.shared
34 | maven-artifact-transfer
35 |
36 |
37 |
38 |
39 |
40 |
41 | maven-jar-plugin
42 |
43 |
44 |
45 | org.wildfly.plugin.core
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/plugin/src/main/java/org/wildfly/plugin/dev/WatchHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | package org.wildfly.plugin.dev;
7 |
8 | import java.io.IOException;
9 | import java.nio.file.Path;
10 | import java.nio.file.WatchEvent;
11 |
12 | import org.apache.maven.plugin.MojoExecutionException;
13 |
14 | /**
15 | * A handler for changes that happen to source files.
16 | *
17 | * @author James R. Perkins
18 | */
19 | public interface WatchHandler {
20 |
21 | Result handle(WatchContext context, WatchEvent event, Path file) throws IOException, MojoExecutionException;
22 |
23 | /**
24 | * The result of handling the changed source file.
25 | */
26 | interface Result {
27 |
28 | /**
29 | * Indicates whether a recompile is required.
30 | *
31 | * @return {@code true} if a recompile is required
32 | */
33 | default boolean requiresRecompile() {
34 | return false;
35 | }
36 |
37 | /**
38 | * Indicates whether the deployment should be redeployed is required.
39 | *
40 | * @return {@code true} if the deployment should be redeployed is required
41 | */
42 | default boolean requiresRedeploy() {
43 | return false;
44 | }
45 |
46 | /**
47 | * Indicates whether the resources should be copied.
48 | *
49 | * @return {@code true} if the resources should be copied
50 | */
51 | default boolean requiresCopyResources() {
52 | return false;
53 | }
54 |
55 | /**
56 | * Indicates whether the deployment should be repackaged.
57 | *
58 | * @return {@code true} if the deployment should be repackaged
59 | */
60 | default boolean requiresRepackage() {
61 | return false;
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/tests/bootable-tests/src/test/resources/test-project/package-bootable-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 |
23 |
24 |
25 | jaxrs-server
26 |
27 | test.war
28 | server-bootable.jar
29 | true
30 | packaged-bootable-server
31 | true
32 | true
33 |
34 |
35 | true
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | = WildFly Application Server Maven Plugin
2 |
3 | A Maven plug-in for WildFly Application Server. This plugin allows you to:
4 |
5 | * Deploy, redeploy or undeploy your application
6 | * Add resources
7 | * Deploy and undeploy artifacts
8 | * Execute CLI commands
9 | * Run a standalone server within Maven
10 | * Galleon provisioning of a server.
11 | * Packaging of a fully configured server containing application deployment.
12 | * Packaging of a fully configured server and application as a Bootable JAR (an executable fat JAR).
13 |
14 | Plugin documentation is at https://docs.wildfly.org/wildfly-maven-plugin
15 |
16 | Issues can be filed at https://issues.redhat.com/browse/WFMP
17 |
18 | == License
19 |
20 | * link:LICENSE.txt[ASLv2]
21 |
22 | == Releasing
23 |
24 | Releasing this project requires access to https://repository.jboss.org/nexust[JBoss Nexus].
25 |
26 | To perform a release ensure you're on the correct branch and that branch is up to date. Once done you can simply use
27 | the `release.sh` bash script.
28 |
29 | [source,bash]
30 | ----
31 | ./release.sh -r 5.1.4.Final -d 5.1.5.Final-SNAPSHOT
32 | ----
33 |
34 | If this was successful, instructions will be printed on the console with the next set of instructions for processing.
35 |
36 | [source,base]
37 | ----
38 | ...
39 | [INFO] ------------------------------------------------------------------------
40 | [INFO] BUILD SUCCESS
41 | [INFO] ------------------------------------------------------------------------
42 | [INFO] Total time: 02:59 min
43 | [INFO] Finished at: 2025-09-04T13:32:25-07:00
44 | [INFO] ------------------------------------------------------------------------
45 |
46 | Your release has been successful. Check the validation after 13:42:25 on https://repository.jboss.org/nexus.
47 | Once validation is successful, execute the following command:
48 |
49 | git checkout v5.1.4.Final
50 | mvn nxrm3:staging-move -Dmaven.repo.local="/tmp/m2/repository/wildfly-maven-plugin"
51 | git checkout main
52 | git push upstream main
53 | git push upstream v5.1.4.Final
54 | ----
--------------------------------------------------------------------------------
/.github/workflows/wildfly-build.yml:
--------------------------------------------------------------------------------
1 | # This workflow is for a nightly run against WildFly upstream
2 |
3 | name: WildFly Test Build
4 |
5 | on:
6 | push:
7 | branches:
8 | - 'main'
9 | paths:
10 | - '.github/workflows/wildfly-build.yml'
11 | - 'core/**'
12 | - 'plugin/**'
13 | - 'tests/**'
14 | - '**/pom.xml'
15 | pull_request:
16 | branches:
17 | - '**'
18 | paths:
19 | - '.github/workflows/wildfly-build.yml'
20 | - 'core/**'
21 | - 'plugin/**'
22 | - 'tests/**'
23 | - '**/pom.xml'
24 | schedule:
25 | - cron: '0 0 * * *' # Every day at 00:00 UTC
26 |
27 | # Only run the latest job and cancel previous ones
28 | concurrency:
29 | group: '${{ github.ref || github.run_id }}'
30 | cancel-in-progress: true
31 |
32 | jobs:
33 |
34 | wildfly-maven-plugin-build:
35 | runs-on: ${{ matrix.os }}
36 | strategy:
37 | fail-fast: false
38 | matrix:
39 | os: [ubuntu-latest, windows-latest]
40 | java: ['17', '21', '25']
41 |
42 | steps:
43 | - uses: actions/checkout@v6
44 | - uses: wildfly-extras/wildfly-nightly-download@v1
45 | id: wildfly-nightly
46 | - name: Set up JDK ${{ matrix.java }}
47 | uses: actions/setup-java@v5
48 | with:
49 | java-version: ${{ matrix.java }}
50 | distribution: 'temurin'
51 | cache: 'maven'
52 | - name: Build with Maven Java ${{ matrix.java }}
53 | run: mvn clean install '-Dorg.jboss.logmanager.nocolor=true' '-Dversion.org.wildfly=${{steps.wildfly-nightly.outputs.wildfly-version}}'
54 | - name: Upload surefire reports
55 | uses: actions/upload-artifact@v6
56 | if: failure()
57 | with:
58 | name: surefire-reports-${{ matrix.os }}-${{ matrix.java }}
59 | path: '**/surefire-reports/*'
60 | - name: Upload server logs
61 | uses: actions/upload-artifact@v6
62 | if: failure()
63 | with:
64 | name: server-logs-${{ matrix.os }}-${{ matrix.java }}
65 | path: '**/*.log'
66 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/image-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 |
23 |
24 |
25 | jaxrs-server
26 |
27 | image-server
28 | test.war
29 | wildfly-maven-plugin
30 |
31 | 1.0
32 | This text illustrates \
33 | that label-values can span multiple lines.
34 | I have "quoted myself" here.
35 |
36 |
37 |
38 | true
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/package-no-deployment-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 | false
23 | false
24 |
25 |
26 | standalone
27 | standalone.xml
28 |
29 |
30 |
31 |
32 | true
33 | packaged-no-dep-server
34 |
35 |
36 | true
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/plugin/src/main/java/org/wildfly/plugin/dev/WebAppResourceHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | package org.wildfly.plugin.dev;
7 |
8 | import java.io.IOException;
9 | import java.nio.file.Path;
10 | import java.nio.file.WatchEvent;
11 | import java.util.Collection;
12 | import java.util.HashSet;
13 | import java.util.Locale;
14 | import java.util.Set;
15 | import java.util.stream.Collectors;
16 |
17 | /**
18 | * @author James R. Perkins
19 | */
20 | class WebAppResourceHandler implements WatchHandler {
21 | private static final Set NO_DEPLOYMENT_WEB_FILE_EXTENSIONS = Set.of(
22 | ".xhtml",
23 | ".html",
24 | ".jsp",
25 | ".js",
26 | ".css");
27 |
28 | private final Set ignoredFileExtensions;
29 |
30 | WebAppResourceHandler(final Collection ignoredFileExtensions) {
31 | this.ignoredFileExtensions = ignoredFileExtensions.stream()
32 | .map((value) -> value.charAt(0) == '.' ? value : "." + value)
33 | .collect(Collectors.toCollection(HashSet::new));
34 | this.ignoredFileExtensions.addAll(NO_DEPLOYMENT_WEB_FILE_EXTENSIONS);
35 | }
36 |
37 | @Override
38 | public Result handle(final WatchContext context, final WatchEvent event, final Path file) throws IOException {
39 | // Check the file extension to see if a redeploy should be ignored
40 | final String fileName = file.getFileName().toString();
41 | final int dot = fileName.lastIndexOf('.');
42 | final boolean requiresRedeploy = dot <= 0 ||
43 | !ignoredFileExtensions.contains(fileName.substring(dot).toLowerCase(Locale.ROOT));
44 | return new Result() {
45 |
46 | @Override
47 | public boolean requiresRepackage() {
48 | return true;
49 | }
50 |
51 | @Override
52 | public boolean requiresRedeploy() {
53 | return requiresRedeploy;
54 | }
55 | };
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/plugin/src/site/fml/faq.fml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
13 |
14 |
15 | What versions of maven will the plugin work with?
16 |
17 |
The plugin requires maven 3.3.1 or higher.
18 |
19 |
20 |
21 | Why are archived server downloads being deprecated?
22 |
23 |
24 | In 3.0.0 new goals will be introduced to allow provisioning a server. WildFly Galleon has come a long
25 | way and it is the preferred means of creating a server. For this reason, the downloading of a server
26 | by means of a Maven artifact will be removed in 3.0.0.
27 |
28 |
29 |
30 |
31 | Why is my server reloading after I execute CLI commands?
32 |
33 |
34 | In 4.2.1 a new configuration parameter, auto-reload, was added which automatically
35 | reloads the running server if offline is set to false and the command
36 | left the server in a state of reload-required. If you previously had a reload operation
37 | or command in your script or command list, you can now remove it. The other option would be to set
38 | the auto-reload configuration to false.
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/plugin/src/main/java/org/wildfly/plugin/deployment/DeployOnlyMojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | package org.wildfly.plugin.deployment;
7 |
8 | import java.net.URL;
9 |
10 | import org.apache.maven.plugins.annotations.Execute;
11 | import org.apache.maven.plugins.annotations.LifecyclePhase;
12 | import org.apache.maven.plugins.annotations.Mojo;
13 | import org.apache.maven.plugins.annotations.Parameter;
14 | import org.wildfly.plugin.common.PropertyNames;
15 | import org.wildfly.plugin.tools.Deployment;
16 |
17 | /**
18 | * Deploys only the application to the WildFly Application Server without first invoking the
19 | * the execution of the lifecycle phase 'package' prior to executing itself.
20 | *
21 | * If {@code force} is set to {@code true}, the server is queried to see if the application already exists. If the
22 | * application already exists, the application is redeployed instead of deployed. If the application does not exist the
23 | * application is deployed as normal.
24 | *
25 | * If {@code force} is set to {@code false} and the application has already been deployed to the server, an error
26 | * will occur and the deployment will fail.
27 | */
28 | @Mojo(name = "deploy-only", threadSafe = true)
29 | @Execute(phase = LifecyclePhase.NONE)
30 | public class DeployOnlyMojo extends DeployMojo {
31 |
32 | /**
33 | * A URL representing the a path to the content to be deployed. The server the content is being deployed to will
34 | * require access to the URL.
35 | *
36 | * If defined this overrides the {@code filename} and {@code targetDir} configuration parameters.
37 | *
27 | * The {@code filename} property does have a default of ${project.build.finalName}.${project.packaging}.
28 | * The default value is not injected as it normally would be due to packaging types like {@code ejb} that result in
29 | * a file with a {@code .jar} extension rather than an {@code .ejb} extension.
30 | *
31 | */
32 | @Parameter(property = PropertyNames.DEPLOYMENT_FILENAME)
33 | private String filename;
34 |
35 | /**
36 | * By default certain package types are ignored when processing, e.g. {@code maven-project} and {@code pom}. Set
37 | * this value to {@code false} if this check should be bypassed.
38 | */
39 | @Parameter(alias = "check-packaging", property = PropertyNames.CHECK_PACKAGING, defaultValue = "true")
40 | private boolean checkPackaging;
41 |
42 | @Override
43 | protected boolean skipExecution() {
44 | boolean skip = super.skipExecution();
45 | if (!skip) {
46 | final PackageType packageType = PackageType.resolve(project);
47 | if (checkPackaging && packageType.isIgnored()) {
48 | getLog().debug(String.format("Ignoring packaging type %s.", packageType.getPackaging()));
49 | skip = true;
50 | }
51 | }
52 | return skip;
53 | }
54 |
55 | @Override
56 | protected File file() {
57 | final PackageType packageType = PackageType.resolve(project);
58 | final String filename;
59 | if (this.filename == null) {
60 | filename = String.format("%s.%s", project.getBuild().getFinalName(), packageType.getFileExtension());
61 | } else {
62 | filename = this.filename;
63 | }
64 | return new File(targetDir, filename);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/plugin/src/site/markdown/channel-example.md.vm:
--------------------------------------------------------------------------------
1 | # Using Channels
2 |
3 | Channels can be used to provision a ${appServerName} server in goals that allow channels for provisioning. A
4 | [WildFly Channel](https://github.com/wildfly-extras/wildfly-channel/blob/main/doc/spec.adoc) is a YAML file of Maven
5 | GAV's. Channels can be used to provision the latest version of ${appServerName} and/or other components that generate a
6 | channel manifests.
7 |
8 | #[[##]]# Provision the Latest Release
9 |
10 | The example below shows how to provision the latest version of ${appServerName}.
11 |
12 | ```xml
13 |
14 | ${project.groupId}
15 | ${project.artifactId}
16 | ${project.version}
17 |
18 |
19 |
20 | org.wildfly
21 | wildfly-ee-galleon-pack
22 |
23 |
24 |
25 |
26 |
27 | org.wildfly.channels
28 | wildfly-ee
29 |
30 |
31 |
32 |
33 |
34 | ```
35 |
36 | #[[##]]# Provision Additional Channels
37 |
38 | The example below will provision a specific version of ${appServerName} with the latest version of RESTEasy on the
39 | latest ${resteasyChannelStream}.
40 |
41 | ```xml
42 |
43 | ${project.groupId}
44 | ${project.artifactId}
45 | ${project.version}
46 |
47 |
48 |
49 | org.wildfly
50 | wildfly-ee-galleon-pack
51 |
52 |
53 |
54 |
55 |
56 | org.wildfly.channels
57 | wildfly-ee
58 | ${wildflyVersion}
59 |
60 |
61 |
62 |
63 | dev.resteasy.channels
64 | resteasy-${resteasyChannelStream}
65 |
66 |
67 |
68 |
69 |
70 | ```
--------------------------------------------------------------------------------
/tests/domain-tests/src/test/resources/test-project/add-resource-with-composite-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 | full
21 |
22 | subsystem=datasources
23 |
24 |
25 | data-source=java:/ds-name2
26 |
27 | java:jboss/ds-name2
28 | true
29 | jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
30 | org.h2.Driver
31 | h2
32 | sa
33 | sa
34 |
35 |
36 |
37 |
38 | data-source=java:/ds-name3
39 |
40 | java:jboss/ds-name3
41 | true
42 | jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
43 | org.h2.Driver
44 | h2
45 | sa
46 | sa
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/plugin/src/main/java/org/wildfly/plugin/deployment/resource/Resource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | package org.wildfly.plugin.deployment.resource;
7 |
8 | import java.util.Collections;
9 | import java.util.Map;
10 |
11 | import org.apache.maven.plugins.annotations.Parameter;
12 |
13 | /**
14 | * Defines a resource.
15 | *
16 | * @author James R. Perkins
17 | */
18 | public class Resource {
19 |
20 | /**
21 | * The operation address.
22 | */
23 | @Parameter
24 | private String address;
25 |
26 | /**
27 | * Only adds the resource if the resource does not already exist. If the resource already exists, the resource is
28 | * skipped.
29 | */
30 | @Parameter
31 | private boolean addIfAbsent;
32 |
33 | /**
34 | * The operation properties for the resource.
35 | */
36 | @Parameter
37 | private Map properties;
38 |
39 | /**
40 | * An array of resources that rely on this resource.
41 | *
42 | * Note all resources will be ignored if the {@code } is defined and his resource is already defined.
43 | */
44 | @Parameter
45 | private Resource[] resources;
46 |
47 | /**
48 | * Default constructor.
49 | */
50 | public Resource() {
51 |
52 | }
53 |
54 | /**
55 | * The address for the resource.
56 | *
57 | * @return the address.
58 | */
59 | public String getAddress() {
60 | return address;
61 | }
62 |
63 | /**
64 | * Whether or not we should add only if the resource is absent.
65 | *
66 | * @return {@code true} if the resource should only be added if it does not already exist, otherwise {@code false}.
67 | */
68 | public boolean isAddIfAbsent() {
69 | return addIfAbsent;
70 | }
71 |
72 | /**
73 | * The properties for the resource. If no properties were defined an empty map is returned.
74 | *
75 | * @return the properties.
76 | */
77 | public Map getProperties() {
78 | if (properties == null) {
79 | return Collections.emptyMap();
80 | }
81 | return properties;
82 | }
83 |
84 | /**
85 | * Returns an array of resources that depend on this resource.
86 | *
87 | * Note all sub-resources will be ignored if the {@link #isAddIfAbsent()} is defined and his resource is already
88 | * defined.
89 | *
90 | * @return an array of resources that depend on this resource or {@code null} if there are no child resources.
91 | */
92 | public Resource[] getResources() {
93 | return resources;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/package-invalid-deployment-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 |
23 |
24 |
25 | jaxrs-server
26 |
27 |
28 | deployment-scanner
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | /system-property=org.wildfly.maven.plugin-package-goal:add(value=true)
37 |
38 |
39 |
40 | test-foo.war
41 |
42 | extra-content
43 |
44 | true
45 | packaged-invalid-dep-server
46 | true
47 |
48 |
49 | true
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/package-grpc-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
22 |
23 |
24 | org.wildfly.extras.grpc:wildfly-grpc-feature-pack:GRPC_VERSION
25 |
26 |
27 |
28 | jaxrs-server
29 | grpc
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | /system-property=org.wildfly.maven.plugin-package-goal:add(value=true)
38 |
39 |
40 |
41 | test.war
42 |
43 | extra-content
44 |
45 | preview
46 | true
47 | packaged-grpc-server
48 |
49 |
50 | true
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/package-invalid-deployment2-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 | foo
15 |
16 |
17 | org.wildfly.plugins
18 | wildfly-maven-plugin
19 |
20 |
21 |
22 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
23 |
24 |
25 |
26 | jaxrs-server
27 |
28 |
29 | deployment-scanner
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | /system-property=org.wildfly.maven.plugin-package-goal:add(value=true)
38 |
39 |
40 |
41 | test-foo.war
42 |
43 | extra-content
44 |
45 | true
46 | packaged-invalid-dep2-server
47 | true
48 |
49 |
50 | true
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: WildFly Maven Plugin - CI
5 |
6 | on:
7 | push:
8 | branches-ignore:
9 | - 'dependabot/**'
10 | paths:
11 | - '.github/workflows/ci.yml'
12 | - 'core/**'
13 | - 'plugin/**'
14 | - 'tests/**'
15 | - '**/pom.xml'
16 | pull_request:
17 | paths:
18 | - '.github/workflows/ci.yml'
19 | - 'core/**'
20 | - 'plugin/**'
21 | - 'tests/**'
22 | - '**/pom.xml'
23 |
24 | # Only run the latest job
25 | concurrency:
26 | group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
27 | cancel-in-progress: true
28 |
29 |
30 | jobs:
31 |
32 | format-check:
33 | runs-on: ubuntu-latest
34 | timeout-minutes: 30
35 |
36 | steps:
37 | - uses: actions/checkout@v6
38 | - name: Set up JDK 21
39 | uses: actions/setup-java@v5
40 | with:
41 | java-version: 21
42 | distribution: 'temurin'
43 | cache: 'maven'
44 | - name: Validate Formatting
45 | run: |
46 | mvn -B validate -Pformat-check -Denforcer.skip=true
47 |
48 | build:
49 | name: ${{ matrix.os }}-jdk${{ matrix.java }}-${{ matrix.wildfly-version }}
50 | needs: format-check
51 | runs-on: ${{ matrix.os }}
52 | strategy:
53 | fail-fast: false
54 | matrix:
55 | os: [ubuntu-latest, windows-latest ]
56 | java: ['17', '21', '25']
57 |
58 | steps:
59 | - uses: actions/checkout@v6
60 | - name: Set up JDK ${{ matrix.java }}
61 | uses: actions/setup-java@v5
62 | with:
63 | java-version: ${{ matrix.java }}
64 | cache: 'maven'
65 | distribution: 'temurin'
66 | - name: Build and Test on ${{ matrix.java }} - ${{ matrix.wildfly-version }}
67 | run: mvn clean install '-Dorg.jboss.logmanager.nocolor=true'
68 | - name: Upload surefire logs for failed run
69 | uses: actions/upload-artifact@v6
70 | if: failure()
71 | with:
72 | name: surefire-reports-${{ matrix.os }}-${{ matrix.java }}
73 | path: '**/surefire-reports/'
74 | - name: Upload failsafe logs for failed run
75 | uses: actions/upload-artifact@v6
76 | if: failure()
77 | with:
78 | name: failsafe-reports-${{ matrix.os }}-${{ matrix.java }}
79 | path: '**/failsafe-reports/'
80 | - name: Upload logs for failed run
81 | uses: actions/upload-artifact@v6
82 | if: failure()
83 | with:
84 | name: server-logs-${{ matrix.os }}-${{ matrix.java }}
85 | path: '**/*.log'
--------------------------------------------------------------------------------
/core/src/main/java/org/wildfly/plugin/core/MavenProxySelector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | package org.wildfly.plugin.core;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 | import java.util.regex.Pattern;
10 |
11 | import org.eclipse.aether.repository.Proxy;
12 | import org.eclipse.aether.util.repository.AuthenticationBuilder;
13 |
14 | /**
15 | *
16 | * @author jdenise
17 | */
18 | class MavenProxySelector {
19 |
20 | static class Builder {
21 |
22 | private String userName;
23 | private String password;
24 | private final String host;
25 | private final int port;
26 | private final String protocol;
27 | private final List nonProxyHosts = new ArrayList<>();
28 |
29 | Builder(String host, int port, String protocol) {
30 | this.host = host;
31 | this.port = port;
32 | this.protocol = protocol;
33 | }
34 |
35 | Builder setUserName(String userName) {
36 | this.userName = userName;
37 | return this;
38 | }
39 |
40 | Builder setPassword(String password) {
41 | this.password = password;
42 | return this;
43 | }
44 |
45 | Builder addNonProxyHosts(List lst) {
46 | for (String h : lst) {
47 | h = h.replaceAll("\\*", ".*");
48 | nonProxyHosts.add(Pattern.compile(h));
49 | }
50 | return this;
51 | }
52 |
53 | MavenProxySelector build() {
54 | return new MavenProxySelector(host, port, protocol, userName,
55 | password, nonProxyHosts);
56 | }
57 | }
58 |
59 | private final List nonProxyHosts;
60 | private final Proxy proxy;
61 |
62 | MavenProxySelector(String host, int port, String protocol, String userName,
63 | String password, List nonProxyHosts) {
64 | this.nonProxyHosts = nonProxyHosts;
65 | if (userName != null && password != null) {
66 | AuthenticationBuilder builder = new AuthenticationBuilder();
67 | builder.addPassword(password);
68 | builder.addUsername(userName);
69 | proxy = new Proxy(protocol, host, port, builder.build());
70 | } else {
71 | proxy = new Proxy(protocol, host, port);
72 | }
73 | }
74 |
75 | public Proxy getProxy(String host) {
76 | return proxyFor(host) ? proxy : null;
77 | }
78 |
79 | private boolean proxyFor(String host) {
80 | boolean match = false;
81 | for (Pattern p : nonProxyHosts) {
82 | if (p.matcher(host).matches()) {
83 | match = true;
84 | break;
85 | }
86 | }
87 | return !match;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/package-no-multiple-deployments-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 | testing
15 | dummy
16 | 1.0
17 | system
18 | ${basedir}/dummy.jar
19 |
20 |
21 | testing
22 | dummy-test
23 | 1.0
24 | system
25 | ${basedir}/dummy-test.jar
26 |
27 |
28 | testing
29 | dummy-test-common
30 | 1.0
31 | system
32 | ${basedir}/dummy-test-common.jar
33 |
34 |
35 | org.junit.jupiter
36 | junit-jupiter
37 | 5.11.3
38 | test
39 |
40 |
41 |
42 |
43 |
44 | org.wildfly.plugins
45 | wildfly-maven-plugin
46 |
47 | test.war
48 | true
49 | packaged-no-multiple-deployments-server
50 |
51 |
52 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
53 |
54 |
55 |
56 | jaxrs-server
57 |
58 |
59 |
60 | true
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/plugin/src/main/java/org/wildfly/plugin/cli/ScriptWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | package org.wildfly.plugin.cli;
7 |
8 | import java.io.BufferedWriter;
9 | import java.io.IOException;
10 | import java.nio.charset.StandardCharsets;
11 | import java.nio.file.Files;
12 | import java.nio.file.Path;
13 |
14 | /**
15 | * @author James R. Perkins
16 | */
17 | class ScriptWriter {
18 |
19 | /**
20 | * Creates a script file for the commands. If {@code failOnError} is {@code false} the command will be wrapped in a
21 | * {@code try-catch} command.
22 | *
23 | * @param config the command configuration being used
24 | *
25 | * @return the script file
26 | *
27 | * @throws IOException if an error occurs creating the script file
28 | */
29 | static Path create(final BaseCommandConfiguration config) throws IOException {
30 | final Path tempScript = Files.createTempFile("cli-scrpts", ".cli");
31 | try (BufferedWriter writer = Files.newBufferedWriter(tempScript, StandardCharsets.UTF_8)) {
32 | if (config.isBatch()) {
33 | writer.write("batch");
34 | writer.newLine();
35 | }
36 |
37 | boolean inTry = false;
38 |
39 | for (String cmd : config.getCommands()) {
40 | if (cmd == null || cmd.isEmpty()) {
41 | continue;
42 | }
43 | if (config.isFailOnError()) {
44 | writeCommand(writer, cmd);
45 | } else {
46 | if ("try".equals(cmd.trim())) {
47 | inTry = true;
48 | }
49 | if (inTry) {
50 | writeCommand(writer, cmd);
51 | } else {
52 | writeCommandInTry(writer, cmd);
53 | }
54 | if ("end-try".equals(cmd.trim())) {
55 | inTry = false;
56 | }
57 | }
58 | }
59 |
60 | if (config.isBatch()) {
61 | writer.write("run-batch");
62 | writer.newLine();
63 | }
64 | }
65 | return tempScript;
66 | }
67 |
68 | private static void writeCommand(final BufferedWriter writer, final String cmd) throws IOException {
69 | writer.write(cmd);
70 | writer.newLine();
71 | }
72 |
73 | private static void writeCommandInTry(final BufferedWriter writer, final String cmd) throws IOException {
74 | writer.write("try");
75 | writer.newLine();
76 | writeCommand(writer, cmd);
77 | writer.write("catch");
78 | writer.newLine();
79 | writer.write("echo Failed to execute command: \"");
80 | writer.write(cmd);
81 | writer.write('"');
82 | writer.newLine();
83 | writer.write("end-try");
84 | writer.newLine();
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/package-channel-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 |
15 |
16 | org.wildfly.plugins
17 | wildfly-maven-plugin
18 |
19 |
20 |
21 |
22 | org.wildfly.channels
23 | wildfly
24 | WF_VERSION
25 |
26 |
27 |
28 |
29 |
30 | org.wildfly:wildfly-galleon-pack:WF_VERSION
31 |
32 |
33 |
34 | jaxrs-server
35 |
36 |
37 | deployment-scanner
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | /system-property=org.wildfly.maven.plugin-package-goal:add(value=true)
46 |
47 |
48 |
49 | test.war
50 |
51 | extra-content
52 |
53 | true
54 | packaged-channel-server
55 |
56 |
57 | true
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/resources/test-project/package-multiple-deployments-pom.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
8 | 4.0.0
9 | testing
10 | testing
11 | 0.1.0-SNAPSHOT
12 |
13 |
14 | testing
15 | dummy
16 | 1.0
17 | system
18 | ${basedir}/dummy.jar
19 |
20 |
21 | testing
22 | dummy-test
23 | 1.0
24 | system
25 | ${basedir}/dummy-test.jar
26 |
27 |
28 | testing
29 | dummy-test-common
30 | 1.0
31 | system
32 | ${basedir}/dummy-test-common.jar
33 |
34 |
35 | org.junit.jupiter
36 | junit-jupiter
37 | 5.11.3
38 | test
39 |
40 |
41 |
42 |
43 |
44 | org.wildfly.plugins
45 | wildfly-maven-plugin
46 |
47 | test.war
48 | true
49 | packaged-multiple-deployments-server
50 |
51 | !testing:*test*
52 | ::jar
53 |
54 | test
55 |
56 |
57 | wildfly@maven(org.jboss.universe:community-universe)#WF_VERSION
58 |
59 |
60 |
61 | jaxrs-server
62 |
63 |
64 |
65 | true
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/CONTRIBUTING.adoc:
--------------------------------------------------------------------------------
1 | :toc:
2 |
3 | = Contributing Guide
4 |
5 | Want to contribute to the WildFly Maven Plugin? We try to make it easy, and all contributions, even the smaller ones,
6 | are more than welcome. This includes bug reports, fixes, documentation, etc. First though, please read this page
7 | (including the small print at the end).
8 |
9 | == Legal
10 |
11 | All original contributions to the WildFly Maven Plugin are licensed under the
12 | https://www.apache.org/licenses/LICENSE-2.0[ASL - Apache License], version 2.0 or later, or, if another license is
13 | specified as governing the file or directory being modified, such other license.
14 |
15 | All contributions are subject to the https://developercertificate.org/[Developer Certificate of Origin (DCO)].
16 | The DCO text is also included verbatim in the [dco.txt](dco.txt) file in the root directory of the repository.
17 |
18 | == Reporting an issue
19 |
20 | This project uses https://issues.redhat.com/browse/WFMP[JIRA] for filing issues. An account is required, However,
21 | if you do not wish to signup for an account, you can open a
22 | https://github.com/wildfly/wildfly-maven-plugin/discussions[discussion] and we will assist you in filing an issue.
23 |
24 | If you believe you found a bug, and it's likely possible, please indicate a way to reproduce it, what you are seeing and
25 | what you would expect to see.
26 |
27 | == Before you contribute
28 |
29 | To contribute, use GitHub Pull Requests, from your **own** fork.
30 |
31 | Also, make sure you have set up your Git authorship correctly:
32 |
33 | ----
34 | git config --global user.name "Your Full Name"
35 | git config --global user.email your.email@example.com
36 | ----
37 |
38 | If you use different computers to contribute, please make sure the name is the same on all your computers.
39 |
40 | We use this information to acknowledge your contributions in release announcements.
41 |
42 | == Setup
43 |
44 | If you have not done so on this machine, you need to:
45 |
46 | * Install Git and configure your GitHub access
47 | * Install Java SDK 17+ (OpenJDK recommended)
48 |
49 | === IDE Config and Code Style
50 |
51 | The WildFly Maven Plugin has a strictly enforced code style. Code formatting is done by the Eclipse code formatter,
52 | using the config files found in the
53 | https://github.com/wildfly/wildfly-dev-tools/tree/main/ide-config/src/main/resources[eclipse-code-formatter.xml]
54 | file. By default, when you run `./mvnw install`, the code will be formatted automatically. When submitting a pull
55 | request the CI build will fail if running the formatter results in any code changes, so it is recommended that you
56 | always run a full Maven build before submitting a pull request.
57 |
58 | If you want to run the formatting without doing a full build, you can run `mvn process-sources`.
59 |
60 | ==== Eclipse Setup
61 |
62 | Open the *Preferences* window, and then navigate to _Java_ -> _Code Style_ -> _Formatter_. Click _Import_ and then
63 | select the `eclipse-code-formatter.xml` downloaded from the above link or clone the repository and navigate to the file.
64 |
65 | Next navigate to _Java_ -> _Code Style_ -> _Organize Imports_. Click _Import_ and select the `eclipse.importorder` file.
66 |
67 | ==== IDEA Setup
68 |
69 | Install the https://plugins.jetbrains.com/plugin/6546-adapter-for-eclipse-code-formatter/[Adapter for Eclipse Code Formatter].
70 | See the https://github.com/krasa/EclipseCodeFormatter#instructions[documentation] on how to configure the plugin.
--------------------------------------------------------------------------------
/plugin/src/main/java/org/wildfly/plugin/cli/CliSession.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | package org.wildfly.plugin.cli;
6 |
7 | import java.io.File;
8 | import java.util.ArrayList;
9 | import java.util.Collections;
10 | import java.util.List;
11 |
12 | /**
13 | * A CLI execution.
14 | *
15 | * @author jdenise
16 | */
17 | public class CliSession {
18 |
19 | private List scripts = Collections.emptyList();
20 | private List propertiesFiles = Collections.emptyList();
21 | private String[] javaOpts = {};
22 | boolean resolveExpressions = false;
23 | private List commands = new ArrayList<>();
24 |
25 | /**
26 | * Set the list of CLI commands to execute.
27 | *
28 | * @param commands List of script CLI commands
29 | */
30 | public void setCommands(List commands) {
31 | this.commands = commands;
32 | }
33 |
34 | /**
35 | * Get the list of CLI commands to execute.
36 | *
37 | * @return The list of CLI commands.
38 | */
39 | public List getCommands() {
40 | return commands;
41 | }
42 |
43 | /**
44 | * Set the list of JVM options to pass to CLI process.
45 | *
46 | * @param javaOpts List of JVM Options.
47 | */
48 | public void setJavaOpts(String[] javaOpts) {
49 | this.javaOpts = javaOpts;
50 | }
51 |
52 | /**
53 | * Get the list of JVM options to pass to CLI process.
54 | *
55 | * @return The list of Java Options
56 | */
57 | public String[] getJavaOpts() {
58 | return javaOpts;
59 | }
60 |
61 | /**
62 | * Set the list of CLI script files to execute.
63 | *
64 | * @param scripts List of script file paths.
65 | */
66 | public void setScripts(List scripts) {
67 | this.scripts = scripts;
68 | }
69 |
70 | /**
71 | * Get the list of CLI script files to execute.
72 | *
73 | * @return The list of file paths.
74 | */
75 | public List getScripts() {
76 | return scripts;
77 | }
78 |
79 | /**
80 | * Set the properties files used when executing the CLI.
81 | *
82 | * @param propertiesFiles List of Path to properties file.
83 | */
84 | public void setPropertiesFiles(List propertiesFiles) {
85 | this.propertiesFiles = propertiesFiles;
86 | }
87 |
88 | /**
89 | * Get the properties files used when executing the CLI.
90 | *
91 | * @return The properties file path.
92 | */
93 | public List getPropertiesFiles() {
94 | return propertiesFiles;
95 | }
96 |
97 | /**
98 | * By default, the CLI doesn't resolve expressions located in scripts locally. In order to have the expressions
99 | * resolved locally, set this value to true.
100 | *
101 | * @param resolveExpressions True to resolve locally, false to resolve at server execution time.
102 | */
103 | public void setResolveExpressions(boolean resolveExpressions) {
104 | this.resolveExpressions = resolveExpressions;
105 | }
106 |
107 | /**
108 | * Get the expression resolution value.
109 | *
110 | * @return The expression resolution value.
111 | */
112 | public boolean getResolveExpression() {
113 | return resolveExpressions;
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/plugin/src/site/site.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 | com.bernardomg.maven.skins
11 | docs-maven-skin
12 | ${version.com.bernardomg.maven.skins}
13 |
14 |
15 |
16 |
17 | WildFly Maven Plugin
18 | @WildFlyAS
19 | ./css/custom.css
20 | slate
21 | bg-primary
22 | rainbow
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
39 |
40 |
52 |
53 |
58 |
59 |
63 |
64 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/tests/shared/src/main/java/org/wildfly/plugin/tests/runner/WildFlyTestRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | package org.wildfly.plugin.tests.runner;
7 |
8 | import java.lang.reflect.Field;
9 | import java.lang.reflect.Modifier;
10 | import java.util.ServiceLoader;
11 |
12 | import javax.inject.Inject;
13 |
14 | import org.jboss.as.controller.client.ModelControllerClient;
15 | import org.junit.runner.Result;
16 | import org.junit.runner.notification.RunListener;
17 | import org.junit.runner.notification.RunNotifier;
18 | import org.junit.runners.BlockJUnit4ClassRunner;
19 | import org.junit.runners.model.InitializationError;
20 | import org.wildfly.plugin.server.TestServer;
21 | import org.wildfly.plugin.tools.DeploymentManager;
22 |
23 | /**
24 | * @author James R. Perkins
25 | */
26 | public class WildFlyTestRunner extends BlockJUnit4ClassRunner {
27 | private static final TestServer server;
28 |
29 | static {
30 | final ServiceLoader loader = ServiceLoader.load(TestServer.class);
31 | if (loader.iterator().hasNext()) {
32 | server = loader.iterator().next();
33 | } else {
34 | throw new RuntimeException("No server implementation found");
35 | }
36 | }
37 |
38 | /**
39 | * Creates a BlockJUnit4ClassRunner to run {@code clazz}
40 | *
41 | * @throws org.junit.runners.model.InitializationError if the test class is malformed.
42 | */
43 | public WildFlyTestRunner(Class> clazz) throws InitializationError {
44 | super(clazz);
45 |
46 | }
47 |
48 | @Override
49 | protected Object createTest() throws Exception {
50 | Object res = super.createTest();
51 | doInject(getTestClass().getJavaClass(), res);
52 | return res;
53 | }
54 |
55 | @Override
56 | public void run(final RunNotifier notifier) {
57 | notifier.addListener(new RunListener() {
58 | @Override
59 | public void testRunFinished(Result result) throws Exception {
60 | super.testRunFinished(result);
61 | server.stop();
62 | }
63 | });
64 | server.start();
65 | super.run(notifier);
66 | }
67 |
68 | private void doInject(final Class> clazz, final Object instance) {
69 | Class> c = clazz;
70 | try {
71 | while (c != null && c != Object.class) {
72 | for (Field field : c.getDeclaredFields()) {
73 | if (instance != null && !Modifier.isStatic(field.getModifiers())) {
74 | if (field.isAnnotationPresent(Inject.class)) {
75 | field.setAccessible(true);
76 | if (field.getType() == ModelControllerClient.class) {
77 | field.set(instance, server.getClient());
78 | } else if (TestServer.class.isAssignableFrom(field.getType())) {
79 | field.set(instance, server);
80 | } else if (DeploymentManager.class.isAssignableFrom(field.getType())) {
81 | field.set(instance, server.getDeploymentManager());
82 | }
83 | }
84 | }
85 | }
86 | c = c.getSuperclass();
87 | }
88 | } catch (Exception e) {
89 | throw new RuntimeException("Failed to inject", e);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/tests/standalone-tests/src/test/java/org/wildfly/plugin/provision/ImageTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | package org.wildfly.plugin.provision;
6 |
7 | import static org.wildfly.plugin.provision.ExecUtil.execSilentWithTimeout;
8 | import static org.wildfly.plugin.tests.AbstractWildFlyMojoTest.getPomFile;
9 |
10 | import java.io.ByteArrayOutputStream;
11 | import java.nio.file.Files;
12 | import java.nio.file.Path;
13 | import java.time.Duration;
14 | import java.util.List;
15 |
16 | import org.apache.maven.plugin.Mojo;
17 | import org.apache.maven.plugin.MojoExecutionException;
18 | import org.junit.Assume;
19 | import org.junit.Test;
20 | import org.junit.experimental.categories.Category;
21 | import org.wildfly.plugin.categories.ChannelsRequired;
22 | import org.wildfly.plugin.tests.AbstractWildFlyMojoTest;
23 | import org.wildfly.plugin.tests.TestEnvironment;
24 |
25 | @Category(ChannelsRequired.class)
26 | public class ImageTest extends AbstractImageTest {
27 |
28 | @Test
29 | public void testBuildImage() throws Exception {
30 | Assume.assumeFalse("This test is flaky on Windows, ignore it on Windows.", TestEnvironment.isWindows());
31 | final String binary = ExecUtil.resolveImageBinary();
32 | try {
33 | assertTrue(
34 | execSilentWithTimeout(Duration.ofMillis(3000),
35 | binary, "-v"));
36 | assertFalse(
37 | exec(binary, "inspect", "wildfly-maven-plugin/testing"));
38 |
39 | final Mojo imageMojo = lookupConfiguredMojo(getPomFile("image-pom.xml").toFile(), "image");
40 |
41 | imageMojo.execute();
42 | Path jbossHome = AbstractWildFlyMojoTest.getBaseDir().resolve("target").resolve("image-server");
43 | assertTrue(jbossHome.toFile().exists());
44 | Path dockerFile = AbstractWildFlyMojoTest.getBaseDir().resolve("target").resolve("Dockerfile");
45 | assertTrue(dockerFile.toFile().exists());
46 | List dockerfileLines = Files.readAllLines(dockerFile);
47 | assertLineContains(dockerfileLines, 1, "LABEL description=\"This text illustrates \\");
48 | assertLineContains(dockerfileLines, 2, "that label-values can span multiple lines.\"");
49 | assertLineContains(dockerfileLines, 3, "LABEL quoted.line=\"I have \\\"quoted myself\\\" here.\"");
50 | assertLineContains(dockerfileLines, 4, "LABEL version=\"1.0\"");
51 | final ByteArrayOutputStream stdout = new ByteArrayOutputStream();
52 | assertTrue(ExecUtil.exec(stdout, binary, "inspect", "wildfly-maven-plugin/testing"));
53 | assertEnvironmentUnset(stdout, "SERVER_ARGS=-c=");
54 | } finally {
55 |
56 | exec(binary, "rmi", "wildfly-maven-plugin/testing");
57 | }
58 | }
59 |
60 | @Test(expected = MojoExecutionException.class)
61 | public void testBuildImageWithUnknownDockerBinary() throws Exception {
62 | final Mojo imageMojo = lookupConfiguredMojo(
63 | getPomFile("image-unknown-docker-binary-pom.xml").toFile(), "image");
64 | imageMojo.execute();
65 | }
66 |
67 | private static void assertLineContains(final List dockerfileLines, final int index, final String expected) {
68 | assertEquals(
69 | String.format("Expected Dockerfile to contain %s at line %d%n%s", expected, index,
70 | String.join(System.lineSeparator(), dockerfileLines)),
71 | expected, dockerfileLines.get(index));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/plugin/src/main/java/org/wildfly/plugin/deployment/DeployArtifactMojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The WildFly Authors
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 |
6 | package org.wildfly.plugin.deployment;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 | import java.util.Objects;
11 | import java.util.Set;
12 |
13 | import org.apache.maven.artifact.Artifact;
14 | import org.apache.maven.plugins.annotations.Mojo;
15 | import org.apache.maven.plugins.annotations.Parameter;
16 | import org.apache.maven.plugins.annotations.ResolutionScope;
17 | import org.wildfly.plugin.common.PropertyNames;
18 | import org.wildfly.plugin.tools.Deployment;
19 | import org.wildfly.plugin.tools.DeploymentManager;
20 | import org.wildfly.plugin.tools.DeploymentResult;
21 |
22 | /**
23 | * Deploys an arbitrary artifact to the WildFly application server
24 | *
25 | * @author Stuart Douglas
26 | */
27 | @Mojo(name = "deploy-artifact", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
28 | public class DeployArtifactMojo extends AbstractDeployment {
29 |
30 | /**
31 | * The artifact to deploys groupId
32 | */
33 | @Parameter
34 | private String groupId;
35 |
36 | /**
37 | * The artifact to deploys artifactId
38 | */
39 | @Parameter
40 | private String artifactId;
41 |
42 | /**
43 | * The artifact to deploys classifier. Note that the classifier must also be set on the dependency being deployed.
44 | */
45 | @Parameter
46 | private String classifier;
47 |
48 | /**
49 | * Specifies whether force mode should be used or not.
50 | *
51 | * If force mode is disabled, the deploy goal will cause a build failure if the application being deployed already
52 | * exists.
53 | */
54 | @Parameter(defaultValue = "true", property = PropertyNames.DEPLOY_FORCE)
55 | private boolean force;
56 |
57 | /**
58 | * The resolved dependency file
59 | */
60 | private File file;
61 |
62 | @Override
63 | public void validate(final boolean isDomain) throws MojoDeploymentException {
64 | super.validate(isDomain);
65 | if (artifactId == null) {
66 | throw new MojoDeploymentException("deploy-artifact must specify the artifactId");
67 | }
68 | if (groupId == null) {
69 | throw new MojoDeploymentException("deploy-artifact must specify the groupId");
70 | }
71 | final Set dependencies = project.getArtifacts();
72 | Artifact artifact = null;
73 | for (final Artifact a : dependencies) {
74 | if (Objects.equals(a.getArtifactId(), artifactId) &&
75 | Objects.equals(a.getGroupId(), groupId) &&
76 | Objects.equals(a.getClassifier(), classifier)) {
77 | artifact = a;
78 | break;
79 | }
80 | }
81 | if (artifact == null) {
82 | throw new MojoDeploymentException("Could not resolve artifact to deploy " + groupId + ":" + artifactId);
83 | }
84 | file = artifact.getFile();
85 | }
86 |
87 | @Override
88 | protected File file() {
89 | return file;
90 | }
91 |
92 | @Override
93 | public String goal() {
94 | return "deploy-artifact";
95 | }
96 |
97 | @Override
98 | protected DeploymentResult executeDeployment(final DeploymentManager deploymentManager, final Deployment deployment)
99 | throws IOException {
100 | if (force) {
101 | return deploymentManager.forceDeploy(deployment);
102 | }
103 | return deploymentManager.deploy(deployment);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------