Maven maven-glassfish-plugin in a multiproject setup



简短版本

我希望maven-glassfish-plugin仅在分层(基于继承的)maven 多项目设置中的根项目中执行。

长版本

以下设置:

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

所有子模块都通过<modules>...</modules>包含在根项目中,所有子模块都继承根项目 pom.xml。在我的根项目 pom 中,我包括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>
...

注意:这只是我的pom的简化版本。它可能无法运行:)

我只想将ear-module模块部署到 glassfish,这就是为什么我添加了<inherited>false</inherited>部分,并将要部署的模块描述为根 pom 中的<components>...</components>

现在命令:

mvn glassfish:deploy

将耳朵部署到玻璃鱼上,到目前为止一切都很好......但是 Maven 会递归地递归到所有子模块,这些子模块都将失败:

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

我可以告诉 maven 只使用 -pl 选项运行根项目,但出于我的热情,部署不应该依赖于这些额外的信息。

非常感谢您的帮助!

这个问题似乎没有好的解决方案:

  • 插件支持"NOP"/静默丢弃功能
  • 否则它将在所有子项目中失败

另一种方法是创建一个新的子项目(<modules>...</modules>它不包含在根项目中,而是从根项目继承),并仅向具有部署项目的项目添加依赖项。

现在可以将插件包含在此子项目中,而无需运行任何子项目。

或者对于任何懒惰的人:mvn clean package glassfish:redeploy -pl .有选择地只运行根项目而不下降到子项目中。

最新更新