Maven 3: Overlay is not a dependency of the project - java

I'm trying to test the overlay functionality of the maven-war-plugin. Basically I need to merge two war projects.
So I defined a war as dependency:
<dependency>
<groupId>my.group.id</groupId>
<artifactId>my-legacy-war-project</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
And then configured the overlay:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>my.group.id</groupId>
<artifactId>my-legacy-war-project</artifactId>
<targetPath>legacy</targetPath>
</overlay>
</overlays>
</configuration>
</plugin>
But Maven fails to build this project, complaining about this dependency:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-war-plugin:2.3:exploded (default) on
project my-project: overlay [ id my.group.id:my-legacy-war-project] is
not a dependency of the project. -> [Help 1]
The overlay is supposed to work with Maven 3.0.5? Why the build is complaining about a dependency that's declared?

Not sure why, but using id instead of groupId and artifactId in the overlay worked:
<configuration>
<overlays>
<overlay>
<id>my-legacy-war-project</id>
<targetPath>legacy</targetPath>
</overlay>
</overlays>
</configuration>

I had the same error, but possibly for a different reason, since you are bringing in a war dependency. In my case, I had a war dependency as one overlay, and a jar dependency as another. The build complained about the jar dependency:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project overlay: overlay [ id com.mycompany:launcher] is not a dependency of the project.
I fixed the error by adding a <type>jar</type> element to my jar overlay. According to the overlay documentation, the default value for type is war, and so the build correctly complained that I did not have a war artifact named launcher.
Here's the working pom for my overlay project:
<project>
<artifactId>overlay</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>app</artifactId>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>launcher</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>com.mycompany</groupId>
<artifactId>app</artifactId>
</overlay>
<overlay>
<groupId>com.mycompany</groupId>
<artifactId>launcher</artifactId>
<type>jar</type> <!-- THIS IS THE FIX -->
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>

I had the same problem with maven-war-plugin version 2.2 and abuse of duplicate plugin declaration. After unifying them and using Sergio Michels suggestion, now it works fine using version 2.3 of maven-war-plugin.
Before changing:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>'**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**'</dependentWarExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>my-snapshot</warName>
<overlay>
<overlay>
<id>my-webapp-common</id>
<groupId>xyz.mycompany</groupId>
<artifactId>my-webapp-common</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
After applying changes:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>my-snapshot</warName>
<overlays>
<overlay>
<overlay>
<id>my-webapp-common</id>
<targetPath>legacy</targetPath>
</overlay>
</overlays>
<dependentWarExcludes>'**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**'</dependentWarExcludes>
</configuration>
</plugin>

Expanding on the other answers. The problem is to get overlay to use the same id as dependency.
Using $ mvn dependency:list can show you the ID you need. For example:
[INFO] +- com.foo.bar.v2:api:jar:1.0:system
[INFO] \- com.foo.bar.v2:main-server:war:1.0:system
[INFO] \- com.foo.bar.v2:second-server:war:classes:1.0:system
Shows one jar and one war. Note: :jar vs :war is entirely controlled by whether you used <type>war</type> in your dependency. Similarly, :classes (or empty) is entirely controlled by whether you used <classifier>classes</classifier> in your dependency.
You need to get this in alignment with <overlay>. For com.foo.bar.v2:main-server:war:1.0:system listed above, this would be the overlay entry:
<overlay>
<id>com.foo.bar.v2:main-server:war:1.0</id>
<groupId>com.foo.bar.v2</groupId>
<artifactId>main-server</artifactId>
</overlay>
For com.foo.bar.v2:second-server:war:classes:1.0:system, this would be the correct entry:
<overlay>
<id>com.foo.bar.v2:main-server:war:1.0</id>
<groupId>com.foo.bar.v2</groupId>
<artifactId>main-server</artifactId>
<classifier>classes</classifier>
</overlay>

Related

How to add additional .jar to JRE System Library [JavaSE-1.6] in VSCode?

