Question

Short version:

I would like the maven-glassfish-plugin to only be executed in the root project in a hierarchical (inheritance based) maven multiproject setup.

Long version:

Following setup:

project-root
|
+-pom.xml
|
+ ear-module
|  |
|  +-pom.xml
|
+ jar-module
   |
   +-pom.xml

All submodules are included in the root project via <modules>...</modules> and all submodules inherit the root project pom.xml. In my root project pom I include the maven-glassfish-plugin:

...
<plugin>
    <groupId>org.glassfish.maven.plugin</groupId>
    <artifactId>maven-glassfish-plugin</artifactId>
    <version>2.1</version>
    <inherited>false</inherited>
    <configuration>
            <glassfishDirectory>${glassfish.home}</glassfishDirectory>
            <passwordFile>${glassfish.home}/masterpassword.txt</passwordFile>
            <domain>
                    <name>${project.name}</name>
                    <adminPort>4848</adminPort>
                    <httpPort>8080</httpPort>
                    <httpsPort>8443</httpsPort>
                    <iiopPort>3700</iiopPort>
                    <jmsPort>7676</jmsPort>
            </domain>
            <components>
                    <component>
                    <name>poc.vermittler</name>
                    <artifact>${project.basedir}/ear-module/target/ear-project-1.0-SNAPSHOT.ear</artifact>
                    </component>
    </configuration>
</plugin>
...

(Note: This is just an simplified version of my pom. It may not run :)

I want to only deploy the ear-module module to glassfish, this is why I added <inherited>false</inherited> section, and depict the modules to be deployed as <components>...</components> in the root pom.

Now the command:

mvn glassfish:deploy

Will deploy the ear to glassfish, all well so far... but then maven will decent recursively to all submodules, which will all fail with:

No plugin found for prefix 'glassfish' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories

I could tell maven to only run the root project with the -pl option but for my gusto, deploying shouldn't rely on such additional information.

Thanks a lot for your help!

Was it helpful?

Solution

It seems that there is no good solution to this problem:

  • either the plugin supports a "NOP"/silent discard functionality
  • or it will fail in all subprojects

Another method could be to create a new subproject (which is not included in the root project by <modules>...</modules> but inherits from the root project) and add dependencies to only the projects that have a deployment artifact.

The plugin can now be included in this subproject without it wanting to run any subproject.

Or for anybody who is lazy: mvn clean package glassfish:redeploy -pl . to selectively only run the root project without descending into child projects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top