Keep examples out of the published jar in three projects - #54
Conversation
batch-publish, counters and schedule-message were shipping their example
classes inside the main published artifact. Examples are meant to compile,
so that they stay correct, but not to be carried into a jar somebody puts
in production, where they are only bloat.
Each project has two separate things:
tasks.register('bundle', Bundle) {
from sourceSets.main.output
exclude("io/synadia/examples/**")
}
jar {
bundle { bnd(...) }
exclude("io/synadia/examples/**")
}
The registered 'bundle' task is an extra task. The published artifact comes
from the jar task by way of components.java, so only the exclude inside
jar{} affects what ships. These three had it in the registered task but not
in jar{}. The other six that publish a bundle already had both.
Measured before, in the main published jar: batch-publish 9 example
classes, counters 1, schedule-message 21. After: 0 in all three, and 0 in
the six that were already correct. The examples classifier jar still
carries them, 4, 1 and 21 respectively, which is the artifact meant to.
No source, no dependency and no publishing coordinate changes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YRbGPiFEXpwnU9BEy8mXb7
|
Claude finished @scottf's task in 40s —— View job PR Review
Verdict: LGTM — correct, minimal, and consistent. The fix is exactly right. Each of the three affected projects was missing After the change, all three projects match the pattern of the six already-correct projects ( No correctness, security, or performance concerns. The |
batch-publish,countersandschedule-messagewere shipping their example classes inside the main published artifact. Examples are meant to compile, so they stay correct, but not to be carried into a jar somebody puts in production, where they are only bloat.Cause
Each project has two separate things:
tasks.register('bundle', Bundle)registers an additional task. The published artifact comes from thejartask by way offrom components.java, so only the exclude insidejar{}affects what ships. These three had it in the registered task but not injar{}. The six other bundle-publishing projects already had both.Measured
Example classes in the main published jar, before and after:
The
examplesclassifier jar still carries them — batch-publish 4, counters 1, schedule-message 21 — which is the artifact intended to.Examples still compile in all three;
srcDirs = ['src/main/java','src/examples/java']is unchanged. No source, dependency or publishing coordinate changes. One line per project.🤖 Generated with Claude Code
https://claude.ai/code/session_01YRbGPiFEXpwnU9BEy8mXb7