Do you want to learn how to create a basic Maven archetype for setting up quickly a WildFly project? then keep reading!

Basically a Maven archetype is made up of the following elements:

  • An archetype descriptor (archetype-metadata.xml in directory: src/main/resources/META-INF/maven/). It lists all the files that will be contained in the archetype and categorizes them so they can be processed correctly by the archetype generation mechanism..
  • The prototype files which are copied by the archetype plugin (directory: src/main/resources/archetype-resources/).
  • The prototype pom (pom.xml in: src/main/resources/archetype-resources).
  • The pom for the archetype (pom.xml in the archetype's root directory).

The good news is that you don't need to create this structure by yourself. You can create it from an archetype follow as follows:

mvn -B archetype:generate -DarchetypeArtifactId=maven-archetype-archetype \
  -DarchetypeGroupId=maven-archetype \ -DgroupId=com.mastertheboss -DartifactId=wildfly-archetype

The following structure will be generated:

├── pom.xml
└── src
    ├── main
    │   └── resources
    │       ├── archetype-resources
    │       │   ├── pom.xml
    │       │   └── src
    │       │       ├── main
    │       │       │   └── java
    │       │       │       └──
    │       │       └── test
    │       │           └── java
    │       │               └──
    │       └── META-INF
    │           └── maven
    │               └── archetype-metadata.xml
    └── test
        └── resources
            └── projects
                └── it-basic
                    └── goal.txt

First off, let's remove the and which are not required in our WildFly project. Then, let's define the pom for the archetype (top's pom.xml):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
    <description>Archetype used to generate rest application based on jaxrs 2.1</description>




Next, the prototype pom which contains the actual WildFly's dependencies:

<project xmlns="" xmlns:xsi=""







Within the archetype-metadata.xml define which files will be include in the project. In our case the example Java files:


        <requiredProperty key="version-wildfly">

        <fileSet filtered="true" packaged="true">



Here are a few important tags and their purpose:

  • Required Property can be used to define properties that can be injected in the prototype pom. In our case "wildfly-version" will be prompted if running in interactive mode.
  • FileSet defines how to use the project files located in the jar file to generate a project. If a file or a directory name contains __property__ pattern, it is replaced with corresponding property value
  • packaged = “true” means that the selected files will be generated in a directory structure that is prepended by the package property

Finally, let's add the Java class files, which are added in src/main/resources/archetype-resources/src/main/java. Here is

package ${package};


public class AppConfig extends Application {

And here is the file:

package ${package};

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;

public class HelloREST {

    public Response hello(){

        return Response
                .ok( "Hello World")


This is the final structure of your Archetype project:

└── main
    └── resources
        ├── archetype-resources
        │   ├── pom.xml
        │   └── src
        │       └── main
        │           └── java
        │               ├──
        │               └──
        ├── logback.xml
        └── META-INF
            └── maven
                └── archetype-metadata.xml

You need to install the archetype on your local repository with:

$ mvn clean install

Using the archetype to create a WildFly project

In order to use our archetype, we will refer to the com.mastertheboss.archetypes we have just installed, adding the required GAV information:

mvn archetype:generate -DarchetypeGroupId=com.mastertheboss.archetypes  -DarchetypeArtifactId=maven-archetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.example -DartifactId=demo-rest -Dversion=1.0-SNAPSHOT

You will be then prompted for the wildfly-version:

[INFO] Using property: groupId = com.example
[INFO] Using property: artifactId = demo-rest
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = com.example
[INFO] Using property: version-wildfly = 17.0.0.Final
Confirm properties configuration:
groupId: com.example
artifactId: demo-rest
version: 1.0-SNAPSHOT
package: com.example
version-wildfly: 17.0.0.Final
 Y: : Y

And finally your project will be generated. Here's the directory structure of it:

├── pom.xml
└── src
    └── main
        └── java
            └── com
                └── example

Build and install it with:

$ mvn clean install wildfly:deploy

Test it with:

curl http://localhost:8080/demo-rest/rest/hello
Hello World


We have just described how to create a Java Enterprise project using WildFly dependencies from a Maven archetype.

You can find the source code for it here:


Related articles available on