I have a Java applet project that some of the package unable to be recognized in VSCode.
It because the project doesn't import plugin.jar and I can't see it in JRE System Library [JavaSE-1.6].
I'm sure the plugin.jar exists in my C:\Program Files\Java\jdk1.6.0_43\jre\lib folder.
How can I add this plugin.jar to the list?
By the way, I'm using Maven and I have a pom.xml file. Here is it's content.
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<properties>
<project.build.sourceEncoding>big5</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<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>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</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>
</build>
</project>
The original answer failed to solve the problem, the updated answer is as follows:
Use the following command to add a local .jar package to the maven local repository.
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
After the addition is successful, modify the pom.xml file to add dependencies.
<dependencies>
<dependency>
<groupId>group-id</groupId>
<artifactId>artifact-id</artifactId>
<version>version</version>
</dependency>
</dependencies>
original answer
This class should be stored in the jrt-fs.jar under the Java folder. I have tried several versions of java (downloaded and installed from the official website), all of which include this file by default.
Even if you delete a jrt-fs.jar under a certain version, vscode will automatically reference jar files under other versions.
So I think a better solution is to use the Java version provided by the official website.
As far as the question you asked. You can add the .jar as follows:
Since your project is built by maven, you can see these two dependency managers in the JAVA PROJECTS panel:
Of course, you can't change the system library, so you can only add dependencies for maven,
Click the plus sign on the right side of Maven Dependencies,
type in the package name you want to add and search for it.
Choose a library to add it.
This modifies the following in your pom.xml file.
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
</dependency>
</dependencies>
If it's just a normal Java project, click the plus sign to the right of Referenced Libraries and add the jar in the file manager.

How do I get JaCoCo to work with Maven and JUnit 4.11?

I'm having trouble getting JaCoCo to work with Maven. I keep running into either
Skipping JaCoCo execution due to missing execution data file.
Or
The parameters 'rules' for goal org.jacoco:jacoco-maven-plugin:0.8.2:check are missing or invalid
I also can't seem to get JaCoCo to run with just mvn clean test instead I have to run mvn clean test jacoco:report or mvn clean test jacoco:check
I've tried a variety of methods of editing my POM file, such as adding configuration for destFile and dataFile, as well as the POM settings here: https://howtodoinjava.com/junit5/jacoco-test-coverage/ and here https://www.lambdatest.com/blog/reporting-code-coverage-using-maven-and-jacoco-plugin/ . Any help would be greatly appreciated. Below is my POM file
<?xml version="1.0" encoding="UTF-8"?>
<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.NAME.PROJECTNAME</groupId>
<artifactId>PROJECTNAME</artifactId>
<version>1.0-SNAPSHOT</version>
<name>PROJECTNAME</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.1</version>
</dependency>
</dependencies>
<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>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<configuration>
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</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>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>HelloFX</mainClass>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
This is because you are using <pluginManagement> tag, and <plugins> are put inside it.
As per the Maven documentation on <pluginManagement>,
pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one. However, this only configures plugins that are actually referenced within the plugins element in the children or in the current POM. The children have every right to override pluginManagement definitions.
In short, you will use <pluginManagement> in case of multi-module Maven project. Here is a bit more explanation in this answer.
I removed the <pluginManagement> tag from pom.xml and now the build is working and Jacoco report is getting generated.
-> mvn clean verify
...
[INFO] --- jacoco-maven-plugin:0.8.2:prepare-agent (default) # PROJECTNAME ---
[WARNING] The artifact xml-apis:xml-apis:jar:2.0.2 has been relocated to xml-apis:xml-apis:jar:1.0.b2
[INFO] argLine set to -javaagent:/home/codejournal/.m2/repository/org/jacoco/org.jacoco.agent/0.8.2/org.jacoco.agent-0.8.2-runtime.jar=destfile=/tmp/maven-jacoco/target/coverage-reports/jacoco-unit.exec
...
...
[INFO] --- jacoco-maven-plugin:0.8.2:report (report) # PROJECTNAME ---
[INFO] Loading execution data file /tmp/maven-jacoco/target/coverage-reports/jacoco-unit.exec
[INFO] Analyzed bundle 'PROJECTNAME' with 1 classes
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) # PROJECTNAME ---
[INFO] Building jar: /tmp/maven-jacoco/target/PROJECTNAME-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.141 s
[INFO] Finished at: 2022-04-24T02:18:30+05:30
[INFO] ------------------------------------------------------------------------
-> cat target/site/jacoco/jacoco.csv
GROUP,PACKAGE,CLASS,INSTRUCTION_MISSED,INSTRUCTION_COVERED,BRANCH_MISSED,BRANCH_COVERED,LINE_MISSED,LINE_COVERED,COMPLEXITY_MISSED,COMPLEXITY_COVERED,METHOD_MISSED,METHOD_COVERED
PROJECTNAME,io.codejournal.maven.jacoco,Hello,7,0,0,0,3,0,2,0,2,0

How can I execute a simple jar?

