plugins section
What id 'java' actually does
When you write id 'java' in a , you are loading Gradle's built-in Java plugin. This plugin does several things automatically — you get all of these for free without writing any extra code: Without id 'java', Gradle doesn't know this is a Java project and none of those tasks exist.
sourceSets
What sourceSets is
A source set tells Gradle where to find the files it needs to compile and package. It answers two questions:
Where are the .java files? (for compileJava) Where are the resource files like .properties? (for processResources) Gradle has one built-in source set called main (for production code) and another called (for test code). You are configuring main here. Gradle's default vs PCSS reality
By default, when you apply id 'java', Gradle assumes this standard Maven directory layout:
my-module/
├── src/
│ └── main/
│ ├── java/ ← Gradle looks for .java files here by default
│ └── resources/ ← Gradle looks for .properties files here by default
└── build/ ← Gradle writes output here
But PCSS was structured for Ant, not Maven. The actual layout of :dataspec is: common/dataspec/
├── com/ ← .java files are directly here (no src/main/java wrapper)
│ └── apcc/
│ ├── datamodel/
│ ├── interfaces/
│ └── util/
│ └── analytics/
│ └── analytics.properties
├── bin/ ← Ant writes .class files here (Ant's "build output")
├── prod/ ← Ant writes pcss_ds.jar here
└── build.xml
If you didn't override sourceSets, Gradle would look for Java files in common/dataspec/src/main/java/ — that folder doesn't exist — and find nothing. The build would produce an empty JAR.
What each line in our sourceSets does
sourceSets {
main {
java {
srcDirs = ['.']
exclude 'bin/**', 'prod/**'
}
resources {
srcDirs = []
}
}
}
srcDirs = ['.']
This tells Gradle: "the Java source files start right here in the module's own directory, not in a subfolder." The . means the project directory itself — which for :dataspec is . So Gradle will find and all other .java files recursively.
Commands to generate the jar:
.gradlew.bat :dataspec:build
Runs the complete build lifecycle: compile Java → process resources → create JAR Use this for a full, fresh build Safest choice for day-to-day work .gradlew.bat :dataspec:jar --no-daemon
Runs only the JAR packaging task (assumes Java is already compiled) Faster if you haven't changed the source code, only re-jars what exists --no-daemon is an optional flag that tells Gradle "don't use the background daemon process" — useful for CI or if the daemon gets stuck, but not needed for normal development When to use which:
For your daily workflow, just use: This is the standard, complete, safest approach. Gradle's incremental build automatically skips unchanged steps anyway, so performance is fine.
The :jar variant and --no-daemon flag are optimization/troubleshooting tools — not needed unless you have a specific reason.