When I run mvn test on my project, I get a JDK version error.
Here's the output:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< net.rorynolan:Detrendr >-----------------------
[INFO] Building Detrendr 0.0.0.9003-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-rules) # Detrendr ---
[INFO] Adding ignorable dependency: null:jcodings:null
[INFO] Adding ignore: org/jcodings/*
[INFO] Adding ignorable dependency: null:jnr-constants:null
[INFO] Adding ignore: com/kenai/constantine/*
...
[INFO] Adding ignorable dependency: com.sun:tools:null
[INFO] Adding ignore: *
[INFO] Restricted to JDK 1.6 yet org.junit.platform:junit-platform-commons:jar:1.3.1:test contains org/junit/platform/commons/JUnitException.class targeted to JDK 1.8
[INFO] Restricted to JDK 1.6 yet org.junit.jupiter:junit-jupiter-api:jar:5.3.1:test contains org/junit/jupiter/api/AssertArrayEquals.class targeted to JDK 1.8
[INFO] Restricted to JDK 1.6 yet org.junit.jupiter:junit-jupiter-engine:jar:5.3.1:test contains org/junit/jupiter/engine/Constants.class targeted to JDK 1.8
[INFO] Restricted to JDK 1.6 yet org.junit.platform:junit-platform-engine:jar:1.3.1:test contains org/junit/platform/engine/TestDescriptor.class targeted to JDK 1.8
[WARNING] Rule 5: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message:
Found Banned Dependency: org.junit.platform:junit-platform-commons:jar:1.3.1
Found Banned Dependency: org.junit.jupiter:junit-jupiter-api:jar:5.3.1
Found Banned Dependency: org.junit.jupiter:junit-jupiter-engine:jar:5.3.1
Found Banned Dependency: org.junit.platform:junit-platform-engine:jar:1.3.1
Use 'mvn dependency:tree' to locate the source of the banned dependencies.
[INFO] ------------------------------------------------------------------------
...
[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
My pom.xml is at https://github.com/rorynolan/ij_detrendr/blob/master/pom.xml.
There's a clue in mvn help:effective-pom
where I can see
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
...
<rules>
...
<enforceBytecodeVersion>
<maxJdkVersion>1.6</maxJdkVersion>
<excludes>
<exclude>com.headius:invokebinder</exclude>
<exclude>com.sun:tools</exclude>
</excludes>
</enforceBytecodeVersion>
<banCircularDependencies />
</rules>
</configuration>
</plugin>
But that's all I've got. I've tried adding the maven enforcer plugin explicitly to my own pom.xml but to no avail.
Your project pom is parented by: net.imagej:pom-imagej:13.2.0 which is parented by org.scijava:pom-scijava:8.4.0 which contains the following excerpts relating to Java version:
<scijava.jvm.version>1.6</scijava.jvm.version>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<!-- Require the Java 6 platform. -->
<configuration>
<source>${scijava.jvm.version}</source>
<target>${scijava.jvm.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
...
<enforceBytecodeVersion>
<maxJdkVersion>${scijava.jvm.version}</maxJdkVersion>
...
</enforceBytecodeVersion>
</plugin>
So, the enforcer rule and its insistence on Java 1.6 is being inherited via your project's parentage.
This restriction to Java 1.6 conflicts with the JUnit5 libraries which were compiled to Java 1.8.
You could perhaps overide the enforcer plugin in your own POM (see references to combine.self="override" in the Maven docs) but the fact that your module's grandparent (org.scijava:pom-scijava:8.4.0) explicitly states that it expects to run on Java 1.6 strongly suggests that any such override will cause issues.
I think the wiser course would be one of the following:
Downgrade from Junit5 to a version of Junit4 which is compatible with Java 1.6
Upgrade the version of your parent (net.imagej:pom-imagej:13.2.0) to one which is compatible with Java 8, note: net.imagej:pom-imagej:13.2.0 is 3 years old so you might find that upgrading to the latest version makes this problem disappear.
Related
I see lots of answers to this question but they don't work for me. I installed Visual Studio Code, latest version of Java and Maven on my PC and I was able to successfully build my application with Maven on the PC. I then went through the same steps on my Mac and I get this error.
Fresh versions of Macos, Visual Studio Code, Maven and Java. Like all the others have said, I added these lines to the properties section of my pom.xml file:
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Still get the same error. Here is the relevant output from the mvn build:
alberts-mbp:com.versabuilt.rushmore.process albertyoungwerth$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ---------< com.versabuilt.rushmore.process:VersaBuiltProcess >----------
[INFO] Building VersaBuilt Process 0.2.18
[INFO] -------------------------------[ bundle ]-------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # VersaBuiltProcess ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) # VersaBuiltProcess ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 10 source files to /Users/albertyoungwerth/rushmore/com.versabuilt.rushmore.process/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 6 is no longer supported. Use 7 or later.
[ERROR] Target option 6 is no longer supported. Use 7 or later.
[INFO] 2 errors
I have also restarted Visual Studio Code to no avail.
The last build system I used was called make, so it's been a while since I debugged a build process. I don't remember make dumping 62Kb of debug output either...
Anywho, searching for the keyword "source" (clue being that was one of the tags I was supposed to add) got me to this in the maven debug output:
[DEBUG] (f) source = 1.6
Ahaaa! the source compiler version had not changed like I asked it to with the edit in my original question! I'll bet the maven folks changed the location of the xml tag! Sure enough, searching for 1.6 in the pom.xml file I find this:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
I changed the source and target tag values to 1.8 and it worked! I also tried deleting the source and target tags in the build plugins scope and left in the maven.compiler.source/target values set to 1.8 and that also worked.
So moral of the story, be careful of extra source or target tags in your pom.xml file!
Actually, I too faced the above error message, after adding this to property file, Error got resolved. :)
property need to be added in pom.xml
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
I corrected this problem by matching the jdk between my IDE and the pom.xml file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Sometimes changing from Kotlin to java or inverted.
You can also change or java version to a higher one.
At least that worked for me.
Changing maven compiler version in pom file solved my issue.
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target>
go to your project properties and go to sources.
then in Source/binary format it will be JDK 5 or 6 etc.
but click and make it the higher version.
you are done.:)
We’re building Java servlet apps using eclipse and maven which run in the Google Cloud Platform.
We are starting to look at integrating OpenClover into our builds to provide test coverage and code complexity statistics.
Some of our apps have dependencies on Google libraries, such as com.google.cloud.spanner.Statement.Builder.
When we try and run clover from the command line against these servlets we see the following errors:
[INFO] Building auditio 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # auditio ---
[INFO]
[INFO] --- clover-maven-plugin:4.3.0:setup (default-cli) # auditio ---
[INFO] OpenClover Version 4.3.0, built on August 03 2018 (build-1010)
[INFO] Creating new database at 'C:\.......\service\auditio\target\clover\clover.db'.
[INFO] Processing files at 1.8 source level.
[INFO] C:\...........\service\auditio\AuditIoSpanner.java:54:5:unexp
ected token: builder
[INFO] Instrumentation error
com.atlassian.clover.api.CloverException: C:\...............\service\auditio\src\main\java\com\mandm\service\aud
itio\AuditIoSpanner.java:54:5:unexpected token: builder
at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:159)
at com.atlassian.clover.CloverInstr.execute(CloverInstr.java:76)
at com.atlassian.clover.CloverInstr.mainImpl(CloverInstr.java:54)
[ERROR] Failed to execute goal org.openclover:clover-maven-plugin:4.3.0:setup (default-cli) on project auditio: Clover has fa
iled to instrument the source files in the [C:\........service\auditio\target\clover\src-instrumented] d
irectory -> [Help 1]
This is when running the following command:
mvn clean clover:setup test clover:aggregate clover:clover check
With the following in our pom.xml
<plugin>
<groupId>org.openclover</groupId>
<artifactId>clover-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<targetPercentage>75%</targetPercentage>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>instrument</goal>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
We’re running JDK 1.8.
While we can exclude the offending class files that contain these references to get the clover coverage to work, that isn’t ideal.
Servlets that do not have these specific references will run clover just fine.
Can anyone advise why this might be occurring and if there is a known resolution?
Thanks in advance.
After reaching out to OpenClover support they have confirmed that this is caused by a bug in their latest (4.3.0) release as can be seen here - https://bitbucket.org/openclover/clover/issues/72
- and will be resolved in a patch.
I'm trying to do a release of my OSS library, but I keep running in to a strange issue with the maven-release-plugin. This used to work fine. I've probably updated either Maven or Git but I can't seem to find the right combination to get things working again for the release.
Has anyone run into this issue, and does anyone know of a solution? I'm using the Maven Shade Plugin (which is what is creating the dependency-reduced-pom.xml files in the build.)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:27 min
[INFO] Finished at: 2015-11-04T08:23:07-05:00
[INFO] Final Memory: 111M/1039M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:prepare (default-cli) on project rewrite-parent: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-add command failed.
[ERROR] Command output:
[ERROR] fatal: pathspec 'config-prettyfaces/dependency-reduced-pom.xml' did not match any files
[ERROR] -> [Help 1]
The dependency-reduced-pom.xml, as I understand it, is a temporary file used while merging dependencies into an uber-jar, and should not be committed, so I'm confused why maven is trying to add this file at all.
Thanks for any help.
I figured it out, at least a workaround:
Using 'checkModificationExcludes" configuration option of the maven-release-plugin to exclude the dependency-reduced-pom.xml seems to work around the issue, though I'm not sure this is exactly what the property was intended for (the documentation is unclear):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<checkModificationExcludes>
<checkModificationExclude>dependency-reduced-pom.xml</checkModificationExclude>
</checkModificationExcludes>
</configuration>
</plugin>
I just updated Maven from 2.0.9 to 2.2.1 and I'm getting the following exception when running a maven build:
INFO] [antrun:run {execution: precompile-jsp}]
[INFO] Executing tasks
default:
jspc:
[mkdir] Created dir: C:\builds\trunk\webapps\vyre_portlets\WEB-INF\jsp_src
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An Ant BuildException has occured: The following error occurred while executing this line:
C:\unify\trunk\portlets\build-jsps.xml:87: The following error occurred while executing this line:
C:\unify\trunk\portlets\build-jsps.xml:7: java.lang.IllegalAccessError: tried to access method org.apache.tools.ant.launch.Locator.decodeUri(Ljava/lang/String;)Ljava/lang/String; from class org.apache.tools.ant.AntClassLoader
The build-jsps.xml ant script runs the org.apache.jasper.JspC task to precompile JSP in the a webapp that maven is building. This was working fine with Maven 2.0.9.
Google gives a bunch of people asking similar questions, but no answers. Has anyone run into this and knows how to resolve this? Or even just why I'm getting the IllegalAccessError?
try to set ANT dependency for "maven-antrun-plugin" explicitly.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
....
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
</plugin>
Note that there are multiple places where you can find ANT in Maven's public repository:
<groupId>org.apache.ant</groupId>
<groupId>ant</groupId>
(2) is the old one so use (1) instead
In Maven 2.2.x, the versions of many of the plugins have been updated, if you run the build with -X, you'll see what version of the antrun-plugin has been used. If these are different versions, it may be using a different version of org.apache.tools.ant.launch.Locator. Looking at the change history for Locator, the decodeUri method was introduced in Ant 1.7 and has been tweaked a few times, though nothing that would obvioulsy cause the problem.
Can you post a minimal pom and ant configuration that shows the error? this would help diagnose the problem.
I cannot import a maven project with WTP features enabled.
I have already tried:
mvn -Dwtpversion=R7 eclipse:eclipse
When I did the import, the WTP features are not enabled.
How do I import with the features enabled?
Does the maven-eclipse-plugin generate the .wtpmodules file as expected? This is what I get when running the same command on a war project:
$ mvn -Dwtpversion=R7 eclipse:eclipse
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-eclipse-plugin-wtp-testcase
[INFO] task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse {execution: default-cli}]
[INFO] Adding support for WTP version R7.
[INFO] Using Eclipse Workspace: null
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAINER
[INFO] Not writing settings - defaults suffice
[INFO] Wrote Eclipse project for "maven-eclipse-plugin-wtp-testcase" to /home/pascal/Projects/maven-eclipse-plugin-wtp-testcase.
[INFO]
Javadoc for some artifacts is not available.
Please run the same goal with the -DdownloadJavadocs=true parameter in order to check remote repositories for javadoc.
List of artifacts without a javadoc archive:
o junit:junit:3.8.1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Tue Oct 27 22:49:17 CET 2009
[INFO] Final Memory: 9M/79M
[INFO] ------------------------------------------------------------------------
$ ls -a
. .. .classpath pom.xml .project src .wtpmodules
$ cat .wtpmodules
<project-modules id="moduleCoreId">
<wb-module deploy-name="maven-eclipse-plugin-wtp-testcase">
<module-type module-type-id="jst.web">
<version>2.4</version>
<property name="context-root" value="maven-eclipse-plugin-wtp-testcase"/>
</module-type>
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
</wb-module>
$
On my environment, the eclipse plugin seems seems to be working fine.
That said, WTP R7 (0.7) is quite old (it was released in July 2005) and may not be the right version for your configuration. According to the Web Tools Platform downloads page, WTP 0.7 and WTP 1.0 goes with Eclipse 3.1, WTP 1.5 goes with Eclipse 3.2, WTP 2.0 goes with Eclipse 3.3, WTP 2.1 and WTP 3.0 goes with Eclipse 3.4, WTP 3.1 goes with Eclipse 3.5.
So the question is: what versions of Eclipse and of the WTP are you running?
The plugin actually can create WTP R7, 1.0, 1.5 and 2.0 configuration files as mentioned on the WTP Support page (2.0 is currently missing in the documentation of the wtpversion optional parameter but this is a documentation bug, see MECLIPSE-434). I've successfully imported a generated WTP 2.0 project in Eclipse 3.5.1 + WTP 3.1 so using 2.0 should be ok for recent versions of Eclipse (regardless of MECLIPSE-559).
Note: If you don't want to pass the wtpversion on the command line, you can set it in the maven-eclipse-plugin configuration in your pom.xml like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpversion>2.0</wtpversion>
...
</configuration>
</plugin>
Don't forget to run a
mvn eclipse:clean eclipse:eclipse
To remove the previously created eclipse wtp configuration files