Maven Compiler Plugin
  1. Maven Compiler Plugin
  2. MCOMPILER-36

class Foo is public, should be declared in a file named Foo.java

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.0.1
    • Fix Version/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      When adding a depency to a jar which contains source code like this:

      <dependency>
      <groupId>com.nordija</groupId>
      <artifactId>nordija-midtier</artifactId>
      <version>snapshot</version>
      <classifier>sources</classifier>
      <scope>test</scope>
      </dependency>

      where I'm using the "classifier", the "compiler:testCompile" goal fails with the error:

      Failure executing javac, but could not parse the error:
      /home/tomcat/.m2/repository/com/nordija/nordija-midtier/snapshot/nordija-midtier-snapshot-sources.jar(com/nordija/midtier/util/NestingException.java):42: class NestingException is public, should be declared in a file named NestingException.java
      (source unavailable)
      1 error

      Now, my first thought is of course that the jar is corrupt or packaged wrongly or something like that. But it seems to be okay, and my IDEA can browse it and does not show error-marks for the source file in question. And, the same dependency is used in another module in the same build, where it is no problem!!!

      I solved the problem by going back to v2.0 of the compiler plugin, where everything works.

        Activity

        Hide
        Randy Watler added a comment -

        I have also experienced this issue using the 2.0.1 version of the plugin with 2.0.2 and 2.0.4 versions of M2, but ONLY using j2sdk 1.4.2. Here is the plugin management configuration that failed:

        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
        <source>1.4</source>
        <target>1.4</target>
        <debug>true</debug>
        <showDeprecation>true</showDeprecation>
        <showWarnings>true</showWarnings>
        <optimize>false</optimize>
        </configuration>
        </plugin>

        As with the original reporter, falling back to the 2.0 version of the plugin or using j2sdk 1.5 resolved the issue.

        Show
        Randy Watler added a comment - I have also experienced this issue using the 2.0.1 version of the plugin with 2.0.2 and 2.0.4 versions of M2, but ONLY using j2sdk 1.4.2. Here is the plugin management configuration that failed: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.4</source> <target>1.4</target> <debug>true</debug> <showDeprecation>true</showDeprecation> <showWarnings>true</showWarnings> <optimize>false</optimize> </configuration> </plugin> As with the original reporter, falling back to the 2.0 version of the plugin or using j2sdk 1.5 resolved the issue.
        Hide
        Randy Watler added a comment -

        It seems that one can also work around this issue for the j2sdk 1.4.2 compiler if you take care to exclude *.java files from your jars/wars. We contiue to use older M1/apache style file structures and have the following <build> configuration defined in our root pom:

        <resources>
        <resource>
        <directory>src/java</directory>
        <excludes>
        <exclude>*/.java</exclude>
        </excludes>
        </resource>
        </resources>

        and

        <testResources>
        <testResource>
        <directory>src/java</directory>
        <excludes>
        <exclude>*/.java</exclude>
        </excludes>
        </testResource>
        <testResource>
        <directory>src/test</directory>
        <excludes>
        <exclude>*/.java</exclude>
        </excludes>
        </testResource>
        </testResources>

        Note that once the excludes were added, we were able to not only generate clean build products, but were also able to avoid this issue with the 2.0.1 plugin.

        Show
        Randy Watler added a comment - It seems that one can also work around this issue for the j2sdk 1.4.2 compiler if you take care to exclude *.java files from your jars/wars. We contiue to use older M1/apache style file structures and have the following <build> configuration defined in our root pom: <resources> <resource> <directory>src/java</directory> <excludes> <exclude>* / .java</exclude> </excludes> </resource> </resources> and <testResources> <testResource> <directory>src/java</directory> <excludes> <exclude>* / .java</exclude> </excludes> </testResource> <testResource> <directory>src/test</directory> <excludes> <exclude>* / .java</exclude> </excludes> </testResource> </testResources> Note that once the excludes were added, we were able to not only generate clean build products, but were also able to avoid this issue with the 2.0.1 plugin.
        Hide
        Robert Scholte added a comment -

        Could someone add a sample project ot reproduce this issue?

        Show
        Robert Scholte added a comment - Could someone add a sample project ot reproduce this issue?
        Hide
        Michael Osipov added a comment -

        Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.

        Show
        Michael Osipov added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.

          People

          • Assignee:
            Unassigned
            Reporter:
            Per Olesen
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: