Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      annotation processors which load non-Java resources from the sourcepath, will currently get only the src/main/java folder.

      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

      see MCOMPILER-98 for more

        Issue Links

          Activity

          Hide
          Jesse Glick added a comment -

          javac bug claimed to be fixed in JDK 7.

          Can be worked around in the processor, e.g.: http://hg.netbeans.org/main/diff/e97fb471102d/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java

          Show
          Jesse Glick added a comment - javac bug claimed to be fixed in JDK 7. Can be worked around in the processor, e.g.: http://hg.netbeans.org/main/diff/e97fb471102d/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java
          Hide
          Jesse Glick added a comment -

          The javac bug is indeed fixed in JDK 7; the compiler plugin needs to be updated.

          Show
          Jesse Glick added a comment - The javac bug is indeed fixed in JDK 7; the compiler plugin needs to be updated.
          Hide
          Vincent Massol added a comment - - edited

          I've hit this problem too.

          I've had to do the following (https://github.com/xwiki/xwiki-commons/blob/master/pom.xml#L762):

                  <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <!-- Lock down plugin version for build reproducibility -->
                    <version>3.2</version>
                    <configuration>
                      <source>1.7</source>
                      <target>1.7</target>
                    </configuration>
                    <executions>
                      <!-- We need custom sourcepaths for our Component Annotation Process work
                          (See ComponentCheckerAnnotationProcessor.java). This is required because of
                          http://jira.codehaus.org/browse/MCOMPILER-122.
                          However note that IntelliJ IDEA doesn't honor custom sourcepaths, see
                          https://youtrack.jetbrains.com/issue/IDEA-133120, which means that you need to turn off
                          Annotation Processing in IDEA or IDEA will generate errors while building modules -->
                      <execution>
                        <id>default-compile</id>
                        <configuration>
                          <compilerArguments>
                            <sourcepath>${project.basedir}/src/main/java:${project.basedir}/src/main/resources</sourcepath>
                          </compilerArguments>
                        </configuration>
                      </execution>
                      <execution>
                        <id>default-testCompile</id>
                        <configuration>
                          <compilerArguments>
                            <sourcepath>${project.basedir}/src/test/java:${project.basedir}/src/test/resources</sourcepath>
                          </compilerArguments>
                        </configuration>
                      </execution>
                    </executions>
                  </plugin>
          

          However this isn't perfect. It works in Maven but fails in IDEA (see https://youtrack.jetbrains.com/issue/IDEA-133120). I'm also not sure it works on Windows machines (but that could be fixed with profiles).

          In addition I've noticed that it runs javac with 2 -sourcepath parameters! For example:

          [DEBUG] -d /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/target/classes -classpath /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/target/classes:/Users/vmassol/.m2/repository/org/xwiki/commons/xwiki-commons-tool-component-generation/6.4-SNAPSHOT/xwiki-commons-tool-component-generation-6.4-SNAPSHOT.jar: 
          -sourcepath /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/src/main/java:/Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/target/generated-sources/annotations: 
          -s /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/target/generated-sources/annotations 
          -g -deprecation -target 1.7 -source 1.7 -encoding UTF-8 
          -sourcepath /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/src/main/java:/Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/src/main/resources 
          -Xlint:all
          

          And luckily it seems javac will take the last one...

          In any case it would be great to fix it

          Thanks

          Show
          Vincent Massol added a comment - - edited I've hit this problem too. I've had to do the following ( https://github.com/xwiki/xwiki-commons/blob/master/pom.xml#L762): <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <!-- Lock down plugin version for build reproducibility --> <version>3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> <executions> <!-- We need custom sourcepaths for our Component Annotation Process work (See ComponentCheckerAnnotationProcessor.java). This is required because of http://jira.codehaus.org/browse/MCOMPILER-122. However note that IntelliJ IDEA doesn't honor custom sourcepaths, see https://youtrack.jetbrains.com/issue/IDEA-133120, which means that you need to turn off Annotation Processing in IDEA or IDEA will generate errors while building modules --> <execution> <id>default-compile</id> <configuration> <compilerArguments> <sourcepath>${project.basedir}/src/main/java:${project.basedir}/src/main/resources</sourcepath> </compilerArguments> </configuration> </execution> <execution> <id>default-testCompile</id> <configuration> <compilerArguments> <sourcepath>${project.basedir}/src/test/java:${project.basedir}/src/test/resources</sourcepath> </compilerArguments> </configuration> </execution> </executions> </plugin> However this isn't perfect. It works in Maven but fails in IDEA (see https://youtrack.jetbrains.com/issue/IDEA-133120 ). I'm also not sure it works on Windows machines (but that could be fixed with profiles). In addition I've noticed that it runs javac with 2 -sourcepath parameters! For example: [DEBUG] -d /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/target/classes -classpath /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/target/classes:/Users/vmassol/.m2/repository/org/xwiki/commons/xwiki-commons-tool-component-generation/6.4-SNAPSHOT/xwiki-commons-tool-component-generation-6.4-SNAPSHOT.jar: -sourcepath /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/src/main/java:/Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/target/generated-sources/annotations: -s /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/target/generated-sources/annotations -g -deprecation -target 1.7 -source 1.7 -encoding UTF-8 -sourcepath /Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/src/main/java:/Users/vmassol/dev/xwiki/git/xwiki-commons/xwiki-commons-core/xwiki-commons-stability/src/main/resources -Xlint:all And luckily it seems javac will take the last one... In any case it would be great to fix it Thanks

            People

            • Assignee:
              Unassigned
              Reporter:
              Milos Kleint
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: