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>
Related
I have multimodule maven project I want to get aggregated surefire reports . I tried below approach but I dont see aggregated surefire report generated. I could see report generated for individual modules.
I have added below plugin configuration in indvidual Modules (packaging jar)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.22.0</version>
</dependency>
</dependencies>
<configuration>
<useManifestOnlyJar>false</useManifestOnlyJar>
<includes>
<include>**/*.java</include>
</includes>
</configuration>
</plugin>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<aggregate>true</aggregate>
<linkXRef>true</linkXRef>
</configuration>
</plugin>
</plugins>
</reporting>
And below in root level pom (packaging type pom)
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${version.plugin.surefire}</version>
<inherited>false</inherited>
<configuration>
<aggregate>true</aggregate>
<linkXRef>true</linkXRef>
</configuration>
</plugin>
</plugins>
</reporting>
Could some one please help where I am going wrong ?
Try with mvn surefire-report:report -Daggregate=true
Is there any sort of Maven plugin that allows me to copy the class files for a dependency into the target\classes folder for my project? Currently I have to manually open the jar file that has the dependencies extract the package that I need to copy over and then copy it into the target\class folder for my project.
I need a way to do those ideally within the pom.xml file but I haven't been able to find a solution that works. Any help would be appreciated, Thanks.
This sounds like a terrible idea. If you want to include unpacked dependencies into your project, use the maven assembly plugin or the maven shade plugin.
Use the maven-dependency-plugin. Here is an example of how you can extract the content of a dependency JAR:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
<destFileName>optional-new-name.jar</destFileName>
<includes>**/*.class,**/*.xml</includes>
<excludes>**/*test.class</excludes>
</artifactItem>
</artifactItems>
<includes>**/*.java</includes>
<excludes>**/*.properties</excludes>
<outputDirectory>${project.build.directory}/wars</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
below is the example to use of assembly pulgin and it works for me
below is the child pom plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<mainClass>my parent package statup class</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Parent pom plugin
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
</build>
I am adding pluginManagement to avoid
Failed to execute goal org.apache.openjpa:openjpa-maven-plugin:3.0.0:enhance (enhancer) on project Execution enhancer of goal org.apache.openjpa:openjpa-maven-plugin:3.0.0:enhance failed:
Error. but when I add pluginManagement it stops creating jar for my project.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.test.testApplication</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</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>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<includes>**/tablemodels/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<persistenceXmlFile>src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
If I remove pluginManagement from pom then Jar is getting created.
My guess is that you just wrapped your <plugins> tag in a <pluginManagement> tag, which does not do what you want. I suggest you read the documentation to understand the relationship between plugin and pluginManagement. See also another post on StackOverflow.
As to your underlying problem: I guess the error you mention is an Eclipse error. It is emitted by the m2e plugin which requires a connector for each maven plugin in your pom.
You can usually come up with a connector (if it is not found on the Eclipse Marketplace) by typing " m2e connector" into your favorite search engine.
In this case you might want to install this: https://github.com/beskow/openjpa-maven-connector
I have a maven build that is copying a bunch of jars that it should not be into WEB-INF/lib for my war project.
The jars do not show up in the output of mvn dependency:tree but mvn package puts these (among other) jars into the WEB-INF/lib directory of the generated war file:
maven-artifact, maven-artifcat-manager, maven-profile, maven-project, maven-settings...
Where are these coming from? What (other than dependency:tree) might show me what is causing these jars to be included? I have done a mvn clean and rebuild and same thing.
It seems that when I add this plugin I get the extra jars added:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<id>xmlbeans-generate-compile</id>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
<goal>xmlbeans-test</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<sourceGenerationDirectory>src/xmlbean/java</sourceGenerationDirectory>
<classGenerationDirectory>target/xmlbean/build</classGenerationDirectory>
<schemaDirectory>src/main/components</schemaDirectory>
</configuration>
</plugin>
</plugins>
The rest of the POM is just dependency stuff and this:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/tests</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.15</version>
</dependency>
</dependencies>
</plugin>
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>