简体   繁体   中英

How to include only specific files from the main/java to be part of jar to be published to using gradle?

I don't want the whole main/java to be pushed as Jar

Instead, I want only specific folders inside main/java to be part of the jar.

How do I achieve it?

Actually, this part of your build.gradle has nothing to do with creating the JAR file. It just defines a publication that refers to the Java component built by your Java project. One part of this Java project is the task jar , which actually creates the JAR file. This task is of type Jar , so it offers methods to either exclude files following a pattern or to only include files following a pattern:

jar {
    include '**/path/to/included/files/*.class'
    // alternatively
    exclude '**/path/to/excluded/files/*.class'
}

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