I'm trying to make a simple batch file with maven commands to execute the installation and execute the jar main class.
But the compile JAR does not have the dependencies and I get error
Exception in thread "main" java.lang.NoClassDefFoundError:
akka/actor/ActorSystem
This is my simple script
call mvn clean dependency:copy-dependencies
call mvn package
call cd target
call java -jar distributed-1.0.0.jar
pause
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>distributed</groupId>
<artifactId>distributed</artifactId>
<version>1.0.0</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.scala-lang/scala-library -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.5.16</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<outputDirectory>src/main/java/resources/lib
</outputDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source/>
<target/>
</configuration>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.ipca.distributed.Implementations</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
What do I need here??
I think the easiest solution to create a runnable jar is to use Maven Assembly Plugin, or Maven Shade Plugin, or One Jar Plugin or even Spring Boot Plugin ( it's not weird if it works ). You can find some more details on how to use each one here.
These plugins are doing exactly you are trying to do with the 2 combined plugins that you have ( maven-dependency-plugin and maven-jar-plugin ).

Maven shade plugin isn't placing dependency class files into jar

My Maven project uses an external library as a dependency, com.sk89q.intake:intake, which I'm trying to package into my jar via the maven-shade-plugin. When building the project, the resulting jar does not contain any of the class files of com.sk89q.intake:intake. During the build process, I get this message, but the build continues on and succeeds:
[INFO] --- maven-shade-plugin:2.4.2:shade (default) # EventManagerPlugin
[INFO] No artifact matching filter com.sk89q.intake:intake
Why is this happening? I'm able to download, access, and use the dependency in my project, so there shouldn't be anything wrong with naming of the artifact.
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>deletethis.eventmanager</groupId>
<artifactId>EventManagerPlugin</artifactId>
<version>1.0.0-beta1</version>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>maven.sk89q.com</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.intake</groupId>
<artifactId>intake</artifactId>
<version>4.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<manifestEntries>
<Built-By>deletethis</Built-By>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>com.sk89q.intake:intake</artifact>
<includes>
<include>com/sk89q/intake/**</include>
</includes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.sk89q.intake</pattern>
<shadedPattern>deletethis.eventmanager.lib.com.sk89q.intake</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
As you can see, I am including the com.sk89q.intake:intake artifact. I have looked through the maven-shade-plugin documentation and don't see what I'm doing wrong. The naming is consistent with everything I have found online; that is, groupId:artifactId.
I have also tried building without the <relocation> class relocation tags to see if they were interfering.
It may be useful to know that I'm using M2Eclipse and building with the clean install goals.
The problem is that your are declaring the com.sk89q.intake:intake dependency with the provided scope.
Provided dependency are expected to be provided by the container at runtime so the maven-shade-plugin will not add it to your shaded jar. As such, you need to remove the provided scope from the dependency declaration:
<dependency>
<groupId>com.sk89q.intake</groupId>
<artifactId>intake</artifactId>
<version>4.2-SNAPSHOT</version>
</dependency>
Relevant build log after this change:
[INFO] --- maven-shade-plugin:2.4.2:shade (default) # test ---
[INFO] Including com.sk89q.intake:intake:jar:4.2-SNAPSHOT in the shaded jar.
[INFO] Including com.google.guava:guava:jar:18.0 in the shaded jar.
[INFO] Including com.google.code.findbugs:jsr305:jar:3.0.0 in the shaded jar.

Error using checkstyle/google_checks.xml with maven-checkstyle-plugin

I am trying to use checkstyles google_checks.xml with maven-checkstyle-plugin. If I use the google_checks.xml with the latest checkstyle intelliJ plugin everything is correct but when I try configurating it via maven-checkstyle plugin I get this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check (default-cli) on project XX_XX_XX: Failed during checkstyle configuration: cannot initialize module TreeWalker - Unable to instantiate AvoidEscapedUnicodeCharacters:
Unable to instantiate AvoidEscapedUnicodeCharactersCheck
My pom.xml looks like this:
<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">
<properties>
[...]
<checkstyle.file.path>develop/checkstyle/google_checks.xml</checkstyle.file.path>
</properties>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.13</version>
<configuration>
<configLocation>${checkstyle.file.path}</configLocation>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation>${checkstyle.file.path}</configLocation>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
</plugins>
</reporting>
Do you guys have some suggestions about what could be wrong?
fixed this by updating the checkstyle-dependency manually to the latest stable version:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.13</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.latest.version}</version>
</dependency>
</dependencies>
<configuration>
<configLocation>${checkstyle.file.path}</configLocation>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
Maven checkstyle plugin uses checkstyle 5.7 (the first line of plugin description).
Checkstyle 5.7 does not have this check (see checks package on grepcode).
You need either to disable this check or to wait for official fix of MCHECKSTYLE-261.
I give a demo at
https://github.com/favoorr/Maven-Checkstyle-Multimodule-Use
Multi modules and use Google Chechstyle

Categories