Skip to content

Keep examples out of the published jar in three projects - #54

Merged
scottf merged 1 commit into
mainfrom
exclude-examples-from-published-jars
Sep 10, 2026
Merged

Keep examples out of the published jar in three projects#54
scottf merged 1 commit into
mainfrom
exclude-examples-from-published-jars

Conversation

@scottf

@scottf scottf commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

batch-publish, counters and schedule-message were 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) {
    from sourceSets.main.output
    exclude("io/synadia/examples/**")
}

jar {
    bundle { bnd(...) }
    exclude("io/synadia/examples/**")
}

tasks.register('bundle', Bundle) registers an additional task. The published artifact comes from the jar task by way of from components.java, so only the exclude inside jar{} affects what ships. These three had it in the registered task but not in jar{}. The six other bundle-publishing projects already had both.

Measured

Example classes in the main published jar, before and after:

project before after
batch-publish 9 0
counters 1 0
schedule-message 21 0
chaos-runner, direct-batch, encoded-kv, js-publish-extensions, request-many, retrier 0 0

The examples classifier 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

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
@synadia-claude-reviewer

synadia-claude-reviewer Bot commented Sep 10, 2026

Copy link
Copy Markdown

Claude finished @scottf's task in 40s —— View job


PR Review

  • Gather context: read PR diff and existing build files
  • Compare with already-fixed projects to verify consistency
  • Assess correctness and completeness of the changes
  • Post review summary

Verdict: LGTM — correct, minimal, and consistent.

The fix is exactly right. Each of the three affected projects was missing exclude("io/synadia/examples/**") inside the jar {} task (while having it in tasks.register('bundle', Bundle)). The published artifact comes from components.java via the jar task, so only the jar {} exclusion matters for what ships to Maven.

After the change, all three projects match the pattern of the six already-correct projects (chaos-runner, direct-batch, encoded-kv, js-publish-extensions, request-many, retrier) — exclude("io/synadia/examples/**") present in both the bundle registration task and the jar {} task.

No correctness, security, or performance concerns. The examples classifier jar is unaffected and still carries example classes as intended.

@scottf
scottf merged commit c74e75a into main Sep 10, 2026
6 checks passed
@scottf
scottf deleted the exclude-examples-from-published-jars branch September 10, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant