Skip to content

Conversation

ethiclab
Copy link

Hello,

Plexus csharp compiler makes some verifications on custom compiler arguments configured as follows:

via maven: as stated here

<project> [...] <build> [...] <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <compilerArgs> <arg>-verbose</arg> <arg>-Xlint:all,-options,-path</arg> </compilerArgs> </plugin> </plugins> [...] </build> [...] </project>

The problem is that iteration over returned map returns keys with null values so I think those tests are broken.

This hack tries to split command line arguments in order to override custom compiler arguments with the following code:

public class CSharpCompiler extends AbstractCompiler { //.... private Map<String, String> compilerArguments; //.... private Map<String, String> getCompilerArguments( CompilerConfiguration config ) { if (compilerArguments != null) { return compilerArguments; } compilerArguments = config.getCustomCompilerArgumentsAsMap(); Iterator<String> i = compilerArguments.keySet().iterator(); while ( i.hasNext() ) { String orig = i.next(); String v = compilerArguments.get( orig ); if ( orig.contains( ":" ) && v == null ) { String[] arr = orig.split( ":" ); i.remove(); String k = arr[0]; v = arr[1]; compilerArguments.put( k, v ); if ( config.isDebug() ) { System.out.println( "transforming argument from " + orig + " to " + k + " = [" + v + "]" ); } } } config.setCustomCompilerArgumentsAsMap( compilerArguments ); return compilerArguments; } //.... }

We made this hack in order to ensure backwards compatibility but we are not sure if this is the right way to proceed.

We use it only with maven. Are you aware of other projects using this library?

It seems this compiler was coded when custom compiler arguments parsing was done in a different way than it is done now.

Do you have any clue on this?

Thank you very much for your review.

EthicLab.

@olamy olamy merged commit 0ea1663 into codehaus-plexus:master Jan 17, 2017
@rfscholte rfscholte added this to the 2.8.2 milestone Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants