I have a parent pom.xml that defines the emma-maven-plugin with inherited=true.
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven.site.version}</version>
</plugin>
<plugin>
<groupId>org.sonatype.maven.plugin</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>${emma.maven.version}</version>
<inherited>true</inherited>
</plugin>
</plugins>
</reporting>
However I have a child pom.xml that does not contain any tests. So I tried adding this... execution none, inherited false and skip true to skip the emma report generation, but it does not seem to work. Any ideas?
<build>
<plugins>
<plugin>
<groupId>org.sonatype.maven.plugin</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>${emma.maven.version}</version>
<inherited>false</inherited>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.sonatype.maven.plugin</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>${emma.maven.version}</version>
<inherited>false</inherited>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</reporting>
I found a way to not instrument certain package and thus not creating coverage.em thus not creating EMMA report.
<build>
<plugins>
<plugin>
<groupId>org.sonatype.maven.plugin</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>${emma.maven.version}</version>
<configuration>
<filters>
<filter>-com.package.*</filter>
</filters>
</configuration>
</plugin>
</plugins>
</build>
Related
I am using maven assembly to build my java application and package it as a JAR file. The resources are located in src/main/resources and they are not copied to the created JAR file.
The POM.XML is like this:
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.test.Application</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Please let me know how can I fix this! I tried to use Resource tag, but it did not work.
I want to override a configLocation that is originally declared in a configuration of a maven-checkstyle-plugin in the parent pom.xml.
But when I'm executing mvn clean package in the child project it's ignoring <configLocation>child-stylecheck.xml</configLocation> and uses parent-stylecheck.xml instead. The child-stylecheck.xml is located in the root of the project next to the pom.xml.
What could be wrong in my configurations?
Plugin configuration in the parent pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-version}</version>
<configuration>
<configLocation>parent-stylecheck.xml</configLocation>
<outputFileFormat>xml</outputFileFormat>
<failOnViolation>true</failOnViolation>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Plugin configuration in the child pom.xml
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-version}</version>
<configuration>
<configLocation>child-stylecheck.xml</configLocation>
<suppressionsFile>parent-stylecheck.xml</suppressionsFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
I'm new to maven, I've a xsd file and am trying to generate JAXB classes for that but the below code is not generating any classes. Below is part of my pom.xml, after adding jaxb2-maven-plugin I did maven clean and maven install and there are no classes generated. Am I missing something or have I misplaced it ? any help would be appreciated.
Update : I was able to generate classes when I ran the command mvn jaxb2:xjc , but not when I do mvn clean install. What should be done for this ?
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>buildinfo.txt</include>
<include>log4j.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>buildinfo.txt</exclude>
<exclude>log4j.xml</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>some-execution</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<workingDirectory>target</workingDirectory>
<arguments>
<argument>-cp</argument>
<argument>classes:${rev-trac-properties}:dependency/*</argument>
<argument>-Xdebug</argument>
<argument>-Xrunjdwp:transport=dt_socket,address=${dport},server=y,suspend=n</argument>
<argument>-Dtrac.home="${trac.home}"</argument>
<argument>com.rev.trac.service.app.MainApp</argument>
</arguments>
</configuration>
</plugin>
<!-- My code -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/webapp/schemas/</schemaDirectory>
<schemaFiles>syncConfig.xsd</schemaFiles>
<packageName>com.example.mapping</packageName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>ISO-8859-1</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>${project.artifactId}-${project.version}</finalName>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>${eclipsePluginVersion}</version>
<configuration>
<!-- by default download all sources when generating project files -->
<downloadSources>true</downloadSources>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER/${vmtype}/${jdkName}</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
</plugin>
</plugins>
</build>
I'm trying to setup Maven with my GWT project but every time that I start debugging, it deletes web.xml and other files that are required to start.
Code fragment related to build from my pom.xml :
<build>
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<webXml>${webappDirectory}/WEB-INF/web.xml</webXml>
<source>${target.jdk}</source>
<target>${target.jdk}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
</plugins>
</build>
Below is my maste pom file profile for my product unit tests. we have junit plug-in tests.
These pom file configurations not giving me the jacoco code coverage file(.exec) in any location.
please help me if any wrong some where. Thank you
<profile>
<id>unit-tests</id>
<modules>
<module>../../../test/com.xxxx.tools.comms.test.utilities</module>
<!-- product related unit tests
<module>../../../test/com.xxxx.comms.product.test</module>
<module>../../../test/com.xxxx.comms.product.mas.test</module>-->
<module>../../../test/com.xxxx.comms.product.iv.test</module>
</modules>
<properties>
<!-- Properties to enable jacoco code coverage analysis -->
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
<configuration>
<!-- Where to put jacoco coverage report -->
<destFile>C:/Userdata/product/GIT/Team/coverage/product1/jacoco/12.exec</destFile>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<build>
<plugins>
<!-- Use of Tycho -->
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<includes>
<include>**/Tests*.java,**/*Tests.java,**/*TestCase.java,**/Test*.java,**/*Test.java</include>
</includes>
<argLine>${argLine}</argLine>
<useUIHarness>true</useUIHarness>
<!-- Kill test JVM if tests take more than 1 minute to finish -->
<forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<!-- Configuration of target platforms -->
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<pomDependencies>consider</pomDependencies>
<resolver>p2</resolver>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<!-- workaround for TYCHO-349 or TYCHO-313 -->
<strictVersions>false</strictVersions>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
I got the problem source.
The culprit is <argLine> parameter in tycho-surefire-plugin configuration.
If this param is present, jacoco file is not generated. I removed it and now .exec file is generated.
More info found at tycho-surefire argLine causes no jacaco.exec