In my pom.xml I have frontend-maven-plugin.
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<nodeVersion>v6.11.0</nodeVersion>
<npmVersion>3.10.10</npmVersion>
<workingDirectory>src/main/frontend</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
It takes some time to run it and don't need this plugin when I run tests.
Is it possible to not execute the plugin when I run mvn test?
The frontend-maven-plugin now has specific keys to disable execution of particular goals. For example, adding system property skip.npm will skip npm execution. You can add it when running maven this way:
mvn test -Dskip.npm
did you heard about maven profile?
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
I understand that when you want to test a package, you don't want to build a bigger one.
You could define a profile that choose exactly what module you want to build and test.
You have a related question there:
Disable maven plugins when using a specific profile
Let us know if it helped you!
Related
I am integrating Flyway in to an existing legacy project, which consists of multiple databases for the same application. The project uses Maven and I want to use the maven-flyway-plugin to integrate with Flyway.
My working configuration so far looks like this:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<executions>
<execution>
<id>db1</id>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
...
</configuration>
</execution>
<execution>
<id>db2</id>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
...
</configuration>
</execution>
<execution>
<id>db2</id>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
...
</configuration>
</execution>
</executions>
</plugin>
With this I can migrate each database separately like this:
mvn flyway:migrate#db1 flyway:migrate#db2 flyway:migrate#db3
Unfortunately this is not very user friendly. I want to be able to simply execute mvn flyway:migrate and execute all three migration configurations.
How can I achieve that?
maven works this way. You can either extends flyway plugin with your needs or you can migrate to gradle which can gather multiple 'job'
Eric
I have a maven project which I do get the new project version from user with:
Current Version = 1.0.0
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>set</goal>
</goals>
</execution>
</executions>
</plugin>
Current Version = 2.0.0
and after that I called my own custom plugin, which runs set of calculations and appends an String to the version
Current Version = 2.0.0
<groupId>mygroup</groupId>
<artifactId>my artifact</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
Current Version = 2.0.0-AddedString
but when I run other plugins, for example:
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<executions>
<execution>
<id>end</id>
<goals>
<goal>echo</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<message>${project.version}</message>
</configuration>
</execution>
</executions>
which gives me the result of : "1.0.0" which should be "2.0.0-AddedString"
but why?
and how to fix this? I need all plugins use the new version and work with that.
You need separate Maven runs for that.
If you run something like mvn versions:set -DnewVersion=2.0.0 my:plugin, then my:plugin will see the version as it was before starting the command, not the 2.0.0 that was set in between.
So when you have goals that change the POM, you need to call them in separate Maven runs, i.e. first mvn versions:set -DnewVersion=2.0.0 and then mvn my:plugin.
Below is the relevant part of my POM -
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>StartHub</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>${basedir}/src/lib/Hub/selenium-server-standalone-2.53.0.jar</argument>
<argument>-role</argument>
<argument>hub</argument>
<argument>-throwOnCapabilityNotPresent</argument>
<argument>false</argument>
<argument>-newSessionWaitTimeout</argument>
<argument>20000</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>StartNode</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>${basedir}/src/lib/Node/selenium-server-standalone-2.53.0.jar</argument>
<argument>-hub</argument>
<argument>http://127.0.0.1:4444/register/grid</argument>
<argument>-port</argument>
<argument>5555</argument>
<argument>
Dwebdriver.chrome.driver=${basedir}/chromedriver.exe</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
I was trying to use the exec plugin to execute a jar(selenium standalone server) in two configurations(hub and Node).
My issue is that the jar is executed only once in the configuration specified between the first pair of "execution" tags. I have searched extensively for a solution and the only thing I found was that the id's for different executions need to be different, which I rectified. I still can't seem to manage to run the jars twice even though I can run any one of them successfully if I comment out the execution of the other.
I should also mention that I'm running the project in Eclipse, so ideally what I would want to do is right-click on the POM.xml click on Run-as and select "Maven test".
This is not a Maven executions issue but rather an issue related to what you are executing: a blocking process (the first server) which would stop the build listening for a node which would never get connected (because its execution won't start).
Changing your pom to the following:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>StartHub</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-version</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>StartNode</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-version</argument>
</arguments>
</configuration>
<a/execution>
</executions>
</plugin>
It would perfectly execute the two exec executions, printing twice the Java version. Note: the snippet is a copy and paste from your question, just replacing arguments of the java command to its version option.
What you are most probably looking for is to execute the two commands in background or at least in a non-blocking way in order to get the second executed, then proceed with the build (to execute some tests I presume).
Check this SO question on how to achieve it: instead of using the exec-maven-plugin, use the maven-antrun-plugin to launch the two selenium commands.
As a further note, you should probably consider using the maven-failsafe-plugin instead and execute integration tests, attaching the executions above to the pre-integration-test phase and stop them during the post-integration-test phase in order to properly clean them.
I have multi module maven project. One parent and two submodules. In first module I have integration tests, specifically selenide tests, which are testing web application. Web application is in the second module. I want to deploy application via jetty server and then run selenide tests on it in one maven command. I have tried more solutions and here are few of them.
In the module with web app I set up jetty plugin to run server before tests.
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<contextPath>web-app</contextPath>
<stopPort>8005</stopPort>
<stopKey>STOP</stopKey>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
and failsafe-maven-plugin.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>failsafe-maven-plugin</artifactId>
<version>2.4.3-alpha-1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
But problem is that plugin not find any tests because they are in other module.
Can you tell me how to set up failsafe to find test in first module ? Or other solution for example run it from parent ?
Well, I'm not an expert, maybe JUnit #Rule is that can help you to solve your task: to initialise, deploy and test your web app.
Have a look at this:
How does Junit #Rule work?
JUnit Rules Wiki
Here is described Rule to start a Jetty Server
In my maven project I use the pgp plugin to sign my jars. I need to do this only when deploying to remote repo, but not when installing to local repo. So I tried to set the phase to deploy.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>deploy</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
With that configuration maven first deploys to remote repo and theh signs my jars...
I read that plugins are executed in the order they are defined in POM file, so I tried to configure deploy-plugin after sign plugin, but that didnt have any effect
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>deploy</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
How can I achieve that sign plugin is not executed on install, but on deploy before artifacts are uploaded? I'm using maven3.
First i would suggest to update maven-gpg-plugin to an more up-to-date version cause this version 1.1 is of 2010..Apart from that i would suggest to keep the defaults of the plugins which means the binding of maven-deploy-plugin as the deploy life cycle and for the maven-gpg-plugin the verify life cycle phase which is not ideal if you have integration tests. In such cases it makes sense to define a profile which is activated only in release cases to prevent confusions with integration test.
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<updateReleaseInfo>true</updateReleaseInfo>
</configuration>
<executions>
<execution>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
I have seen project putting the gpg-plugin in verify phase.
May I know what version of Maven you are using? I believe the plugin in same phase should run in order it is defined, after Maven 2.0.10 (or probably earlier). However as maven-deploy-plugin is default binding for deploy phase, I am not clear if the ordering will be in effect