I have a new error in my project that is in the pom.xml file. How can I fix it?
The error below is
shown in IntelliJ idea:
Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found
Plugin 'org.apache.maven.plugins:maven-compiler-plugin:' not found
Plugin 'org.apache.maven.plugins:maven-compiler-plugin:' not found
Only add the version.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
</plugin>
<version>${project.parent.version}</version>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
Now its working.
so I want to exclude one jar file from a third party war dependency due to cve issues.
I tried a lot of ways like overlay exclude, but it did not help.
Basically, i just want maven to remove that jar transitive dependency in the war file.
Here is my current code:
<dependencies>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr</artifactId>
<version>4.10.3</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<overlays>
<overlay>
<groupId>org.apache.solr</groupId>
<artifactId>solr</artifactId>
<excludes>
<exclude>WEB-INF/lib/commons-fileupload-1.2.1.jar</exclude>
</excludes>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
But when I check the solr war file, the commons-fileupload-1.2.1.jar is still there. I am kind of lost now.
I have a project (Spring Boot application), in which I mix Java and Groovy.
I can compile and run the project without problems inside IntelliJ Idea.
But I can't compile it with Maven.
Java 12 works fine, but when switching to 13 version it shows me next errors:
Example of POM.xml configuration:
<properties>
<java.version>13</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<javax.version>1.5.4</javax.version>
<groovy.version>2.5.8</groovy.version>
<lombok.version>1.18.10</lombok.version>
....
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>{java.version}</source>
<target>{java.version}</target>
<verbose>true</verbose>
<fork>true</fork>
<compilerArguments>
<javaAgentClass>lombok.launch.Agent</javaAgentClass>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.6.0-03</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>${groovy.version}-01</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
Does anyone know which compiler/plugin compiles java and groovy code with the java 13 version?
Java 13 support starts in groovy-eclipse-batch 2.5.8-03, which is based upon Eclipse 4.14. https://www.eclipse.org/eclipse/news/4.13/jdt.php#Java_13
You are using 2.5.8-01. At this time, Groovy 2.5.10 is the latest release and groovy-eclipse-batch:2.5.10-01 matches that. And both offer support for Java 13.
Assume we have maven multimodule project "Foo":
Foo
|-web-module-war
|-dependency-jar
There are two profiles defined for moduleC:
<profile>
<id>poll-some-external-service</id>
<properties>
<dependency-jar.poll.configured>true</dependency-jar.poll.configured>
</properties>
</profile>
<profile>
<id>produce-some-product</id>
<properties>
<dependency-jar.poll.configured>false</dependency-jar.poll.configured>
</properties>
</profile>
Now we run two builds:
mvn clean package -P poll-some-external-service
mvn clean package -P produce-some-product
First build produce following artifacts:
web-module-war-1.0.0-poll.war
dependency-jar-1.0.0-poll.war
Second build produce following artifacts:
web-module-war-1.0.0-produce.war
dependency-jar-1.0.0-produce.war
This means that war file contains web application which works in a different way based on selected profile.
Naming is based on the following configuration in the parent pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<jarName>${project.build.finalName}${foo.build.info}</jarName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warName>${project.build.finalName}${foo.build.info}</warName>
</configuration>
</plugin>
How can I deploy these artifacts into Nexus? -poll/-produce part is stripped during deployment. This means we have two different applications of the same version but we can deploy only one of them
Thanks
Instead of changing the name use a classifier
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<classifier>poll</classifier>
</configuration>
</plugin>
Your profile for the pom should look similar to the following example. Note that you have to change the dependencies by using the profile too.
<profile>
<id>poll</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<classifier>poll</classifier>
</configuration>
</plugin>
</plugins>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>dependency-jar</artifactId>
<classifier>poll</classifier>
</dependency>
</dependencies>
</build>
</profile>
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>