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
Related
I have spring boot app and i want to run it as service. I am using tanuki wrapper to do so :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.8.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate-daemons</goal>
</goals>
</execution>
</executions>
<configuration>
<logsDirectory>logs</logsDirectory>
<daemons>
<daemon>
<id>DataCopier</id>
<wrapperMainClass>org.tanukisoftware.wrapper.WrapperSimpleApp</wrapperMainClass>
<mainClass>com.myProject.mainClass</mainClass>
<platforms>
<platform>jsw</platform>
</platforms>
</daemon>
</daemons>
</configuration>
</plugin>
However how do i run this? I included it as plugin. I tried to mvn install it to see if this generates something but it does not generate anything in target folder. How do i run this then?
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!
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
I have a project named HelloWorld. It is a maven java project.
I have got a repository like https://my.repo.com/svn/filesToCopy
What i want to do is:
Automaticly coping 3 files (a.xsd, b.xsd, c.xsd) from SVN repository into my src/main/resource directory.
I was trying to add smth like that in my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Coping one file</echo>
<copy file="https://my.repo.com/svn/filesToCopy/a.xsd" todir="${basedir}/src/main/resource" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
And then just building a project but it isnt working at all.
What is more im wondering if passing a https link need a username and password somewhere.
Any ideas?
Have you tried this approach? It's from Maven SCM plugin
<execution>
<id>perform-checkout</id>
<configuration>
<connectionUrl>myUrl</connectionUrl>
<checkoutDirectory>myDirectory</checkoutDirectory>
<excludes>folder1</excludes>
</configuration>
<phase><!-- some phase --></phase>
<goals>
<goal>checkout</goal>
</goals>
</execution>
I use tomcat6-maven-plugin to run integration tests on my web application. This starts Tomcat and deploys my web application in it before running the tests. Works well!
But I'd like to run another web application, GeoServer, at the same time, for some new integration tests to work. What would be the best approach?
Is it possible to add a GeoServer .war to the Tomcat instance started using tomcat6-maven-plugin? How?
Here my current tomcat6-maven-plugin config :
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<port>8087</port>
<fork>true</fork>
<useTestClasspath>true</useTestClasspath>
</configuration>
<executions>
<execution>
<id>run</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>shutdown</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>