test integration phase including jetty:run-war - maven

I am still in a phase to create a POM.xml file. The basic is to start jetty plugin during the build life cycle. So far I have to enter
mvn package
mvn jetty:run-war
I do not want to do it manually. I prefer the way where a war file is created and jetty plugin started using the one command.
Here is my POM.xml
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/hellojavaworld</contextPath>
</webApp>
<war>c:\apache-tomcat-7.0.64\webapps\hellojavaworld.war</war>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<!--configuration>
<daemon>true</daemon>
</configuration-->
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Why the jetty plugin is not started when inserted the following command?
mvn pre-integrate-test
What is the problem? The jetty plugin starts only when used the command
mvn jetty:run-war

From parent : mvn jetty:run-war -pl module

Solved.
The property of the jetty plugin for multimodule project si mentioned here: Multi-module Maven project and jetty:run
I had to specify the plugin and lifecycle configuration in the child pom.xml file. In the parent it was not working.
---Hellojavaworld-pom.xml (parent)
----app-pom.xml (child)
----jjav-pom.xml (child)

Related

Skip maven-cucumber-reporting plugin when integration test is skipped

This is a basic level question about maven plugin lifecycle.
When I run the command mvn clean install -Dskip.integration.tests=false then cucumber report is generated by the following plugin:
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>${project.name}</projectName>
<inputDirectory>${project.build.directory}/cucumber</inputDirectory>
<outputDirectory>${project.build.directory}</outputDirectory>
<jsonFiles>
<jsonFile>cucumber.json</jsonFile>
</jsonFiles>
</configuration>
</execution>
</executions>
</plugin>
If I skip the integration tests using the maven command mvn clean install -Dskip.integration.tests=true then the maven build fails with the following error:
Execution execution of goal net.masterthought:maven-cucumber-reporting:5.5.0:generate failed: basedir app/target/cucumber does not exist
To what phase should the plugin be configured so that the maven build does not fail when integration test is skipped?
Add the skip variable to the plugin config whose value is based on whether the integration tests are skipped or not.
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<skip>${skip.integration.tests}</skip>
<projectName>${project.name}</projectName>
<inputDirectory>${project.build.directory}/cucumber</inputDirectory>
<outputDirectory>${project.build.directory}</outputDirectory>
<jsonFiles>
<jsonFile>cucumber.json</jsonFile>
</jsonFiles>
</configuration>
</execution>
</executions>
</plugin>
in root pom.xml in the properties section add:
<skip.integration.tests>true</skip.integration.tests>
Now the plugin generates cucumber-html-reports folder when you run the maven command mvn clean install -Dskip.integration.tests=false. If you skip integration tests using the maven command mvn clean install -Dskip.integration.tests=true then the cucumber-html-reports folder will not be generated but maven build would still succeed.

Maven plugin in not getting executed

I have a custom maven plugin but when i use that in my project pom , it does not get triggered !
Here is how i using same:
<plugin>
<groupId>com.autodeploy.maven</groupId>
<artifactId>my-docs-plugin</artifactId>
<version>1.0.2-0</version>
<inherited>false</inherited>
<executions>
<execution>
<id>myid</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<outputDirectory>target/doc</outputDirectory>
<custom-Folders>
<param>${basedir}/files/</param>
</custom-Folders>
</configuration>
</execution>
</executions>
</plugin>
I am triggering build cycle like mvn install:install or even mvn install ! None of these invoke my maven plugin !

Only generate one war during package

By default JHipster generate 2 wars during the package phase (your_project_version.war & your_project_version.war.original). The first one is the executable jar and the second is the war you can use in a servlet container.
Is there a way to only generate the 'original' war. The executable is not required for my project and I would like to deploy the war to Nexus.
jhipster generated project will make use of spring-boot, and in particular of the spring-boot-maven-plugin, which by default binds the repackage goal to the package lifecycle phase. If you want to disable the repackaging, it should be enough to edit your pomfile, so that no execution is present for the repackage goal (by setting the bound phase to none):
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<phase>none</phase>
</execution>
</executions>
</plugin>
If you need so, you will then be able to run the goal directly, as:
mvn package spring-boot:repackage
In SpringBoot 2, removing executions did not work for me. I needed to set goal to package :
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
<phase>none</phase>
</execution>
</executions>

maven tomcat7:run terminates automaticatlly in eclipse

Guys I know its very easy to run tomcat7 plugin in maven(in eclipse) but as I'm new to maven structure I can't figure it out that I was running maven build with "tomcat:run" and was working but I switched to maven plugin tomcat7 configured in pom.xml It starts it and stopped and gives build success msg. how change i make it keep listening?
Here my tomcate plugin settings
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<addContextWarDependencies>true</addContextWarDependencies>
<fork>true</fork>
<path>/</path>
<port>8080</port>
<httpsPort>8443</httpsPort>
<keystoreFile>C:/Users/Sohail Haider/.keystore</keystoreFile>
<keystorePass>apexsohail</keystorePass>
</configuration>
<executions>
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war</goal>
</goals>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
Take into account the default lifecycle in maven
So, what you are doing in the configuration is starting and stopping tomcat when you are building the project. I think that you have a webapp project and want to run tomcat so you have to remove executions tag from the configuration and just execute mvn tomcat7:run

Maven Build some modules, liferay:deploy others

I have some modules like:
|-business jar
|-dal jar
|-model jar
|-webApp war
I need to build all jar before liferay:deploy the war.
I also have a parent pom module that allow to build all modules but it doesn't deploy my war after that.
thanks
If you have defined all modules as dependencies then maven will take care that the modules build in the proper order.
By default the Liferay deploy goal is not executed. You need execute it or add some configuration to run tit automatically. e.g.
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<configuration>
<pluginType>portlet</pluginType>
</configuration>
<executions>
<execution>
<id>deploy-package</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
Does your parent pom contains all the modules in the
<modules>
<module>business-jar</module>
<module>dal-jar</module>
<module>model-jar</module>
<module>portlet</module>
<module>theme</module>
</modules>
and then make sure that your portlet/webapp war does contain
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<executions>
<execution>
<id>deploy-package</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</executions>
</plugin>

Resources