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'
}