[ https://jira.codehaus.org/browse/MCOMPILER-123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=319157#comment-319157 ]
Ulli Hafner edited comment on MCOMPILER-123 at 2/11/13 9:33 AM: ---------------------------------------------------------------- I'm using the following snippet (which works quite well). It reuses the configuration of the Eclipse settings folder: so your warnings in the build will be the same as in Eclipse. {code} <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <compilerId>eclipse</compilerId> <source>1.6</source> <target>1.6</target> <detail>true</detail> <debug>true</debug> <fork>true</fork> <compilerArguments> <properties>.settings/org.eclipse.jdt.core.prefs</properties> </compilerArguments> </configuration> <dependencies> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-compiler-eclipse</artifactId> <version>2.1</version> </dependency> </dependencies> </plugin> {code} was (Author: ulli): I'm using the following snippet (which works quite fine). It reuses the configuration of the Eclipse settings folder: so your warnings in the build will be the same as in Eclipse. {code} <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <compilerId>eclipse</compilerId> <source>1.6</source> <target>1.6</target> <detail>true</detail> <debug>true</debug> <fork>true</fork> <compilerArguments> <properties>.settings/org.eclipse.jdt.core.prefs</properties> </compilerArguments> </configuration> <dependencies> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-compiler-eclipse</artifactId> <version>2.1</version> </dependency> </dependencies> </plugin> {code} > No way to set compiler arguments/options for Eclipse compiler > ------------------------------------------------------------- > > Key: MCOMPILER-123 > URL: https://jira.codehaus.org/browse/MCOMPILER-123 > Project: Maven 2.x Compiler Plugin > Issue Type: Bug > Affects Versions: 2.2 > Reporter: Lóránt Pintér > > I have a problem with setting compiler options for the Eclipse compiler. I > tried to do the following: > {code:xml} > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-compiler-plugin</artifactId> > <version>2.2</version> > <configuration> > <compilerId>eclipse</compilerId> > <source>1.6</source> > <target>1.6</target> > <encoding>utf-8</encoding> > <compilerArguments> > > <org.eclipse.jdt.core.compiler.problem.missingSerialVersion>ignore</org.eclipse.jdt.core.compiler.problem.missingSerialVersion> > </compilerArguments> > </configuration> > <dependencies> > <dependency> > <groupId>org.codehaus.plexus</groupId> > <artifactId>plexus-compiler-eclipse</artifactId> > <version>1.8</version> > </dependency> > </dependencies> > </plugin> > {code} > It should be okay, as this is in EclipseJavaCompiler: > {code:java} > // compiler-specific extra options override anything else in the config > object... > Map extras = config.getCustomCompilerArguments(); > if ( extras != null && !extras.isEmpty() ) > { > settings.putAll( extras ); > } > // ... > // ---------------------------------------------------------------------- > // Compile! > // ---------------------------------------------------------------------- > CompilerOptions options = new CompilerOptions( settings ); > Compiler compiler = new Compiler( env, policy, options, requestor, > problemFactory ); > {code} > But the problem is that all keys in the map are prefixed with "-" in > AbstractCompilerMojo: > {code:java} > Map<String, String> effectiveCompilerArguments = getCompilerArguments(); > String effectiveCompilerArgument = getCompilerArgument(); > if ( ( effectiveCompilerArguments != null ) || ( effectiveCompilerArgument != > null ) ) > { > LinkedHashMap<String, String> cplrArgsCopy = new LinkedHashMap<String, > String>(); > if ( effectiveCompilerArguments != null ) > { > for ( Map.Entry<String, String> me : > effectiveCompilerArguments.entrySet() ) > { > String key = (String) me.getKey(); > String value = (String) me.getValue(); > if ( !key.startsWith( "-" ) ) > { > key = "-" + key; > } > cplrArgsCopy.put( key, value ); > } > } > if ( !StringUtils.isEmpty( effectiveCompilerArgument ) ) > { > cplrArgsCopy.put( effectiveCompilerArgument, null ); > } > compilerConfiguration.setCustomCompilerArguments( cplrArgsCopy ); > } > {code} > So what actually gets into the Map for CompilerOptions is this: > {code} > -org.eclipse.jdt.core.compiler.problem.missingSerialVersion = ignore > {code} > Instead of: > {code} > org.eclipse.jdt.core.compiler.problem.missingSerialVersion = ignore > {code} > The incorrect setting name is then silently discarded by ECJ. > I cannot use this either: > {code:xml} > <configuration> > <compilerId>eclipse</compilerId> > <source>1.6</source> > <target>1.6</target> > <encoding>utf-8</encoding> > <compilerArgument>-warn:-serial</compilerArgument> > </configuration> > {code} > ...because "-warn:-serial" is not passed as a command-line argument, but it > is also added to the Map for CompilerOptions: > {code:java} > if ( !StringUtils.isEmpty( effectiveCompilerArgument ) ) > { > cplrArgsCopy.put( effectiveCompilerArgument, null ); > } > compilerConfiguration.setCustomCompilerArguments( cplrArgsCopy ); > {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira