hey,
I have a deploy pojo plugin (deploying a war to a remote server). I have the remote-deploy plugin in the build section of pom definition, I need package phase to be triggered before deploy-remote goal, for it the war be already created before I secure-copy it to a remote server.
With the execution elements (according to a documentation), I can attach my goal to a particular phase, for instance bind it to the phase after, so in my case, install phase …but that’s just a workaround.
<build>
<plugins>
<plugin>
<groupId>sample.plugin</groupId>
<artifactId>maven-hello-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>sayhi</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
simply put, if I place only my goal into the build section, and run it, package phase is not run before. Please help
You can’t.
Just bind it to the
packagephase, your goal will be called after the goals bounds topackageby default (so the war will be there).Here is an example demonstrating this behavior with the Maven AntRun plugin configured like this:
And the output of
mvn package:$ mvn package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Q3934833 Maven Webapp 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ ... [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Q3934833 --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.5:test (default-test) @ Q3934833 --- [INFO] No tests to run. [INFO] [INFO] --- maven-war-plugin:2.1:war (default-war) @ Q3934833 --- [INFO] Packaging webapp [INFO] Assembling webapp [Q3934833] in [/home/pascal/Projects/stackoverflow/Q3934833/target/Q3934833] [INFO] Processing war project [INFO] Copying webapp resources [/home/pascal/Projects/stackoverflow/Q3934833/src/main/webapp] [INFO] Webapp assembled in [317 msecs] [INFO] Building war: /home/pascal/Projects/stackoverflow/Q3934833/target/Q3934833.war [INFO] WEB-INF/web.xml already added, skipping [INFO] [INFO] --- maven-antrun-plugin:1.6:run (default) @ Q3934833 --- [INFO] Executing tasks main: [echo] Hi!!!!! [INFO] Executed tasks [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ ...The antrun plugin is executed after
package, as expected.