Uploaded image for project: 'Maven Compiler Plugin'
  1. Maven Compiler Plugin
  2. MCOMPILER-174

Maven compiler plugin <excludes> doesn't work all the time

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.4, 2.5
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      N/A

      Description

      When you set a source file as

        <configuration>
          <excludes>
            <exclude>com/you/example.java</exclude>
          </excludes>
        </configuration>

      it doesn't pass the file in with the list of .java files to javac. However, it still passes in the ./src/ directory under the -sourcepath option to the javac command. Thus, javac still knows that the file exists and can try to compile it anyways under certain circumstances.

      The passing of ./src/ under -sourcepath is redundant anyways, as every single file to be compiled is passed (in my case, all 391 source files) to javac. The only possible result from passing ./src/ (or at least the only one I can think of) is that a file which is in your ./src/ directory yet excluded by the maven-compiler-plugin can still be seen (and compiled) by javac. This can cause inexplicable results and a lot of confusion since it operates in a counter-intuitive way.

        Activity

        Hide
        krokodylowy3 Krashan Brahmanjara added a comment - - edited

        True. In one ejb project excludes works, in another war project excludes doesn't work
        as expected. Some files was excluded but not all.

        For example for this configuration and 'mvn clean compile'
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
        <includes>
        <include>pl/as/in/**</include>
        <include>pl/as/zs/**</include>
        </includes>
        <excludes>
        <exclude>pl/as/af/**</exclude>
        </excludes>
        </configuration>
        </plugin>

        I got correct message
        [INFO] — maven-compiler-plugin:2.5.1:compile (default-compile) @ in-web —
        [INFO] Compiling 27 source files to D:\opt\workspace\in-web\target\classes

        But folder af was compiled and D:\opt\workspace\in-web\target\classes\pl\af exists and has got many *.class files

        Show
        krokodylowy3 Krashan Brahmanjara added a comment - - edited True. In one ejb project excludes works, in another war project excludes doesn't work as expected. Some files was excluded but not all. For example for this configuration and 'mvn clean compile' <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <includes> <include>pl/as/in/**</include> <include>pl/as/zs/**</include> </includes> <excludes> <exclude>pl/as/af/**</exclude> </excludes> </configuration> </plugin> I got correct message [INFO] — maven-compiler-plugin:2.5.1:compile (default-compile) @ in-web — [INFO] Compiling 27 source files to D:\opt\workspace\in-web\target\classes But folder af was compiled and D:\opt\workspace\in-web\target\classes\pl\af exists and has got many *.class files
        Hide
        t.broyer Thomas Broyer added a comment -

        MCOMPILER-26 got it right, but this was later reverted in MCOMPILER-98.

        Show
        t.broyer Thomas Broyer added a comment - MCOMPILER-26 got it right, but this was later reverted in MCOMPILER-98 .

          People

          • Assignee:
            Unassigned
            Reporter:
            matt5784 Matthew Lavin
          • Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Development