From a1d47c69617ca9c834a00d58af3c96aaf83dfe6e Mon Sep 17 00:00:00 2001 From: Marc Philipp Date: Wed, 16 Oct 2024 17:29:47 +0200 Subject: [PATCH] Document runtime dependency scope Resolves #28. --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index e37a3c6..b54394f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,14 @@ dependencies { } ``` +Using `compileOnlyApi` will include the library on the compile classpath of downstream projects but not their runtime classpath. If you want downstream projects to be able to use the `@API` annotation at runtime, you should declare it as `api` instead: + +```gradle +dependencies { + api("org.apiguardian:apiguardian-api:1.1.2") +} +``` + ### Java Platform Module System ```java @@ -36,3 +44,11 @@ module org.example { requires static transitive org.apiguardian.api; } ``` + +Using `static` will only include the library on the module path of downstream projects at compile time but not at runtime. If you want downstream projects to be able to use the `@API` annotation at runtime, you should declare it without `static` instead: + +```java +module org.example { + requires transitive org.apiguardian.api; +} +```