Search code examples
mavenpluginscommand-line-interfacewildflyarchive

Can CLI archives be deployed on WildFly using Maven plugin?


How do I a deploy CLI archive (zipped) in WildFly (8-10) using wildfly-maven-plugin?

I've created a simple example: A Maven project with a archive.cli file. This archive will deploy a PostgreSQL jdbc driver.

If I deploy it using jboss-cli.sh/bat, it works just as expected: The PostgreSQL driver will appear as an deployment.

Try:

deploy src/main/archive.cli

If I deploy it using maven-wildfly-plugin, WildFly will deploy the file but won't unzip/expand it - I've have a useless archive.cli file as a deployment, but no driver installed. Why?

Try:

mvn validate

My pom.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <name>deploy-archive-cli</name>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.foo</groupId>
    <artifactId>deploy-archive-cli</artifactId>
    <version>1</version>
    <packaging>pom</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.2.1.Final</version> 
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <configuration>
                            <filename>archive.cli</filename>
                            <targetDir>src/main/</targetDir>
                            <skip>false</skip>
                            <checkPackaging>false</checkPackaging>
                        </configuration>
                    </execution>                
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Project strukture looks like this:

.
├── pom.xml
└── src
    └── main
        ├── archive
        │   ├── deploy.scr
        │   ├── postgresql-42.2.1.jar
        │   └── undeploy.scr
        └── archive.cli

Java8. I've tried using deploy-artifact, Win/Linux, WildFly 8-10... Can I configure wildfly-maven-plugin and tell it to expand the artifact? An example would be appreciated.

I understand alternatives are to deploy EAR/WAR/JAR artifacts using Maven, or running jboss-cli, but this is how one IT department would like to handle it. It should be possible, huh?

The simple example Maven project can be downloaded here

thanks,

Jens


Solution

  • I believe that CLI deployments are part of CLI and not processed by normal deployment operations. However in the maven plugin you can execute CLI commands.

    For your example the pom configuration would look something like the following.

    <plugin>
        <groupId>org.wildfly.plugins</groupId>
        <artifactId>wildfly-maven-plugin</artifactId>
        <version>1.2.1.Final</version> 
        <executions>
            <execution>
                <phase>validate</phase>
                <goals>
                    <goal>execute-commands</goal>
                </goals>
                <configuration>
                    <commands>
                        <command>deploy --path=${project.basedir}/src/main/archive.cli</command> 
                    </commands>
                </configuration>
            </execution>                
        </executions>
    </plugin>
    

    One thing to note is while testing this I discovered WFMP-94. If you're using Java 1.8.0_161 you may run into this error. It worked fine for me on the Oracle JDK 1.8.0_151 however.