Maven how to invoke a plugin goal? - maven

In the Tomcat Maven plugin, tomcat7-maven-plugin, how to invoke the goal, tomcat7:deploy, after package phase ? can you please give me concise sample pom file ?
Thanks.

Add an execution for the plugin and tie it to a phase after the package phase, i.e. verify or install..
<build>
<plugins>
<plugin>
<dependency>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Related

Maven shade plugin is not called automatically for goal "package"

I've spent quite a bit of time figuring out how to invoke Maven shade plugin to build a uber-jar (with all dependencies).
Most of the google-able info that I found (including numerous examples, and Maven documentation) suggests that all I have to do is include the plugin into pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
and then "mvn package" (or any other goal that eventually invokes "package") will automatically trigger this plugin.
But no matter what I tried - the only way to actually invoke the plugin appears to be: running "mvn package shade:shade" (which seems to defeat the purpose of config-driven build). Same results whether running Maven from within Eclipse (STS Version: 3.8.2.RELEASE), or from command line (Apache Maven 3.3.9).
Am I missing anything?
UPD: solved, see answer by GauravJ.
I have managed to reproduce your problem. In your pom.xml, you must have defined plugin like below,
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
....
</plugins>
</pluginManagement>
</build>
instead of
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
This will probably fix your problem.

How can I execute following maven plugin before resolving the dependencies

I am from ANT background and newbie to Maven.
For some reason, I need to execute shell script before maven tries to fetch snapshot dependencies.
So I wrote following plugin configuration, but I not getting how can I make it invoke before resolving dependencies task.
I am using Apache Maven 3.0.5
Following is the part of my pom.xml
<build>
<finalName>edte</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<phase>clean</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>Docs/ci/delete_snapshots.sh</executable>
<arguments>
<argument>${user.home}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Any help is appreciated.

convert maven plugin into gradle plugin

I'm planning to use aspects-jcabi for benchmarking my methods (http://aspects.jcabi.com/annotation-loggable.html). However, it uses maven-plugin, and my project is on gradle. I'm not yet that familiar with Gradle though.
Can I write the following in gradle (http://aspects.jcabi.com/example-weaving.html)?
<project>
<build>
<plugins>
<plugin>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-maven-plugin</artifactId>
<version>0.8</version>
<executions>
<execution>
<goals>
<goal>ajc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Maven jarsigner plugin

I just tried to configure the maven jarsigner plugin for signing a jar project.
As far as I can understand, the plugin should run automatically when I run mvn clean package but it doesn't.
I must run mvn clean package jarsigner:sign for the plugin to be executed.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.4</version>
<configuration>
<executions>
<execution>
<id>sign</id>
<phase>package</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<alias>java-code</alias>
<keystore>mykeystore.keystore</keystore>
<keypass>mykeypass</keypass>
<storepass>mystorepass</storepass>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
I could find the error on my own. The configuration element has to be within the execution element.
Thanks.

Generating java from rpc wsdl

I have a pom which generates some java code from an RPC wsdl. The problem is that the code is never generated.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<sourceDirectory>src/main/resources</sourceDirectory>
<outputDirectory>${project.build.directory}/generated/rpc</outputDirectory>
<packageSpace>com.company.wsdl</packageSpace>
<testCases>false</testCases>
<serverSide>true</serverSide>
<subPackageByFileName>false</subPackageByFileName>
</configuration>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
Any ideas as to why this isnt generating the java code?
After taken a look into your pom I realized your problem. It's not related to calling mvn its based on the configuration you made.
You have configured the axistools-maven-plugin in the pluginManagement area. In this case you need to do this in the build area like this:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
..
</configuration>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
instead of:
<build>
<pluginManagement>
<plugins>
...
</plugins>
</pluginManagement>
...
</build>
If you configure it correctly you can use mvn clean package or mvn clean install instead of calling mvn axistools:wsdl2java ...

Resources