Execute Commands Examples

The execute-commands goal allows you to execute commands, in the CLI format, on the running WildFly.

Execute commands

The example below shows how to add a debug logger with a debug log file:

<project>
    ...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.2.1.Final</version>
                <configuration>
                    <commands>
                        <command>/subsystem=logging/file-handler=debug:add(level=DEBUG,autoflush=true,file={"relative-to"=>"jboss.server.log.dir", "path"=>"debug.log"})</command>
                        <command>/subsystem=logging/logger=org.jboss.as:add(level=DEBUG,handlers=[debug])</command>
                    </commands>
                </configuration>
            </plugin>
            ...
        </plugins>
        ...
    </build>
...
</project>

Execute commands from CLI scripts

The example below shows how to execute commands from a CLI script:

<project>
    ...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.2.1.Final</version>
                <configuration>
                    <scripts>
                        <script>config.cli</script>
                    </scripts>
                </configuration>
            </plugin>
            ...
        </plugins>
        ...
    </build>
...
</project>

Example of a CLI script to set the transaction timeout to 600 seconds.

batch
# set default transaction timeout
/subsystem=transactions :write-attribute(name=default-timeout, value=600)
#...
# Execute and reload
run-batch
:reload