i tried build on jenkins simple project with maven , but i getting this error and i don't inderstand what's the issue
enter code here
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error: Source option 6 is no longer supported. Use 7 or later.
[ERROR] error: Target option 6 is no longer supported. Use 7 or later.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-
compile) on project server: Compilation failure: Compilation failure:
As the error clearly states maven-compiler-plugin should be configured with java 7 or higher version.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Also update maven-compiler-plugin as 2.3.2 is really old. check this for further explanation Maven Compilation Error: (use -source 7 or higher to enable diamond operator)
You can solve it in 3 ways
Upgrade to JDK7 or JDK8 (meh)
Use maven-compiler-plugin version or later, because
Indicate to the maven-compiler-plugin to use source level 7 and target 7
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
or
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
Related
I am migrating my code from Java 1.8 to Java 11. I have done the below change in my pom.xml
From:
<java.version>1.8</java.version>
To:
<java.version>11</java.version>
Also changed the source and target in maven compiler as per below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
When I execute the command maven install I get the below error:
[ERROR] Failed to execute goal on project store: Could not resolve dependencies for project. Could not find artifact jdk.tools:jdk.tools:jar:1.7 at specified path C:\Program Files\Java\jdk-11.0.12/../lib/tools.jar -> [Help 1]
How do I solve this error? Please help
sonarQube9.0.1 CE(Java 11 ) + pgsql (docker install) 。 my project is Java 8
when i excute mvn sonar:sonar,my project failed
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:3.9.0.2155
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/D:/project/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.0.2155/sonar-maven-plugin-3.9.0.2155.jar
[ERROR] urls[1] = file:/D:/project/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
by the way, sonarqube9 needs java 11 means my project also needs java 11?
You can use Java 11 compiler to produce Java 8 code. The configuration could be set on the maven-compiler-plugin, you can see an example below:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${jdk.console.version}</release>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
Where ${jdk.console.version} would be 1.8 in case you want compile to be executed in a JRE 8
Question about maven PMD plugin.
I used to have maven pod plugin version 3.12.0
Very happy with this plugin, it was configured that way, everything was working fine.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.12.0</version>
<configuration>
<targetDirectory>.out/reports/pmd</targetDirectory>
<outputDirectory>target/reports/pmd</outputDirectory>
</configuration>
</plugin>
However, I wanted to upgrade to the newest version 3.13.0 and I am now facing this issue.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<targetDirectory>.out/reports/pmd</targetDirectory>
<outputDirectory>target/reports/pmd</outputDirectory>
</configuration>
</plugin>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:3.13.0:pmd (default-cli) on project my-project: Execution default-cli of goal org.apache.maven.plugins:maven-pmd-plugin:3.13.0:pmd failed: org.apache.maven.reporting.MavenReportException: /workspace/my-project/.out/reports/pmd/pmd.xml (No such file or directory) -> [Help 1]
This is literally a one character change. The 3.12 version is working perfectly fine, while with 3.13.0, it is failing 100% reproducible.
May I ask what is the issue please?
This is now fixed with version 3.14.0 of the same plugin by PMD team.
I code Java 7 on Java 8 JDK
When I run
mvn clean install
it show error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project foo: Compilation failure: Compilation failure:
[ERROR] /E:/bar/XmlUtils.java:[9,44] package com.sun.xml.internal.bind.marshaller does not exist
[ERROR] /E:/bar/XmlUtils.java:[11,34] cannot find symbol
[ERROR] symbol: class CharacterEscapeHandler
[ERROR] /E:/.../FooServiceImpl.java:[106,44] package com.sun.xml.internal.bind.marshall
This is line of code make error
CharacterEscapeHandler.class.getName()
Maven can't find
import com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler;
Maven can't find CharacterEscapeHandle. How to fix it?
but when I build, package, run by Eclipse Neon, no problem. How to fix it?
Normally you should not use any code from package com.sun.xml.internal. And this fails intentionally. Here are more details: https://bugs.java.com/bugdatabase/view_bug.do;jsessionid=1711ee4eae3ff10565fc7a212018?bug_id=6778491
This is temporary solution
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>rt.jar</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<fork>true</fork>
<compilerArgument>-XDignore.symbol.file</compilerArgument>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Maven builds success.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
maven: (use -source 5 or higher to enable static import declarations)
What do I need to do to get around this error in Maven (there's more, I just copied the top).
A key message seems to be:
could not parse error message: (use -source 5 or higher to enable
annotations)
but I tried adding -source 5 to the command and it didn't recognize it. Do I need to edit a configuration file somewhere to state a Java version to use or something along those lines?
Here's the error:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
C:\SVN-atx-Ingestion\branches\atx-ingestion\src\main\java\com\somecompany\eikon\atx\ingestion\database\atxAtomickosXaDataSource.java:[115,4] error: annotations are not supported in -source 1.3
could not parse error message: (use -source 5 or higher to enable annotations)
C:\SVN-atx-Ingestion\branches\atx-ingestion\src\main\java\com\somecompany\eikon\atx\ingestion\database\atxAtomickosNonXaDataSource.java:47: error: annotations are not supported in -source 1.3
#Override
^
could not parse error message: (use -source 5 or higher to enable annotations)
C:\SVN-atx-Ingestion\branches\atx-ingestion\src\main\java\com\somecompany\eikon\atx\ingestion\database\XaDatabase.java:29: error: generics are not supported in -source 1.3
private final Map<String,atxAtomickosXaDataSource> map =
You need to do something like this I think:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
You need to add the flags as configurations in the pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
Reference Site