You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Piotr Zygielo (Jira)" <ji...@apache.org> on 2022/03/13 08:25:00 UTC

[jira] [Commented] (MCOMPILER-402) Not possible to exclude module-info with 'excludes'

    [ https://issues.apache.org/jira/browse/MCOMPILER-402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17505407#comment-17505407 ] 

Piotr Zygielo commented on MCOMPILER-402:
-----------------------------------------

Here is my guess.

The same with CLI:

{{$ rm -rf target/classes/*}}
{{$ javac -d target/classes -sourcepath src/main/java:target/generated-sources/annotations: -s target/generated-sources/annotations -g -nowarn --release 11 src/main/java/com/example/Main.java}}
{{$ tree target/classes}}

{{target/classes}}
{{├── com}}
{{│ └── example}}
{{│   └── Main.class}}
{{└── module-info.class}}

So {{module-info.java}} is not sent for compilation by the plugin, but it's being found by compiler itself.

[https://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html#searching]
{quote}You can use the [-implicit|https://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html#implicit] option to specify the behavior.
{quote}
And it helps:

{{$ rm -rf target/classes/*}}
{{$ javac -d target/classes -sourcepath src/main/java:target/generated-sources/annotations: -s target/generated-sources/annotations -g -nowarn --release 11 src/main/java/com/example/Main.java -implicit:none}}
{{$ tree target/classes}}

{{target/classes}}
{{└── com}}
{{  └── example}}
{{    └── Main.class}}

As there is currently no option to configure {{-implicit}} in mojo I suggest to use [https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#compilerArgs] to do it explicitly.

> Not possible to exclude module-info with 'excludes'
> ---------------------------------------------------
>
>                 Key: MCOMPILER-402
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-402
>             Project: Maven Compiler Plugin
>          Issue Type: Bug
>    Affects Versions: 3.8.0, 3.8.1
>            Reporter: Petr Dolezal
>            Priority: Major
>
> I tried to use {{excludes}} to exclude {{module-info.java}} from build, essentially in the same way as described in [the official example|https://maven.apache.org/plugins/maven-compiler-plugin/examples/module-info.html], but the file was always compiled anyway. I even tried to use various patterns with no effect.
> This seems weird to me and with the respect to the mentioned example I consider such a behavior to be a bug.
> Since I could not attach the source files, here is the listing for reproducing the issue:
>  
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.example</groupId>
>   <artifactId>com.example</artifactId>
>   <version>1.0.0-SNAPSHOT</version>
>   <packaging>jar</packaging>
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <version>3.8.1</version>
>         <configuration>
>           <release>11</release>
>           <source>11</source>
>           <target>11</target>
>           <excludes>
>             <exclude>module-info.java</exclude>
>           </excludes>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
> </project>
> {code}
> {code:java}
> // src/main/java/module-info.java
> module com.example {
>     exports com.example;
> }
> {code}
> {code:java}
> // src/main/java/com/example/Main.java
> package com.example;
> public final class Main {
>     public static void main(String... args) {
>         System.out.println("Hello World");
>     }
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)