Search code examples
javamavenmaven-plugin

How to exclude module-info.java file from maven-processor-plugin?


Please, help to exclude module-info file.

This is my code:

       <plugin>
            <groupId>org.bsc.maven</groupId>
            <artifactId>maven-processor-plugin</artifactId>
            <version>3.3.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <phase>generate-sources</phase>
                    <configuration>
                            <excludes>
                                <exclude>${project.basedir}src/main/java/module-info.java</exclude>
                            </excludes>
                    </configuration>
                </execution>
            </executions>
        </plugin>

I also tried:

     <exclude>src/main/java/module-info.java</exclude>
     <exclude>**/module-info.java</exclude>
     <exclude>**/*module-info.java</exclude>

but not one helped.

I need it as I get a lot of error like this:

[ERROR] diagnostic: /home/<deleted>/src/main/java/module-info.java:11: error: module not found: org.slf4j
    requires static org.slf4j;

Could anyone say how to do it?


Solution

  • I figure out that exclusion on module-info.java doesn't work as expected, however, I think that the problem here is mostly related to java9 Platform Module System (JPMS).

    After reproduced the error (thanks Pavel_K) I got a solution adding all compile and runtime dependencies to --module-path options.

    I released version 4.0-rc1 with such fix