Maven 2.x Compiler Plugin

-sourcepath not passed to javac

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 2.0.2
  • Fix Version/s: 2.2
  • Component/s: None
  • Labels:
    None
  • Environment:
    Ubuntu 8.10, JDK 6.
  • Testcase included:
    yes
  • Patch Submitted:
    Yes
  • Number of attachments :
    2

Description

JavacCompiler.java (actually in plexus-compiler-javac, but I cannot find the source project for this anywhere) has

List sourceLocations = config.getSourceLocations();
if ( sourceLocations != null && !sourceLocations.isEmpty() && ( sourceFiles.length == 0 ) )

{ args.add( "-sourcepath" ); args.add( getPathString( sourceLocations ) ); }

The sourceFiles.length == 0 clause should be deleted. The problem is that javac really does need to have -sourcepath even when you are passing an explicit list of *.java files; it is necessary for 269-compliant annotation processors:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6647998

Following is a patch which

1. Fixes diagnostics to print compiler arguments even for unforked mode. (javac is still run with a command line when unforked, so there is no reason to omit this valuable diagnostic info.)

2. Hacks maven-compiler-plugin to work around the bug in plexus-compiler-javac and pass -sourcepath. Obviously a fix to p-c-j would be preferable.

When applied to m-c-p 2.0.2 it allows the test case to build.

Issue Links

Activity

Hide
Jesse Glick added a comment -

269 support in general would require this to be fixed.

Show
Jesse Glick added a comment - 269 support in general would require this to be fixed.
Hide
Jesse Glick added a comment - - edited

Even if this were fixed, the expected output from the test case would be invisible unless MCOMPILER-66 were fixed too.

Show
Jesse Glick added a comment - - edited Even if this were fixed, the expected output from the test case would be invisible unless MCOMPILER-66 were fixed too.
Hide
Jesse Glick added a comment - - edited

MCOMPILER-97 has to be worked around in test case.

Show
Jesse Glick added a comment - - edited MCOMPILER-97 has to be worked around in test case.
Hide
Jesse Glick added a comment -

Patch incl. better diagnostics and hotfix.

Show
Jesse Glick added a comment - Patch incl. better diagnostics and hotfix.
Hide
Jesse Glick added a comment -

Workaround seems to be:

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArguments>
<sourcepath>${project.basedir}/src/main/java</sourcepath>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>

Show
Jesse Glick added a comment - Workaround seems to be: <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <sourcepath>${project.basedir}/src/main/java</sourcepath> </compilerArguments> </configuration> </plugin> </plugins> </build>
Hide
Milos Kleint added a comment -

http://svn.apache.org/viewvc?rev=900690&view=rev
http://fisheye.codehaus.org/changelog/plexus/?cs=8590

the compiler plugin's trunk still references the 1.6 version of the javac compiler plugin.

Show
Milos Kleint added a comment - http://svn.apache.org/viewvc?rev=900690&view=rev http://fisheye.codehaus.org/changelog/plexus/?cs=8590 the compiler plugin's trunk still references the 1.6 version of the javac compiler plugin.
Hide
Jesse Glick added a comment -

Note that for annotation processors which load non-Java resources from the sourcepath, the above fix will not suffice since it only includes Java sources. Untested workaround:

<compilerArguments>
<sourcepath>${project.basedir}/src/main/java:${project.basedir}/src/main/resources</sourcepath>
</compilerArguments>

Show
Jesse Glick added a comment - Note that for annotation processors which load non-Java resources from the sourcepath, the above fix will not suffice since it only includes Java sources. Untested workaround: <compilerArguments> <sourcepath>${project.basedir}/src/main/java:${project.basedir}/src/main/resources</sourcepath> </compilerArguments>
Hide
Jesse Glick added a comment -

Unfortunately just adding src/main/resources to -sourcepath does not suffice, due to a bug in javac:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6929404

(link may take a few days to work)

Show
Jesse Glick added a comment - Unfortunately just adding src/main/resources to -sourcepath does not suffice, due to a bug in javac: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6929404 (link may take a few days to work)
Hide
Milos Kleint added a comment -

I've opened the MCOMPILER-122 for the resources usecase. closing this one as the generic -sourcepath case is fixed.

Show
Milos Kleint added a comment - I've opened the MCOMPILER-122 for the resources usecase. closing this one as the generic -sourcepath case is fixed.

People

Vote (8)
Watch (7)

Dates

  • Created:
    Updated:
    Resolved: