@javamodules/gradle

Tools for working with Gradle Module metadata from JavaScript.


Keywords
tools, java, gradle, java-modules, jpms
License
Apache-2.0
Install
npm install @javamodules/gradle@1.0.0

Documentation


Java Modules


Modular Java Kotlin Bazel Gradle Maven

Build status Apache 2.0 License


JPMS Attic Repository

Latest Release: 1.0.9

This repository provides sub-module library overrides for popular Java libraries which don't yet provide JPMS support (at least until some PRs are merged!). There is a Maven repository which contains these artifacts, too, so you can safely use them in your projects.

Pending PRs

Tracking issue here provides the best tracker. Once these PRs are merged and changes are released, this repo becomes obsolete.

What's in the box?

  • com.google.errorprone: Error Prone Compiler "is a static analysis tool for Java that catches common programming mistakes at compile time," built by Google. Error Prone's annotations module is JPMS-enabled at the embedded sub-module, and is used by Guava. The PR enabling JPMS support in Error Prone Annotations has been filed, merged, and released, as 2.26.1.

  • com.google.guava: Google Guava is Google's core Java commons, used throughout Google's code and the wider JVM ecosystem. Guava is an immensely popular artifact, with tons of fantastic utilities. JPMS support is in draft.

  • com.google.j2objc: J2ObjC is a Java to Objective-C cross-compiling layer used by Google to effectively share Java logic on iOS and macOS platforms. J2ObjC itself is very complex and powerful, but here we have just JPMS-enabled the annotations module, which is used by Guava. The PR enabling JPMS support for J2ObjC annotations has been filed, merged, and released as 3.0.0.

  • com.google.protobuf: Protocol Buffers (a.k.a., protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. JPMS support is in draft.

  • io.leangen.geantyref: Geantyref is a fork of the excellent GenTyRef library, adding support for working with AnnotatedTypes introduced in Java 8 plus many nifty features. JPMS support has been proposed, but not yet merged or released.

  • kotlinx.collections.immutable: KotlinX Immutable Collections is a library provided as part of the Kotlin Extensions suite, maintained by the JetBrains team. It provides immutable and persistent collection types in Kotlin. JPMS support is in draft, but not yet merged or released.

  • org.apache.maven.resolver: Maven Resolver is how Maven and many other build tools resolve graphs of dependencies, and perform downloads of dependency artifacts. JPMS support is in early draft; no PR has been filed yet.

  • org.checkerframework: Checker Framework is a type-checking framework for Java. The checker-qual package is used by Guava, so it is included here transitively. Checker Framework added a JPMS module definition in a recent PR, so this is sub-moduled at master. At the time of this writing no release has taken place.

  • org.reactivestreams: Reactive Streams is a universal JVM API for building reactive software in an implementation-agnostic manner.

How do I use it?

Add this domain as a repository within any JVM build tool: Maven, Gradle, Bazel, sbt. For example:

Note

Filing issues: Please file issues for this repo on elide-dev/jpms.

Maven

In a pom.xml:

<repositories>
  <repository>
    <id>jpms-attic</id>
    <name>JPMS Attic</name>
    <url>https://jpms.pkg.st/repository</url>
  </repository>
</repositories>

In a settings.xml:

<profiles>
  <profile>
    <id>jpms-attic</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <repositories>
      <repository>
        <id>pkgst-jpms</id>
        <name>Pkgst JPMS</name>
        <url>https://jpms.pkg.st/repository</url>
      </repository>
    </repositories>
  </profile>
</profiles>

Gradle

Groovy
repositories {
    maven {
        url "https://jpms.pkg.st/repository"
    }
}
Kotlin
repositories {
    maven {
        url = uri("https://jpms.pkg.st/repository")
    }
}

Libraries

You should use a JPMS-enabled library version which has no conflict with Maven Central. Reference the table below to pick a library.

Libraries marked Central have seen releases in Maven Central, and so are no longer needed through this repository.

Coordinate Version
com.google.errorprone:error_prone_annotations Central
com.google.guava:guava JPMS
com.google.j2objc:j2objc-annotations Central
com.google.protobuf:protobuf-java JPMS
com.google.protobuf:protobuf-javalite JPMS
com.google.protobuf:protobuf-util JPMS
com.google.protobuf:protobuf-kotlin JPMS
com.google.protobuf:protobuf-kotlin-lite JPMS
io.leangen.geantyref:geantyref JPMS
org.apache.maven.resolver:maven-resolver-api JPMS
org.apache.maven.resolver:maven-resolver-connector-basic JPMS
org.apache.maven.resolver:maven-resolver-generator-gnupg JPMS
org.apache.maven.resolver:maven-resolver-impl JPMS
org.apache.maven.resolver:maven-resolver-named-locks JPMS
org.apache.maven.resolver:maven-resolver-spi JPMS
org.apache.maven.resolver:maven-resolver-transport-classpath JPMS
org.apache.maven.resolver:maven-resolver-transport-file JPMS
org.apache.maven.resolver:maven-resolver-transport-jdk JPMS
org.apache.maven.resolver:maven-resolver-transport-jetty JPMS
org.apache.maven.resolver:maven-resolver-util JPMS
org.checkerframework:checker-qual JPMS
org.jetbrains.kotlinx:kotlinx-collections-immutable JPMS
org.reactivestreams:reactive-streams JPMS

Using the modules

Use the modules in your module-info.java:

Coordinate Module
com.google.errorprone:error_prone_annotations com.google.errorprone.annotations
com.google.guava:guava com.google.common
com.google.j2objc:j2objc-annotations com.google.j2objc.annotations
com.google.protobuf:protobuf-java com.google.protobuf
com.google.protobuf:protobuf-javalite com.google.protobuf
com.google.protobuf:protobuf-util com.google.protobuf.util
com.google.protobuf:protobuf-kotlin com.google.protobuf.kotlin
com.google.protobuf:protobuf-kotlin-lite com.google.protobuf.kotlin
io.leangen.geantyref:geantyref io.leangen.geantyref
org.apache.maven.resolver:maven-resolver-api org.apache.maven.resolver
org.apache.maven.resolver:maven-resolver-connector-basic org.apache.maven.resolver.connector.basic
org.apache.maven.resolver:maven-resolver-generator-gnupg org.apache.maven.resolver.generator.gnupg
org.apache.maven.resolver:maven-resolver-impl org.apache.maven.resolver.impl
org.apache.maven.resolver:maven-resolver-named-locks org.apache.maven.resolver.named
org.apache.maven.resolver:maven-resolver-spi org.apache.maven.resolver.spi
org.apache.maven.resolver:maven-resolver-transport-classpath org.apache.maven.resolver.transport.classpath
org.apache.maven.resolver:maven-resolver-transport-file org.apache.maven.resolver.transport.file
org.apache.maven.resolver:maven-resolver-transport-jdk org.apache.maven.resolver.transport.jdk
org.apache.maven.resolver:maven-resolver-transport-jetty org.apache.maven.resolver.transport.jetty
org.apache.maven.resolver:maven-resolver-util org.apache.maven.resolver.util
org.checkerframework:checker-qual org.checkerframework.checker.qual
org.jetbrains.kotlinx:kotlinx-collections-immutable kotlinx.collections.immutable
org.reactivestreams:reactive-streams org.reactivestreams

By and large, where a module already had an Automatic-Module-Name, it has been preserved.

BOMs & Catalogs

This repository additionally provides Maven BOM, Gradle Version Catalog, and Gradle Platform artifacts. These simplify and enforce the use of the right library versions. See below for use.

Type Coordinate Version
Maven BOM dev.javamodules:jpms-bom JPMS
Gradle Catalog dev.javamodules:jpms-catalog JPMS
Gradle Platform dev.javamodules:jpms-platform JPMS

Using the Version Catalog

To use the version catalog from Gradle, follow the setup steps below. These code samples are provided in Kotlin:

settings.gradle.kts:

dependencyResolutionManagement {
  repositories {
    mavenCentral()

    maven {
      name = "jpms-attic"
      url = uri("https://jpms.pkg.st/repository")
    }
  }

  versionCatalogs {
    create("attic") {
      from("dev.javamodules:jpms-catalog:1.0.9")
    }
  }
}

build.gradle.kts:

dependencies {
  api(attic.guava)
}

Using the Gradle Platform

To use the Gradle Platform to constrain your versions, map the repository as usual, then:

dependencies {
  api(platform("dev.javamodules:jpms-platform:1.0.9"))
}

The Version Catalog also provides a mapping:

dependencies {
  api(platform(attic.javamodules.platform))
}

Limitations

This repo does not currently publish source or javadoc JARs. It's not that it couldn't, it's just that mounting classifier-equipped JARs in local repositories is annoying.

Sample Projects

Sample projects are provided in the samples directory, which show how to hook up the repository and override libraries.

Coming soon

Future badges

SLSA SPDX

Licensing

This repo is open source, licensed under Apache 2.0. The libraries listed in this repo may have their own licenses; it is up to you to comply with these. These libraries are only published here for the purpose of early testing and development against new code; no warranty is provided of any kind.