My project is built using Maven. I use the 'Jacoco' plugin to perform quality checks.
For a project I would like to check the test coverage on line basis. I would like to check the line coverage only for only 3 packages. How can I specify this check?
I tried 'including' a number of packages, but that does not work.
I also tried to include the root package level and exclude a number of other packages. Also not working.
How can I have the package A, B and C checked? See my example below:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
...
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<includes>
<include>nl.abc.xyz.package-a.**</include>
<include>nl.abc.xyz.package-b.**</include>
<include>nl.abc.xyz.package-c.**</include>
</includes>
...
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.30</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
includes and excludes of rule are about name of the corresponding element.
In case of <element>PACKAGE</element> they are about package name.
And therefore
<includes>
<include>nl.abc.xyz.package-a.**</include>
<include>nl.abc.xyz.package-b.**</include>
<include>nl.abc.xyz.package-c.**</include>
</includes>
Matches for example package named nl.abc.xyz.package-a.something, but doesn't match nl.abc.xyz.package-a.
Given
src/main/java/org/example/a/A.java
package org.example.a;
public class A {
}
src/main/java/org/example/a/B.java
package org.example.b;
public class B {
}
src/test/java/ExampleTest.java
public class ExampleTest {
#org.junit.Test
public void test() {
new org.example.a.A();
}
}
and pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<includes>
<include>org.example.b</include>
</includes>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.90</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Execution of mvn verify will fail as expected
[INFO] --- jacoco-maven-plugin:0.8.2:check (check) # example ---
[INFO] Loading execution data file /private/tmp/j/target/jacoco.exec
[INFO] Analyzed bundle 'example' with 2 classes
[WARNING] Rule violated for package org.example.b: lines covered ratio is 0.00, but expected minimum is 0.90
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
and after replacement of <include>org.example.b</include> on <include>org.example.*</include> will also fail with the same message, because org.example.* matches org.example.b. And after replacement on <include>org.example.a</include> will succeed as expected.
This is my first use of Maven and I am trying to generate a client from a WSDL.
I created a Maven Project and downloaded a pom.xml file from a similar project then I ran mvn assembly:assembly command build to generate the stubs but the compilation doesn't work and it generate an error.
This is my pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.logicsector</groupId>
<artifactId>weather-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SOAP weather client</name>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
<build>
<finalName>weather-client</finalName>
<plugins>
<!-- Generate Java classes from WSDL during build -->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/weather.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Add generated sources - avoids having to copy generated sources to build location -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated/src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Build the JAR with dependencies -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
<!-- Build with Java 1.5 -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
And this is the error that I get
[INFO] Scanning for projects... [WARNING] [WARNING] Some problems
were encountered while building the effective model for
com.logicsector:weather-client:jar:0.0.1-SNAPSHOT [WARNING]
'build.plugins.plugin.version' for
org.codehaus.mojo:build-helper-maven-plugin is missing. # line 61,
column 21 [WARNING] [WARNING] It is highly recommended to fix these
problems because they threaten the stability of your build. [WARNING]
[WARNING] For this reason, future Maven versions might no longer
support building such malformed projects. [WARNING] [INFO]
[INFO]
------------------------------------------------------------------------ [INFO] Building SOAP weather client 0.0.1-SNAPSHOT [INFO]
------------------------------------------------------------------------ [INFO] [INFO] >>> maven-assembly-plugin:2.2-beta-5:assembly
(default-cli) # weather-client >>> [INFO] [INFO] ---
cxf-codegen-plugin:2.1.2:wsdl2java (generate-sources) # weather-client
--- mars 23, 2015 3:11:05 PM org.springframework.context.support.AbstractApplicationContext
prepareRefresh INFO: Refreshing
org.apache.cxf.bus.spring.BusApplicationContext#466d9e6c: display name
[org.apache.cxf.bus.spring.BusApplicationContext#466d9e6c]; startup
date [Mon Mar 23 15:11:05 GMT+01:00 2015]; root of context hierarchy
mars 23, 2015 3:11:05 PM
org.apache.cxf.bus.spring.BusApplicationContext getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
mars 23, 2015 3:11:05 PM
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory INFO: Bean factory for application context
[org.apache.cxf.bus.spring.BusApplicationContext#466d9e6c]:
org.springframework.beans.factory.support.DefaultListableBeanFactory#7f85e8ac
mars 23, 2015 3:11:06 PM
org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker
postProcessAfterInitialization INFO: Bean
'org.apache.cxf.bus.spring.Jsr250BeanPostProcessor' is not eligible
for getting processed by all BeanPostProcessors (for example: not
eligible for auto-proxying) mars 23, 2015 3:11:06 PM
org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker
postProcessAfterInitialization INFO: Bean
'org.apache.cxf.bus.spring.BusExtensionPostProcessor' is not eligible
for getting processed by all BeanPostProcessors (for example: not
eligible for auto-proxying) mars 23, 2015 3:11:06 PM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory#7f85e8ac:
defining beans
[cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
root of factory hierarchy mars 23, 2015 3:11:10 PM
org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing
org.apache.cxf.bus.spring.BusApplicationContext#466d9e6c: display name
[org.apache.cxf.bus.spring.BusApplicationContext#466d9e6c]; startup
date [Mon Mar 23 15:11:05 GMT+01:00 2015]; root of context hierarchy
mars 23, 2015 3:11:10 PM
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
destroySingletons INFO: Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory#7f85e8ac:
defining beans
[cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
root of factory hierarchy [INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 9.122s [INFO] Finished at: Mon Mar 23 15:11:10
GMT+01:00 2015 [INFO] Final Memory: 21M/311M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.cxf:cxf-codegen-plugin:2.1.2:wsdl2java (generate-sources)
on project weather-client: Execution generate-sources of goal
org.apache.cxf:cxf-codegen-plugin:2.1.2:wsdl2java failed: Illegal
character in opaque part at index 2:
D:\gireveWorkSpace\weather-client/src/main/wsdl/weather.wsdl -> [Help
1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run
Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to
enable full debug logging. [ERROR] [ERROR] For more information about
the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
I am using Eclipse Juno and I configured Maven successfully, can you help me please to find the solution.
Well you could use below pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.logicsector</groupId>
<artifactId>weather-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SOAP weather client</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cxf.version>2.7.5</cxf.version>
<slfj.version>1.7.5</slfj.version>
<jdk.version>1.6</jdk.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slfj.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slfj.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slfj.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<versionRange>[2.7,)</versionRange>
<goals>
<goal>wsdl2java</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/weather.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/ServiceManagement.wsdl</wsdlLocation>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-client</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Maven compiler -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
You could change cxf version based on the requirement and jdk version in properties tag. Though the version you are talking about is maven eclipse plugin (m2e), however eclipse supports maven version 3, and more over dependencies are independent of maven version.
Another point worth noting directory structure, wsdl directory in configuration is outside the classpath. In maven by default the src/main/java,src/main/resources are the classpath(this is also considered during packaging). Hence modified your cxf plugin configuration accordingly
Trying to see unit test code coverage on sonar. I am using Jacoco code coverage and able to get the code coverage for my project when I execute my code in eclipse. However while running in Jenkins, I get following messages and warnings as NO Tests to run , No Sources to compile
I can the some code coverage report on sonar but for unit tests it shows. How can Sonar display the coverage for unit tests? Also how can I eliminate the warning messages?
Attaching my surefire and jacoco plugins and jebnkins console log
Kindly help
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.4.201312101107</version>
<executions>
<execution>
<id>prepare-unit-test-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>generate-unit-test-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.12.4</version>
</dependency>
</dependencies>
<configuration>
<systemPropertyVariables>
<environment>${env.USER}</environment>
</systemPropertyVariables>
</configuration>
</plugin>
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project Test 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # project test ---
[INFO] Deleting /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:prepare-agent (prepare-unit-test-agent) # project test ---
[INFO] argLine set to -javaagent:/Users/ray1/.m2/repository/org/jacoco/org.jacoco.agent/0.6.4.201312101107/org.jacoco.agent-0.6.4.201312101107-runtime.jar=destfile=/Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target/jacoco.exec
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # project test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # project test---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # project test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # project test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # project test ---
[INFO] No tests to run.
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (run-unit-tests) # project test ---
[INFO] No tests to run.
[INFO] Skipping execution of surefire because it has already been run for this configuration
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # project test ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target/project test-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:report (generate-unit-test-report) # project test ---
[INFO] Skipping JaCoCo execution due to missing execution data file
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # project test ---
[INFO] Installing /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target/project test-0.0.1-SNAPSHOT.jar to /Users/ray1/.m2/repository/com/company/taf/project test/0.0.1-SNAPSHOT/project test-0.0.1-SNAPSHOT.jar
[INFO] Installing /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/pom.xml to /Users/ray1/.m2/repository/com/company/taf/project test/0.0.1-SNAPSHOT/project test-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.801 s
[INFO] Finished at: 2015-04-14T10:25:50-07:00
[INFO] Final Memory: 15M/81M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/pom.xml to com.company.inner/project test /0.0.1-SNAPSHOT/project test-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target/project test-0.0.1-SNAPSHOT.jar to com.company.inner/project test /0.0.1-SNAPSHOT/project test-0.0.1-SNAPSHOT.jar
channel stopped
Finished: SUCCESS
you need to add this section to your parent pom.xml
<properties>
<!-- Properties to make sure we capture *all* coverage -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.language>java</sonar.language>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
I had the similar issue, 0.0% coverage & no unit tests count on Sonar dashboard with SonarQube 6.7.2:
Maven : 3.5.2,
Java : 1.8,
Jacoco : Worked with 7.0/7.9/8.0,
OS : Windows
After a lot of struggle finding for correct solution, resolved issue with this configuration my parent pom looks like:
<properties>
<!--Sonar -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.language>java</sonar.language>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
I've tried few other options like jacoco-aggregate & even creating a sub-module by including that in parent pom but nothing really worked & this is simple. I see in logs <sonar.jacoco.reportPath> is deprecated,but still works as is and seems like auto replaced on execution or can be manually updated to <sonar.jacoco.reportPaths> or latest. Once after doing setup start with mvn clean install then mvn org.jacoco:jacoco-maven-plugin:prepare-agent install & then do mvn sonar:sonar , this is what I've tried please let me know if some other best possible solution available.Hope this helps!! If not please post your question..
I'm using jmeter-maven-plugin to run Performance test using JMX files:
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.0</version>
<dependencies>
<dependency>
<groupId>com.gemalto.pse.pim</groupId>
<artifactId>pim-ws-client</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<testFilesIncluded>
<jMeterTestFile>file_1.jmx</jMeterTestFile>
<jMeterTestFile>file_2.jmx</jMeterTestFile>
</testFilesIncluded>
</configuration>
</execution>
</executions>
</plugin>
The JMX file file_1.jmx execute a method in a class that call a web-service as follows:
final String ENDPOINT_ADDRESS = "http://10.256.45.147:8080/service-ejb/ServiceClass?wsdl";
final QName SERVICE_NAME = new QName(
"http://service.tools.com/", "ServiceClassService");
javax.xml.ws.Service service = javax.xml.ws.Service.create(
new URL(ENDPOINT_ADDRESS), SERVICE_NAME);
IServiceClass myService = dataFinderService.getPort(IServiceClass.class);
The problem is that Jmeter plugin is blocked at execution of file_1.jmx and does not process the file_2.jmx, the process is blocked at:
IServiceClass myService = dataFinderService.getPort(IServiceClass.class);
And when i cancel the execution (type Ctrl+C) the process continues and Jmeter-maven-plugin generate the output report file
Any one have encounter this problem ? ... Thanks a lot in advance :)
The problem is resolved, all what i implimented is right, the problem is just that i should use jmeter-maven-plugin version 1.8.0 instead of 1.9.0 :)
I created a new scala project with the following:
mvn org.apache.maven.plugins:maven-archetype-plugin:2.2:generate
-DarchetypeGroupId=org.scala-tools.archetypes
-DarchetypeArtifactId=scala-archetype-simple
-DarchetypeVersion=1.3
-DgroupId=myGroup
-DartifactId=myProject
-Dversion=0.1.0
-DinteractiveMode=false
Which gives me the following POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myGroup</groupId>
<artifactId>myProject</artifactId>
<version>0.1.0</version>
<name>${project.artifactId}</name>
<description>My wonderfull scala app</description>
<inceptionYear>2010</inceptionYear>
<licenses>
<license>
<name>My License</name>
<url>http://....</url>
<distribution>repo</distribution>
</license>
</licenses>
<properties>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.8.0</scala.version>
</properties>
<!--
<repositories>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>
-->
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scala-tools.testing</groupId>
<artifactId>specs_${scala.version}</artifactId>
<version>1.6.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-make:transitive</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<useFile>false</useFile>
<disableXmlReport>true</disableXmlReport>
<!-- If you have classpath issue like NoDefClassError,... -->
<!-- useManifestOnlyJar>false</useManifestOnlyJar -->
<includes>
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
I can run mvn test and the sample tests run successfully. I'd like to use the most recent version of scala (I downloaded / installed 2.9.2...), but the most recent version of the org.scala-tools.testing scala_VERSION dependency seems to be 2.9.1. I made the following changes in my POM:
<scala.version>2.9.1</scala.version>
and
<dependency>
<groupId>org.scala-tools.testing</groupId>
<artifactId>specs_${scala.version}</artifactId>
<version>1.6.5</version>
<scope>test</scope>
</dependency>
Now, running mvn test gives
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running samples.ListSuite
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.674 sec <<< FAILURE!
initializationError(samples.ListSuite) Time elapsed: 0.003 sec <<< ERROR!
java.lang.ClassCastException: scala.collection.immutable.Set$EmptySet$ cannot be
cast to scala.collection.generic.Addable
at org.scalatest.FunSuite$class.test(FunSuite.scala:1039)
at samples.ListSuite.test(scalatest.scala:59)
at samples.ListSuite.<init>(scalatest.scala:61)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at org.scalatest.junit.JUnitRunner.<init>(JUnitRunner.scala:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:51)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:103)
at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
Running samples.StackSuite
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.12 sec
Running samples.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
Results :
Tests in error:
initializationError(samples.ListSuite)
Tests run: 4, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.880s
[INFO] Finished at: Wed Oct 10 01:10:56 ADT 2012
[INFO] Final Memory: 9M/112M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.6:test (default-test) on project myProject: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Dropbox\work\dev\scalasandbox\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I presumably have some of the most simple tests possible (samples created by the maven archetype plugin), and bumping scala by a single minor version is breaking them? Should I just stick with scala 2.8 until the maven tools catch up?
Your artifact is outdated.
The latest version of Scala is 2.10. Currently ScalaTest is being distributed under different groupid and it supports the latest version of Scala. Here's the dependecy:
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<version>2.0.M5b</version>
<scope>test</scope>
</dependency>
You will also require a different plugin:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
You don't need to specify any repositories, since all those artifacts are being distributed with the central repo.
Here's an example of a complete pom of a project depending on the Scala 2.10.
Use specs_2.9.1:1.6.9
And latest version of plugin
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
Old scala maven plugin in not longer supported.