How to exclude module-info.java in Netbeans (11)?

 ̄綄美尐妖づ 提交于 2019-12-23 03:06:53

问题


Our source code is still Java 8 complient, but we have two different builds: one built with JDK 11 and module-info.java. And one with JDK 8 and without module-info.java. With maven, this is easy two accomplish with to different profiles. For the JDK 8 profile, module-info.java is excluded:

  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
      ...
      <excludes>
        <exclude>module-info.java</exclude>
      </excludes>
    </configuration>
  </plugin>

When this project is imported into Netbeans 11 and the correct profile activated, the maven configuration for excludes is ignored.


回答1:


Make exclusion a part of base configuration.

<pluginManagement>
    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
            ...
            <excludes>
                <exclude>**/module-info.java</exclude>
            </excludes>
        </configuration>
    </plugin>

and override exclusions in java-11 profile

<profile>
    <id>java-11</id>
    <pluginManagement>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <excludes combine.self="override"/>
            </configuration>
        </plugin>



回答2:


In case anybody stumbles upon this issue, I've indicated here why it (probably) doesn't work:

Migrating maven project to modules - ignore module-info.java



来源:https://stackoverflow.com/questions/56670787/how-to-exclude-module-info-java-in-netbeans-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!