繁体   English   中英

多项目设置中的Maven Maven-glassfish-plugin

[英]Maven maven-glassfish-plugin in a multiproject setup

简短版本

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

长版

设置如下:

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 . 有选择地只运行根项目,而不必进入子项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM