I have cloned a git repo and am trying to build it locally, but getting the following error
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.850 s [INFO] Finished at:
2021-07-12T15:42:57+02:00 [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile
(default-compile) on project gtvg: Fatal error compiling: invalid
flag: --release -> [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/MojoExecutionException
I have java jdk 8 and 11 installed, currently using java 8
java -version
16:03:24
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
and maven
mvn -version
Apache Maven 3.6.3
the pom.xml is really large, so I will post the part which I assume is relevant
<properties>
<java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>
<project.build.sourceEncoding>US-ASCII</project.build.sourceEncoding>
<thymeleaf.version>3.0.12.RELEASE</thymeleaf.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.html</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
I had hoped (not sure if I am doing the right thing) changing from 3.8.1
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
to 3.6.3
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.3</version>
could solve my issues. But that doesn't work and end up getting another error
Cannot resolve plugin org.apache.maven.plugins:maven-compiler-plugin:3.6.3
How do i get it to build successfully? I am flexible regarding Java versions. I am allowed to use Java 8 - Java 12, but if possible no changes to the Maven version. It should stay as is 3.6.3
You could write one of both 8 or 1.8 into your java version property to declare Java 8. And using Java 8 you can not use maven.compiler.release which could be used only with Java 9+
<java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
I'm trying to do cargo:deployer-redeploy but keeps on getting this error:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.8.1:deployer-redeploy (default-cli) on project backend-server:
Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.8.1:deployer-redeploy failed: error submitting remote command: sun/misc/BASE64Encoder: sun.misc.BASE64Encoder -> [Help 1]
Here's the plugin I am using:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>glassfish4x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>${payara.username}</cargo.remote.username>
<cargo.remote.password>${payara.password}</cargo.remote.password>
<cargo.glassfish.admin.port>${payara.adminPort}</cargo.glassfish.admin.port>
<cargo.hostname>${payara.hostname}</cargo.hostname>
</properties>
</configuration>
</configuration>
<!-- provides JSR88 client API to deploy on Payara Server -->
<dependencies>
<dependency>
<groupId>org.glassfish.main.deployment</groupId>
<artifactId>deployment-client</artifactId>
<version>4.1.1</version>
</dependency>
</dependencies>
</plugin>
Check your Java version. I was getting this error until I found I was accidentally using Java 15. Switching back to Java 8 solved the issue.
I am trying to start with Spring-boot, Maven in Intellij
Please help me I am getting the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project spring-rest: Fatal error compiling: invalid flag: --release -> [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/MojoExecutionException
Process finished with exit code 1
My pom.xml is:
<?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>spring-rest</artifactId>
<version>3.1.3.RELEASE</version>
<packaging>war</packaging>
<name>spring-rest</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>8</release>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
</project>
In your pom.xml file, simply remove the tag <release>8</release> from your maven-compiler-plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<verbose>true</verbose>
</configuration>
</plugin>
This has to do with the version of JDK running on your system. As per the documentation for maven-compiler-plugin, the release flag is supported since 1.9, and thus has to be commented/removed from the POM if you are using prior (1.8 and below) versions of JDK.
Check Maven documentation for release tag for maven-compiler-plugin here
open terminal to check that Maven using correct version of Java
run: mvn -v
If you will see an old Java version, that might be the problem.
Being on Linux, I suggest removing Maven, e.g. using Fedora package manager dnf remove maven or check your PATH for maven.
Download one from here: https://maven.apache.org/download.cgi
Extract downloaded to your home path, e.g. ~/maven.
Add/Edit ~/maven/bin to your PATH
Reapply .bash_profile (or re-login)
Run mvn -v
Now you should see a correct Java version in the output
I faced this problem too, check your JAVA_HOME environment variable.
I was setting the value of release to 11 as I am using JAVA 11.
My System JAVA_HOME was set for java 8, After adding the JAVA_HOME user environment variable to the java 11 path this got resolved.
An alternative approach is to directly set the compiler flags inside your properties tag instead of using the <configuration> tag of the compiler plugin:
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<!-- Use the release flag only if you are using Java 9+ -->
<!-- <maven.compiler.release>8</maven.compiler.release> -->
<!-- verbose is useful for debugging purposes -->
<maven.compiler.verbose>true</maven.compiler.verbose>
</properties>
As stated in the official page:
https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
This is mostly because of the java version mismatch. Managing more than one java version for projects can be painful.
I am working simultaneously on projects asking for different versions of java and have been using jenv for switching the java versions.
More details here
I was getting this error with Java v8, then resolved the issue by updating to Java v11, updating JAVA_HOME, and updating my IntelliJ SDK settings to use the new jdk.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile (default-testCompile) on project selenium-for-beginners: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile failed: multiple points -> [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
When trying to do a Selenium maven beginner project if you are running into this trouble/issue. Please try to change the maven plugin in the pom.xml file. Use Plugin for "Compile Using the --release javac option (JDK 9+)". This should work.
Set the $MAVEN_HOME and JAVA_HOME in environment Properties
Check the maven version ( C:>mvn -version )
Check the Java Version
( C:>java -version )
Add the below code snip in pom.xml file and change the version number of maven
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version> // replace the maven version number
<configuration>
<source>1.8</source>
<target>1.8</target>
<verbose>true</verbose>
</configuration>
</plugin>
This configuration worked for me, for java 11. (IntelliJ version 2019.1)
java.version is 11, declared in the properties part of the pom.xml. Maven version should be 3.6 or higher.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<fork>false</fork>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<release>${java.version}</release>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
I'm trying to create a Maven POM which will pull in the correct version of alpn-boot when building the project and running the tests.
The whole thing works if I'm injecting the property from "outside" when running the build (e. g. via mvn -Dalpn-boot.version=8.1.8.v20160420 test or as an environment variable) but not when trying to interpolate it inside the POM using ${java.version}.
I've tried using properties-maven-plugin to accomplish this with the following settings in the pom.xml file (snippet):
<project>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${project.basedir}/alpn-boot/jdk-${java.version}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>${alpn-boot.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Contents of one of the properties files:
$ cat alpn-boot/jdk-1.8.0_92.properties
alpn-boot.version=8.1.8.v20160420
Basically the same problem with the gmaven-plugin:
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
alpnVersions = [ '1.8.0_92': '8.1.8.v20160420' ]
project.properties['alpn-boot.version'] = alpnVersions[System.getProperty('java.version')]
</source>
</configuration>
</execution>
</executions>
</plugin>
With both approaches I get the following error message:
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.mortbay.jetty.alpn:alpn-boot:jar must be a valid version but is '${alpn-boot.version}'. # org.example:my-project:[unknown-version], /path/to/pom.xml, line 132, column 22
#
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.example:my-project:1.0.0-rc3-SNAPSHOT (/path/to/pom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for org.mortbay.jetty.alpn:alpn-boot:jar must be a valid version but is '${alpn-boot.version}'. # org.example:my-project:[unknown-version], /path/to/pom.xml, line 132, column 22
[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/ProjectBuildingException
I ended up following the advice of #khmarbaise and add a Maven profile for each version of the JDK which needs to be supported:
<properties>
<!-- Default alpn-boot version. See <profiles> for specific profiles. -->
<alpn-boot.version>8.1.3.v20150130</alpn-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>${alpn-boot.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- Profiles for selecting the correct version of alpn-boot for each JDK.
see http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html for reference. -->
<profiles>
<profile>
<id>jdk-1.8.0</id>
<activation>
<jdk>1.8.0</jdk>
</activation>
<properties>
<alpn-boot.version>8.1.0.v20141016</alpn-boot.version>
</properties>
</profile>
<!-- Lots of profiles [...] -->
<profile>
<id>jdk-1.8.0_92</id>
<activation>
<jdk>1.8.0_92</jdk>
</activation>
<properties>
<alpn-boot.version>8.1.8.v20160420</alpn-boot.version>
</properties>
</profile>
</profiles>
I'm trying to make Maven call an ANT build for some legacy code. The ant build builds correctly through ant. However when I call it using the maven ant plugin, it fails with the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project CoreServices: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] C:\dev\projects\build\build.xml:158: The following error occurred while executing this line:
[ERROR] C:\dev\projects\build\build.xml:62: The following error occurred while executing this line:
[ERROR] C:\dev\projects\build\build.xml:33: The following error occurred while executing this line:
[ERROR] C:\dev\projects\ods\build.xml:41: Unable to find a javac compiler;
[ERROR] com.sun.tools.javac.Main is not on the classpath.
[ERROR] Perhaps JAVA_HOME does not point to the JDK.
[ERROR] It is currently set to "C:\bea\jdk150_11\jre"
My javac exists at C:\bea\jdk150_11\bin and this works for all other things. Im not sure where Maven is getting this version of JAVA_HOME. JAVA_HOME in windows environmental variables is set to C:\bea\jdk150_11\ as it should be.
The Maven code that I'm using to call the build.xml is
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<ant antfile="../build/build.xml" target="deliver" >
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
First thing: Why do you execute your ANT script in install phase and not in compile?
The second thing: Your problem may be caused by the fact that Maven executes JRE instead of JDK, despite the fact that your JAVA_HOME points to JDK. To fix this see you have to manually adjust dependencies for maven-antrun-plugin. This is just an example:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
<executions>
<execution>
<phase>compile</phase>
<configuration><target><ant/></target></configuration>
<goals><goal>run</goal></goals>
</execution>
</executions>
</plugin>