简体   繁体   中英

why maven-compiler-plugin exclude disable

             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
                     <excludes>
                         <exclude>**/Application.java</exclude>
                     </excludes>
                 </configuration>
             </plugin>

this is my pom.xml , maven-compiler-plugin.version is 3.8.1 .

but i see the Applciation.class still in my jar package by maven

在此处输入图片说明

You are looking at the wrong location. From what I see in the screenshot, you've found some Application file from the External Libraries . What the maven-compiler-plugin does is to generate the target folder. That's where the class file should be excluded from. Check the existence of the file class under:

target/classes/...

And don't forget to run mvn clean install before (with emphasis on clean - this will wipe out your target folder)

In a project, I had to do a similar thing, due I need to exclude the module-info.java . I resolved using this configuration:

 <plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>  
   <executions>
     <execution>
       <id>default-compile</id>
       <configuration>
         <excludes>
           <exclude>**/module-info.java</exclude>
         </excludes>
        </configuration>
      </execution>
    </executions>
</plugin>

If you want the entire project you can get it from GitHub . I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM