mvn release:perform fails in java 8 - added javadoc plugin - java

I'm having trouble running release:perform with Java 8 and maven 3.0.5. I get an error when the Javadoc is generated. I have added the javadoc plugin:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <goals>
                <goal>jar</goal>
            </goals>
<configuration>
         <additionalparam>-Xdoclint:none</additionalparam>
     </configuration>
        </execution>
    </executions>
</plugin>
The strange thing is that it works fine when I run 'mvn javadoc:javadoc' or 'mvn javadoc:jar'. Does anyone have a fix for this?
I'm getting this error after everything is generated:
Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.3:jar (attach-javadocs) on project sdm: MavenReportException: Error while generating Javadoc:
[INFO] [ERROR] C:\dir...\JavaClass.java:50: error: self-closing element not allowed
[INFO] [ERROR] * <p/>
[INFO] [ERROR] ^
[INFO] [ERROR]
[INFO] [ERROR] Command line was: "C:\Program Files\Java\jdk1.8.0_60\jre\..\bin\javadoc.exe" #options #packages
[INFO] [ERROR]
[INFO] [ERROR] Refer to the generated Javadoc files in 'C:\dir.....\' dir.

Try disabling doc linting completely for java 8:
<profile>
<id>disable-javadoc-doclint</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
Found it here: https://issues.shibboleth.net/jira/browse/JPAR-73

Unfortunately; I cannot tell you with the provided information why "-Xdoclint:none" isn't respected by the release plugin.
But a "simple" fix might just be to remove the argument altogether and actually fix the Javadoc issues the compiler reports (such as the self-closing elements which are not allowed).

Related

Another Maven "Source option 6 is no longer supported. Use 7 or later."

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.:)

Why would Maven enforcer restrict to Java 1.6?

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.

maven-release-plugin [ERROR] fatal: pathspec '' did not match any files

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>

java.lang.OutOfMemoryError: Java heap space in Maven

When I run maven test, java.lang.OutOfMemoryError happens. I googled it for solutions and have tried to export MAVEN_OPTS=-Xmx1024m, but it did not work.
Anyone know other solutions for this problem? I am using maven 3.0
Paste the error message here when run mvn test -e
Failed tests:
warning(junit.framework.TestSuite$1)
testDefaultPigJob_1(com.snda.dw.pig.impl.DefaultPigJobLocalTest)
testDefaultPigJob_2(com.snda.dw.pig.impl.DefaultPigJobLocalTest)
Tests run: 11, Failures: 3, Errors: 0, Skipped: 0
10/11/01 13:37:18 INFO executionengine.HExecutionEngine: Connecting to hadoop fi
le system at: file:///
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.063s
[INFO] Finished at: Mon Nov 01 13:37:18 PDT 2010
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
5:test (default-test) on project dw.pig: There are test failures.
[ERROR]
[ERROR] Please refer to E:\Code\Java\workspace\dw.pig\target\surefire-reports fo
r the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-surefire-plugin:2.5:test (default-test) on project
dw.pig: There are test failures.
Please refer to E:\Code\Java\workspace\dw.pig\target\surefire-reports for the in
dividual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:199)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:140)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures
.
Please refer to E:\Code\Java\workspace\dw.pig\target\surefire-reports for the in
dividual test results.
at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugi
n.java:629)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:195)
... 19 more
[ERROR]
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
When I run maven test, java.lang.OutOfMemoryError happens. I google it for solutions and have tried to export MAVEN_OPTS=-Xmx1024m, but it did not work.
Setting the Xmx options using MAVEN_OPTS does work, it does configure the JVM used to start Maven. That being said, the maven-surefire-plugin forks a new JVM by default, and your MAVEN_OPTS are thus not passed.
To configure the sizing of the JVM used by the maven-surefire-plugin, you would either have to:
change the forkMode to never (which is be a not so good idea because Maven won't be isolated from the test) ~or~
use the argLine parameter (the right way):
In the later case, something like this:
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
But I have to say that I tend to agree with Stephen here, there is very likely something wrong with one of your test and I'm not sure that giving more memory is the right solution to "solve" (hide?) your problem.
References
Maven 2 Surefire Plugin
Classloading and Forking in Maven Surefire
For those new to Maven (like me) here is the whole config that goes in the build section of your pom. Cheers.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
</build>
The chances are that the problem is in one of the unit tests that you've asked Maven to run.
As such, fiddling with the heap size is the wrong approach. Instead, you should be looking at the unit test that has caused the OOME, and trying to figure out if it is the fault of the unit test or the code that it is testing.
Start by looking at the stack trace. If there isn't one, run mvn ... test again with the -e option.
To temporarily work around this problem, I found the following to be the quickest way:
export JAVA_TOOL_OPTIONS="-Xmx1024m -Xms1024m"
I have solved this problem on my side by 2 ways:
Adding this configuration in pom.xml
<configuration><argLine>-Xmx1024m</argLine></configuration>
Switch to used JDK 1.7 instead of 1.6
As mentioned in the top answers, as Surefire is creating a new JVM to run your tests, you want to pass that -Xmx1024m to the new JVM instead of the JVM where you start mvn test.
Just wanted to add that you can do that in your command like
mvn test -DargLine="-Xmx1024m"
It has equivalent effect with adding the JVM option to the Surefire plugin's configuration in pom.xml:
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
In order to resolve java.lang.OutOfMemoryError: Java heap space in Maven, try to configure below configuration in pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<argLine>-XX:MaxPermSize=500M</argLine>
</configuration>
</plugin>
Not only heap memory. also increase perm size to resolve that exception in maven use these variables in environment variable.
variable name: MAVEN_OPTS
variable value: -Xmx512m -XX:MaxPermSize=256m
Example :
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=500m"

IllegalAccessError when calling ant script from maven-antrun-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.

Categories