deploymentmaven-3glassfish-2.xmaven-glassfish-plugin

Maven-glassfish-plugin: how to specify deploy target?


I'm using Maven 3.0.4 with maven-glassfish-plugin 2.1 (http://maven-glassfish-plugin.java.net/) and Glassfish 2.1.1.

Relevant POM.XML fragment:

<profile>
        <id>deploy</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.glassfish.maven.plugin</groupId>
                    <artifactId>maven-glassfish-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <glassfishDirectory>/home/user/glassfish</glassfishDirectory>
                        <domain>
                            <name>domain1</name>
                            <host>hostname</host>
                            <adminPort>4848</adminPort>
                        </domain>
                        <autoCreate>false</autoCreate>
                        <terse>true</terse>
                        <debug>false</debug>
                        <echo>true</echo>
                        <user>admin</user>
                        <passwordFile>/home/user/user.gfpass</passwordFile>
                        <components>
                            <component>
                                <name>${project.artifactId}</name>
                                <artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
                            </component>
                        </components>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

The problem is, the Glassfish server I'm deploying onto has one stand-alone instance per developer configured, and running mvn glassfish:deploy causes:

[INFO] --- maven-glassfish-plugin:2.1:deploy (default-cli) @ project ---
[INFO] deploy --port 4848 --enabled=true --host hostanme --precompilejsp=false --verify=false --echo=true --upload=true --terse=true --generatermistubs=false --passwordfile /home/user/user.gfpass --interactive=false --availabilityenabled=false --name project --target server --force=true --user admin /home/user/git/project/target/project-1.0.0-SNAPSHOT.war
[ERROR] CLI171 Command deploy failed : Application project is already deployed on other targets. Please remove all references or specify all targets (if not using asadmin command line) before attempting redeploy operation
[ERROR] Deployment of /home/user/git/project/target/project-1.0.0-SNAPSHOT.war failed.

Note --target server in the executed command.

How can I specify in POM which instance (i.e. target) I want to deploy to?


Solution

  • After some more research, the answer is NO, I CANNOT.

    There are two options I'm aware of:

    1. Use exec-maven-plugin to call asadmin with desired parameters, or
    2. Fork your own version of maven-glassfish-plugin with changes required (that's what I've done as for now).

    As it turns out, the plugin is very simple, and I've no problem to modify it to suit my needs. More troublesome was building it, but that's another story.