jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
Maven 2.x Compiler Plugin
  • Maven 2.x Compiler Plugin
  • MCOMPILER-129

unable to pass in javac -J option

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 2.3.1
  • Fix Version/s: None
  • Labels:
    None
  • Environment:
    jdk 1.6
    maven 3.0-beta-1
  • Number of attachments :
    0

Description

because of MCOMPILER-109, l10n-ed javac warning messages will be regarded as error, so I want to pass user language configuration to javac, like this:

javac ... -J-Duser.language=en_us

this works well on pure javac command line, but when I configure this for maven-compiler-plugin:

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<fork>true</fork>
<source>1.5</source>
<target>1.5</target>
<compilerArgument>-J-Duser.language=en_us</compilerArgument>
</configuration>
</plugin>

I got:

[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile' with basic configurator -->
[DEBUG] (f) basedir = D:\workspace\test
[DEBUG] (f) buildDirectory = D:\workspace\test\target
[DEBUG] (f) classpathElements = [D:\workspace\test\target\classes]
[DEBUG] (f) compileSourceRoots = [D:\workspace\test\src\main\java]
[DEBUG] (f) compilerArgument = -J-Duser.language=en_us
[DEBUG] (f) compilerId = javac
[DEBUG] (f) debug = true
[DEBUG] (f) failOnError = true
[DEBUG] (f) fork = true
[DEBUG] (f) generatedSourcesDirectory = D:\workspace\test\target\generated-sources\annotations
[DEBUG] (f) optimize = false
[DEBUG] (f) outputDirectory = D:\workspace\test\target\classes
[DEBUG] (f) outputFileName = test-0.0.1-SNAPSHOT
[DEBUG] (f) projectArtifact = com.juvenxu:test:jar:0.0.1-SNAPSHOT
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@11d2572
[DEBUG] (f) showDeprecation = false
[DEBUG] (f) showWarnings = false
[DEBUG] (f) source = 1.5
[DEBUG] (f) staleMillis = 0
[DEBUG] (f) target = 1.5
[DEBUG] (f) verbose = false
[DEBUG] – end configuration –
[DEBUG] Using compiler 'javac'.
[DEBUG] Source directories: [D:\workspace\test\src\main\java]
[DEBUG] Classpath: [D:\workspace\test\target\classes]
[DEBUG] Output directory: D:\workspace\test\target\classes
[DEBUG] Classpath:
[DEBUG] D:\workspace\test\target\classes
[DEBUG] Source roots:
[DEBUG] D:\workspace\test\src\main\java
[DEBUG] Command line options:
[DEBUG] -d D:\workspace\test\target\classes -classpath D:\workspace\test\target\classes; -sourcepath D:\workspace\test\src\main\java; D:\workspace\test\src\main\java\com\juvenxu\test\Test.java -g -nowarn -target 1.5 -source 1.5 -J-Duser.language=en_us
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\workspace\test\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
javac: 无效的标志: -J-Duser.language=en_us
用法: javac <options> <source files>
-help 用于列出可能的选项

[INFO] 1error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.451s
[INFO] Finished at: Wed May 26 17:29:06 CST 2010
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (default-compile) on project test: Compilation failure
Failure executing javac, but could not parse the error:
javac: 无效的标志: -J-Duser.language=en_us
用法: javac <options> <source files>
-help 用于列出可能的选项
-> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (default-compile) on project test: Compilation failure
Failure executing javac, but could not parse the error:
javac: 无效的标志: -J-Duser.language=en_us
用法: javac <options> <source files>
-help 用于列出可能的选项

at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:581)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
Failure executing javac, but could not parse the error:
javac: 无效的标志: -J-Duser.language=en_us
用法: javac <options> <source files>
-help 用于列出可能的选项

at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
... 14 more
[ERROR]

Issue Links

depends upon

Bug - A problem which impairs or prevents the functions of the product. PLXCOMP-190 JavacCompiler puts custom runtime arguments (-J flags) in an argumentsfile instead of adding them to the executable

  • Critical - Crashes, loss of data, severe memory leak.
  • Open - The issue is open and ready for the assignee to start work on it.
is related to

Bug - A problem which impairs or prevents the functions of the product. MCOMPILER-109 JavacCompiler treat localized warning messages as errors

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Juven Xu added a comment - 29/Jun/10 9:41 AM

I initially wanted to try -J option as a workaround for MCOMPILER-109

Show
Juven Xu added a comment - 29/Jun/10 9:41 AM I initially wanted to try -J option as a workaround for MCOMPILER-109
Hide
Permalink
Robert Scholte added a comment - 27/Aug/11 4:21 PM - edited

One way to solve this is by using compilerArguments like this:

<compilerArguments>
  <J-Duser.language>en_us</J-Duser.language>
</compilerArguments>

This works because the plugin will prefix the key with a '-' if it's not there.

There real problem is caused by this piece of code:

if ( !StringUtils.isEmpty( effectiveCompilerArgument ) )
{
  cplrArgsCopy.put( effectiveCompilerArgument, null );
}

Here the whole line is set as the key without a specific value.
To solve this the line should be split into key-value pairs.
I´ve assigned this already issue to myself.

Show
Robert Scholte added a comment - 27/Aug/11 4:21 PM - edited One way to solve this is by using compilerArguments like this: <compilerArguments> <J-Duser.language> en_us </J-Duser.language> </compilerArguments> This works because the plugin will prefix the key with a ' - ' if it's not there. There real problem is caused by this piece of code: if ( !StringUtils.isEmpty( effectiveCompilerArgument ) ) { cplrArgsCopy.put( effectiveCompilerArgument, null ); } Here the whole line is set as the key without a specific value. To solve this the line should be split into key-value pairs. I´ve assigned this already issue to myself.
Hide
Permalink
Robert Scholte added a comment - 27/Aug/11 5:33 PM

I had to edit previous comment, because I made a typo in the configuration. Due to this it seemed to work, but it didn't.
The cplrArgsCopy which is passed to the Plexus Compiler separates the key and value with a space instead of a '='.
I've looked at its sourcecode and right now there's no way to specify which separator should be used.
So that brings us back to the original issue.

Show
Robert Scholte added a comment - 27/Aug/11 5:33 PM I had to edit previous comment, because I made a typo in the configuration. Due to this it seemed to work, but it didn't. The cplrArgsCopy which is passed to the Plexus Compiler separates the key and value with a space instead of a '='. I've looked at its sourcecode and right now there's no way to specify which separator should be used. So that brings us back to the original issue.
Hide
Permalink
Robert Scholte added a comment - 27/Aug/11 6:15 PM

We'll have to wait for a fix and a release of plexus-compiler.

Show
Robert Scholte added a comment - 27/Aug/11 6:15 PM We'll have to wait for a fix and a release of plexus-compiler.

People

  • Assignee:
    Robert Scholte
    Reporter:
    Juven Xu
Vote (2)
Watch (2)

Dates

  • Created:
    26/May/10 4:32 AM
    Updated:
    27/Aug/11 6:15 PM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.