Maven child modules not being built
I have a relativey simple multi module maven buid with a parent pom. This includes the 2 child modules as follows:
<modules>
<module>WebApp</module>
<module>WebService</module>
</modules>
When I run mvn clean install on the top level pom it cleans & installs each child module as expected. However I am now trying to add a plugin (codehaus weblogic) goal to deploy the WebApp .war to Weblogic 10.3.4 e.g. mvn clean install weblogic:deploy. For some reason this does not run the clean and install phases but does the deploy. If I run the command from within the WebApp directory it does do the clean and install before doing the deploy.
Is there some gotcha I'm missing that will not run the child life cycle phases if running a goal at the top level. Here's the command line output:
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] SupportClient
[INFO] SupportClient-WebServices
[INFO] SupportClient-WebApp
[INFO] Searching repository for plugin with prefix: 'weblogic'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] ------------------------------------------------------------------------
[INFO] Building SupportClient
[INFO] task-segment: [clean, install, weblogic:deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] [site:attach-descriptor]
[INFO] [install:install]
[INFO] Installing C:\Development\Destin8SupportClient\pom.xml to C:\Users\finchaj.HPH\.m2 \repository\com\mcpplc\supportClient\supportClient\1.0\supportClient-1.0.pom
[INFO] [weblogic:deploy]
[INFO] Weblogic Deployment beginning with parameters DeployMojoBase[adminServerHostName = localhost, adminServerProtocol = t3, adminServerPort = 8001, userId = xx, password = ****, artifactPath = C:\Development\Destin8SupportClient/WebApp/target/WebApp.war, projectPackaging = war, name = support-client-webapp, targetNames = AdminServer,开发者_StackOverflow remote = false]
[INFO] Weblogic Deployment parameters [-adminurl, t3://localhost:8001, -username, xx, -password, xx, -name, support-client-webapp, -targets, AdminServer, -source, C:\Development\Destin8SupportClient/WebApp/target/WebApp.war, -deploy]
weblogic.Deployer invoked with options: -adminurl t3://localhost:8001 -username xx-name support-client-webapp -targets AdminServer -source C:\Development\Destin8SupportClient/WebApp/target/WebApp.war -deploy
The file, 'C:\Development\Destin8SupportClient/WebApp/target/WebApp.war', does not exist.
It is running the weblogic:deploy goal on the top-level (pom!) module. This goal can only be run on a war or ear module.
You need to bind that goal in the WebApp sub-module to run in the install phase. It is currently running on the top-level (pom!) module.
e.g. try adding the following to your weblogic configuration in the Webapp sub-module.
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
See also Example C-1 in this documentation
If you wish to have this run at the end of your build, once all other modules have been built, you will need to either:
- re-order your sub-modules, so WebApp is last, then do as above
- or, add another sub-module that will execute last, which depends on your WebApp submodule. Then, tell the weblogic plugin to use that .war file by specifying the following property maven.weblogic.war . You may want to use the dependency:copy goal first, to get the into the target dir of that last sub-module.
If you want to run the install phase first for all projects and after that deploy your projects to your webserver, you have to split the maven calls.
mvn clean install
mvn weblogic:deploy
By default, maven execute all tasks per project and to separate maven tasks the only solution to run them separately.
maven runs all the specified goals first on the parent project and then on the chldren.
From the logs it is evident that maven ran the clean
and install
goals of the parent and then tried to run the weblogic:deploy
goal. Now, weblogic:deploy
evidently is not a goal which is relevant to the parent, since it is meant to deploy a child webapp. maven does not know that and thus the failure.
Perhaps you should reconsider npellow's solution since it should work for your requirement.
精彩评论