You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Holger Mense (Jira)" <ji...@apache.org> on 2022/11/30 15:21:00 UTC

[jira] [Commented] (MCOMPILER-512) Defining maven.compiler.release as empty string ends with NumberFormatException in testCompileMojo

    [ https://issues.apache.org/jira/browse/MCOMPILER-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17641384#comment-17641384 ] 

Holger Mense commented on MCOMPILER-512:
----------------------------------------

Root cause is that in {{TestCompilerMojo}} the content of parameter {{release}} is only checked to be not null before passing it to {{Integer.parseInt()}}.

However an empty should be valid - that case is also handled correctly by {{plexus-compiler}} when building the {{javac}} command line.

> Defining maven.compiler.release as empty string ends with NumberFormatException in testCompileMojo
> --------------------------------------------------------------------------------------------------
>
>                 Key: MCOMPILER-512
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-512
>             Project: Maven Compiler Plugin
>          Issue Type: Bug
>    Affects Versions: 3.10.1
>            Reporter: Holger Mense
>            Priority: Major
>         Attachments: showcase-1.zip
>
>
> When {{maven.compiler.release}} is set to an empty string, a {{NumberFormatException}} is thrown when trying to compile tests.
> See attached  [^showcase-1.zip]  for a minimal example. Calling {{mvn test}} in subdirectory {{HelloWorld/}}  produces the following:
> {noformat}
> [HelloWorld/] $ mvn clean test -e
> [INFO] Error stacktraces are turned on.
> [INFO] Scanning for projects...
> [INFO]
> [INFO] -------------------------< example:helloworld >-------------------------
> [INFO] Building helloworld 1.0.0-SNAPSHOT
> [INFO] --------------------------------[ jar ]---------------------------------
> [INFO]
> [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ helloworld ---
> [INFO] Deleting C:\DATA\temp\maven-compiler-issue\HelloWorld\target
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
> [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory C:\DATA\temp\maven-compiler-issue\HelloWorld\src\main\resources
> [INFO]
> [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ helloworld ---
> [INFO] Changes detected - recompiling the module!
> [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
> [INFO] Compiling 1 source file to C:\DATA\temp\maven-compiler-issue\HelloWorld\target\classes
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloworld ---
> [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory C:\DATA\temp\maven-compiler-issue\HelloWorld\src\test\resources
> [INFO]
> [INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ helloworld ---
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time:  0.690 s
> [INFO] Finished at: 2022-11-30T16:05:57+01:00
> [INFO] ------------------------------------------------------------------------
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile (default-testCompile) on project helloworld: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile failed: For input string: "" -> [Help 1]
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile (default-testCompile) on project helloworld: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile failed: For input string: ""
>     at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
>     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
>     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
>     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
>     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
>     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
>     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
>     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
>     at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
>     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke (Method.java:568)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
> Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile failed: For input string: ""
>     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
>     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
>     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
>     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
>     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
>     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
>     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
>     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
>     at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
>     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke (Method.java:568)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
> Caused by: java.lang.NumberFormatException: For input string: ""
>     at java.lang.NumberFormatException.forInputString (NumberFormatException.java:67)
>     at java.lang.Integer.parseInt (Integer.java:678)
>     at java.lang.Integer.valueOf (Integer.java:999)
>     at org.apache.maven.plugin.compiler.TestCompilerMojo.preparePaths (TestCompilerMojo.java:309)
>     at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:864)
>     at org.apache.maven.plugin.compiler.TestCompilerMojo.execute (TestCompilerMojo.java:183)
>     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
>     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
>     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
>     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
>     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
>     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
>     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
>     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
>     at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
>     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke (Method.java:568)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
> [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 read the following articles:
> [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)