Skip to content

java(plugins): extend building-plugins guide with ecosystem conventions - #2870

Open
rjayasinghe wants to merge 1 commit into
mainfrom
extend-java-plugin-conventions
Open

java(plugins): extend building-plugins guide with ecosystem conventions#2870
rjayasinghe wants to merge 1 commit into
mainfrom
extend-java-plugin-conventions

Conversation

@rjayasinghe

Copy link
Copy Markdown
Contributor

Summary

  • Adds a comprehensive Plugin Conventions & Reference Implementations section to java/building-plugins.md, derived from an analysis of the real plugins in the cap-java GitHub org (attachments, notifications, ord, event-hub, advanced-event-mesh, auditlog-ng, cds-ai, print, console, n8n, and the plugin-template-emoji skeleton).
  • Adds a groupId caveat clarifying that the cap-java example repos use com.sap.cds as SAP-owned artifacts — the external-plugin rule still stands.
  • Adds a one-paragraph ecosystem-norm note near the existing ServiceLoader-vs-Spring decision, with a forward link to the new Configuration & Enablement subsection.

New section covers

Subsection What it documents
Reference Plugins Table: pattern → living cap-java example repo
Recommended Project Layout Root aggregator + cds-feature-<x> module (+ optional integration-tests, coverage-report)
Maven Skeleton ${revision} + flatten, cds-services-bom import, versionless cds-services-api, cds-maven-plugin pin, package.json companion
Choosing a Registration Hook Decision matrix over CdsRuntimeConfiguration hooks + when to use Spring AutoConfiguration
Custom Services & Event Contexts Service interface + DEFAULT_NAME + EventContext subtype pattern
Configuration & Enablement Binding-driven mock-vs-productive switch; no cds.<feature>.enabled convention; Spring conditional alternative
Testing a Plugin Unit tests with cds-services-impl (test scope); dedicated integration-tests app module; CDS mock handlers
Repository Hygiene REUSE/Apache-2.0, shared CI actions, Maven Central publishing

All existing anchors (#service-loader, #spring-autoconfiguration, #protocol-adapter, #reference-the-new-cds-model-in-an-existing-cap-java-project) are preserved.

Test plan

  • Run the VitePress dev server (npm run docs:dev from repo root) and open /java/building-plugins — confirm new section renders with no parse errors
  • Verify all inbound anchor links still resolve: #service-loader, #spring-autoconfiguration, #protocol-adapter (linked from plugins/index.md, developing-applications/building.md, change-tracking.md)
  • Click through the github.com/cap-java/<repo> links in the reference table to confirm all repos exist
  • Run the repo's markdown lint / link-check if configured

Adds a "Plugin Conventions & Reference Implementations" section to
building-plugins.md, grounded in an analysis of the real plugins in the
cap-java GitHub org (attachments, notifications, ord, event-hub,
advanced-event-mesh, auditlog-ng, cds-ai, print, console, n8n, and the
plugin-template-emoji skeleton).

The new section covers:
- Reference plugin table linking each pattern to a living example
- Recommended multi-module Maven project layout
- Maven skeleton: ${revision} + flatten-maven-plugin, cds-services-bom
  import, versionless cds-services-api, cds-maven-plugin pinning,
  and a package.json companion for hermetic cds-dk builds
- CdsRuntimeConfiguration hook decision matrix (environment / services /
  eventHandlers / providers / order, with when-to-use and reference repo)
- Spring AutoConfiguration as the alternative when typed
  @ConfigurationProperties / @ConditionalOn… wiring is needed
- Custom Service interface + DEFAULT_NAME + EventContext pattern
- Configuration & enablement: binding-driven mock-vs-productive handler
  switching; no cds.<feature>.enabled convention
- Testing: cds-services-impl (test scope) for unit tests, a dedicated
  integration-tests app module, CDS mock handlers for external services
- Repository hygiene: REUSE/Apache-2.0, CI workflows, Maven Central publishing

Also adds two small in-place edits:
- groupId caveat clarifying that cap-java example repos use com.sap.cds
  as SAP-owned artifacts; the external-plugin rule still stands
- Ecosystem norm note pointing from the ServiceLoader-vs-Spring decision
  to the new Configuration & Enablement subsection
@rjayasinghe

Copy link
Copy Markdown
Contributor Author

@Akatuoro I asked Claude to reverse-engineer some information on how to build CAP Java plugins. Let me know what you think about it. :)

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I posted two inline comments on issues that could mislead readers: an outdated CAP Java version example and a Java snippet that would not compile as shown. The rest of the added guide content looks broadly consistent with the existing page structure and intent.

PR Bot Information

Version: 1.31.30

Comment thread java/building-plugins.md
```xml [Root pom.xml — version & BOM]
<properties>
<revision>0.0.1-SNAPSHOT</revision>
<cds.services.version><!-- choose current LTS, e.g. 3.7.1 --></cds.services.version>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The example CAP Java version is outdated

The file now documents active CAP Java 5.x and maintenance 4.9.x elsewhere, so 3.7.1 can lead plugin authors to start from an unsupported baseline. Consider pointing to the maintained version overview instead of hard-coding an obsolete example.

Suggested change
<cds.services.version><!-- choose current LTS, e.g. 3.7.1 --></cds.services.version>
<cds.services.version><!-- choose a supported CAP Java version, see java/versions.md --></cds.services.version>

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Comment thread java/building-plugins.md
// Register in CdsRuntimeConfiguration
@Override
public void services(CdsRuntimeConfigurer configurer) {
configurer.service(new PrintServiceImpl(runtime));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The example uses an undefined runtime variable

This code snippet will not compile as shown because runtime is not declared in the method or class. Instead, fetch the runtime from the CdsRuntimeConfigurer, as the later example also does.

Suggested change
configurer.service(new PrintServiceImpl(runtime));
configurer.service(new PrintServiceImpl(configurer.getCdsRuntime()));

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

@hyperspace-pr-bot hyperspace-pr-bot Bot deleted a comment from renejeglinsky Sep 11, 2026
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