How can I execute following maven plugin before resolving the dependencies - maven

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.

Related

replace nexus staging maven plugin with maven-deploy-plugin

Our project inherits nexus staging maven plugin from a parent pom which we don't have control on. I have this configuration in my root pom to disable the nexus staging maven plugin and this configuration seems to disabling the default-deploy execution.
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
</executions>
<configuration>
<serverId>nexus</serverId>
<nexusUrl>url</nexusUrl>
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
</configuration>
</plugin>
and I have the maven deploy plugin defined in my root pom, but the maven-deploy plugin seems to be not kicking off
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
I am not able to figure out how i can replace the inherited nexus staging maven plugin with the maven deploy plugin. Any help is much appreciated
You may qualify the goal by the plugin groupID:artefactID:
mvn org.apache.maven.plugins:maven-deploy-plugin:deploy
I faced a similar issue, and for success disabling of nexus-staging-maven-plugin I only need to add following to my main pom:
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>false</extensions>
</plugin>
And as one of my dependencies was disabling maven-deploy-plugin(I reccomend to check it also in your project) I also need to add:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>

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.

Maven how to invoke a plugin goal?

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>

maven execute java command

I want to execute a jar file with parameters from maven. The command I want to execute is listed below. I have the perf4j jar file in the dependency. The times.log file is in they filesystem.
java -jar perf4j-0.9.16.jar times.log
Thanks
You might want to take a look # exec-maven-plugin
first
mvn clean install
than
mvn exec:java -Dexec.mainClass="com.java.App" -Dexec.args="Args"
What do you really want to do ? Using a jar (which is a dependency) to monitor your app ?
Did you took a look at maven exec plugin ?
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
...
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>maven</executable>
<!-- optional -->
<workingDirectory>/tmp</workingDirectory>
<arguments>
<argument>-X</argument>
<argument>myproject:dist</argument>
...
</arguments>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
I had looked at maven exec plugin but wasn't sure how and where to specify the jar file name, hence thanks for your responses, but I was looking at a little more info especially with jar file. With some trial and error the following worked. I had to find the main class to use from the jar file. mvn install runs the file and produces the following output:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.perf4j.LogParser</mainClass>
<arguments>
<argument>InlineLogging.log</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.perf4j</groupId>
<artifactId>perf4j</artifactId>
</dependency>
</dependencies>

Resources