Using cargo maven plugin to start the server without artifact deployment

1.4k Views Asked by At

I'm trying to use the cargo maven plugin just to start a JBoss AS 7 server from maven, without executing any deployments.

I'm able to start the server but as I can read in cargo pluging documentation the goals cargo:run and cargo:start will deploy automatically the current project if project's packaging is Java EE (WAR, EAR, etc.) and if I'm not using deployable sections in the plugin configuration.

This is my simple cargo plugin section in the pom file:

<plugins>
    ...
    <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <version>1.4.13</version>
        <configuration>

            <!-- Container configuration -->
            <container>
                <containerId>jboss73x</containerId>
                <home>${jboss-as.home}</home>
            </container>

        </configuration>
    </plugin>
    ...
</plugins>

Since I'm not using deployables and the project packaging is war, cargo automatically deploys my project when the server starts.

I would like use the goal cargo:run just to start my local server without deploy any project artifacts.

Is it possible with the cargo maven plugin? Any idea or alternative?

2

There are 2 best solutions below

0
On

Yes Yersan, it is possible to start the server without self built artifact deployment. It can be achieved by adding an empty <deployer /> element on the <configuration> tag of the project.

I found the info at the cargo plugin reference site. In addition, I have tested the configuration in my local project to confirm it works.

0
On

I think that it might not be possible to ask the plugin not to deploy the project in which it is configured, when you are in the case of a deployable archive project.

But what you could do is creating a pom project, with no source in it just the pom.xml, and run your cargo plugin in that project.

My example below starts and stops the cargo plugin when I run the goal install on it :

<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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>fr.fabien.perso</groupId>
    <artifactId>pom-project-tests</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <executions>
                    <execution>
                        <id>start-container</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-container</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <container>
                        <type>embedded</type>
                    </container>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>