Why Jetty Not Start After Mvn Install - maven

I use follow config pom.xml
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.6.14.v20131031</version>
<executions>
<execution>
<id>start-jetty</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Then I use mvn clean install, All build success, But the jetty not start not run.

I find the error.My config is error.
Use this is OK!
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.0.v20120127</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/mideaAdmin</contextPath>
</webApp>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>9999</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<stopPort>8191</stopPort>
<stopKey>ts</stopKey>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<finalName>mideaAdmin</finalName>
</build>

Related

SonarQube doesn't show any results

I don't know why sonarqube isn't showing any resuls while running sonar-scanner and even mvn clean verify sonar:sonar and everything is successfully but with no results.
this is my configuration:
sonar.host.url=http://localhost:9000
sonar.projectKey=releveproject
sonar.projectName=releveproject
sonar.java.binaries=**/**target/classes
sonar.login=admin
sonar.password=1234
POM.xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>ini</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property environment="env" />
<echoproperties prefix="env." />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>**/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
This is how it looks like on sonarqube dashboard:

Configuring Findbugs in Jenkins

My goal is to fail jenkins build for my project in case bugs are reported by FindBugs plugin. For that I have integrated FindBugs config in the project's pom.xml & the execution part of the config is below
<executions>
<execution>
<id>analyze-compile</id>
<phase>compile</phase>
<goals><goal>check</goal></goals>
<configuration>
<threshold>High</threshold>
</configuration>
</execution>
</executions>
I found the above config from online sources & with this config, the project is not failing incase of bugs reported by FindBugs. Also I have tried other configs like below
<xmlOutput>true</xmlOutput>
<configuration>
<failOnError>${findbugs.failOnError}</failOnError>
<threshold>High</threshold>
</configuration>
<executions>
<execution>
<id>noFailOnError</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<failOnError>false</failOnError>
</configuration>
</execution>
<execution>
<id>failOnError</id>
<phase>install</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<failOnError>true</failOnError>
</configuration>
</execution>
</executions>
Can someone please let me know what is the correct execution which needs to be used for failing build in case of bugs in FindBugs ?
Below is the correct configuration for find-bugs in pom.xml. It does the following - Perform FindBugs check, Generate xml report during verify phase , Transform it to html & Fail build in case bugs are present during check
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<id>findbug</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<findbugsXmlOutputDirectory>
${project.build.directory}/findbugs
</findbugsXmlOutputDirectory>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>${project.build.directory}/findbugs</dir>
<outputDir>${project.build.directory}/findbugs</outputDir>
<stylesheet>fancy-hist.xsl</stylesheet>
<!--<stylesheet>default.xsl</stylesheet> -->
<!--<stylesheet>plain.xsl</stylesheet> -->
<!--<stylesheet>fancy.xsl</stylesheet> -->
<!--<stylesheet>summary.xsl</stylesheet> -->
<fileMappers>
<fileMapper
implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.html</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.3</version>
<executions>
<execution>
<id>failing-on-high</id>
<phase>install</phase>
<goals>
<goal>findbugs</goal>
<goal>check</goal>
</goals>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<failOnError>true</failOnError>
</configuration>
</execution>
</executions>
</plugin>

Maven-replacer-plugin is not invoked with maven-war-plugin

I am trying to replace string %APP_NAME% with enviroment variable in jdbc.properties using maven. I have following configuration:
<pluginManagement>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${project.build.directory}/classes</basedir>
<includes>
<include>jdbc.properties</include>
</includes>
<replacements>
<replacement>
<token>%APP_NAME%</token>
<value>${env.BRANCH_NAME}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
<executions>
<execution>
<!-- First step is to disable the default-war build step. -->
<id>default-war</id>
<phase>none</phase>
</execution>
<execution>
<!-- Second step is to create an exploded war. Done in prepare-package -->
<id>war-exploded</id>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
<execution>
<!-- Last step is to make sure that the war is built in the package
phase -->
<id>custom-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- <compilerArgument>-Xlint:all</compilerArgument> -->
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<compilerArguments>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</pluginManagement>
When i invoke:
mvn clean package
or
mvn clean install
the replacer plugin is not called. Can anyone can please explain why and what can I do to let it work? Or if replacer is not compatible with future war plugin can anyone explain me any other way to replace some string in jdbc.properties before building war? I saw also ant plugin but with same config it is not called too.. Example below..
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>deploy-ui</id>
<phase>package</phase>
<inherited>false</inherited>
<configuration>
<tasks>
<replace dir="${basedir}/src/main/resources">
<include name="**/jdbc.properties" />
<replacefilter token="%APP_NAME%" value="${env.BRANCH_NAME}"/>
</replace>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The plugin is defined in a <pluginManagement> block:
<pluginManagement>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
...
Find the <build><plugins> block for the POM where replacer needs to run, and add the following:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
</plugin>
Plugin Management is rather like a template for what should happen when the plugin is invoked. If the plugin is not referenced in the <build><plugins> block, nothing will happen.

maven toolchain in profile

If I define toolchain plugin in activated by default profile it's not working for some plugin such as maven-javadoc-plugin(for maven-compiler-plugin it is working) :
<profile>
<id>jdk-toolchain</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>${project.javaVersion}</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
</build>
</profile>
In other case it work perfect for all plugin:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>${project.javaVersion}</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
...
</plugins>
</build>
Why is this happening?
you have to bind the execution of your plugin into validate phase:
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>

Build waits at Jetty start when running integration tests

I'm trying to run some integration / acceptance tests.
I want to run these tests only when passed an environment variable, and so I use the following command:
mvn clean install -Denv="acceptance"
But the build stops at
2015-09-28 18:56:19.273:INFO:oejsh.ContextHandler:main: Started o.e.j.m.p.JettyWebAppContext#4bbc9862{/,file:///home/stephane/dev/java/projects/kahoot-rest/src/main/webapp/,AVAILABLE}{file:///home/stephane/dev/java/projects/kahoot-rest/src/main/webapp/}
2015-09-28 18:56:19.419:INFO:oejs.ServerConnector:main: Started ServerConnector#26b4acf4{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2015-09-28 18:56:19.423:INFO:oejs.Server:main: Started #171829ms
[INFO] Started Jetty Server
I'm using Java 1.8.
My pom.xml file:
<profile>
<id>acceptance</id>
<activation>
<property>
<name>env</name>
<value>acceptance</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>failsafe-maven-plugin</artifactId>
<version>2.4.3-alpha-1</version>
<configuration>
<includes>
<include>**/acceptance/*.java</include>
</includes>
<excludes>
<exclude>**/*$*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.4.RC0</version>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
<configuration>
<stopKey>stop</stopKey>
<stopPort>8081</stopPort>
</configuration>
</execution>
</executions>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<connectors>
<connector implementation="org.eclipse.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
</build>
</profile>
change
<goal>run</goal>
to
<goal>start</goal>
and add daemon option
<configuration>
<daemon>true</daemon>
</configuration>

Resources