-
Notifications
You must be signed in to change notification settings - Fork 3
Dependencies
Add a dependency by Java module name or Maven package URL:
ja require org.slf4j
ja require 'pkg:maven/org.slf4j/slf4j-api'Both forms add a standard requires directive using the dependency's Java module name. When no version is given, ja selects the latest stable semantic version across all major versions. If the repository has no semantic versions, it selects the latest version reported by the repository.
Add @version to either form when you need an exact release. Explicit prerelease and non-semantic versions are supported:
ja require org.slf4j@2.0.17
ja require 'pkg:maven/org.slf4j/slf4j-api@2.0.17'The requested version is recorded as a comment on the module declaration:
module com.example.hello {
requires org.slf4j; // @2.0.17
}Requirement modifiers are available through the command line:
ja require --static org.junit.jupiter@6.1.3
ja require --transitive com.example.api@1.4.0A static dependency is available when compiling but is not required when the application runs. A transitive dependency is also made available to modules that depend on yours.
Update every direct dependency, or name the ones to update:
ja require --update
ja require --update org.slf4j
ja require --update=patch org.slf4j
ja require --update=majorBy default, updates select compatible minor and patch releases. Versions before 1.0.0 may advance through 1.x; later versions remain on their current major release. Use patch to remain on the current major and minor release, or major to allow any newer stable semantic version. Dependencies with only non-semantic versions advance to the latest version reported by the repository.
Hashes of resolved dependencies in module-info.hash are verified when resolving later. It stops if the content of an existing JPMS module coordinate changes.
Annotation processor generated code is treated as ordinary source files. Review, maintain, and check them in alongside handwritten source. A clean checkout can then compile without running the generator first, and ensures that annotation processors aren't opaque.
Add an annotation processor as a static dependency, or provide it from another source module, then select it with @processWith:
/** @processWith com.example.generator */
module com.example.model {
requires static com.example.generator; // @1.2.3
}Run the processor to update the generated files:
ja generateRun ja generate again whenever the generated files need updating. Compilation and tests use the files already in the source tree.