Skip to content

Commit

Permalink
Restore "build: update JPMS patch rules (#42)"
Browse files Browse the repository at this point in the history
This reverts commit d5f774c.

Signed-off-by: Jendrik Johannes <[email protected]>
  • Loading branch information
jjohannes committed Dec 19, 2024
1 parent e0bc5f7 commit 8550d2a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 22 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Hiero Gradle Conventions - Changelog

## Version 0.2.0

* JPMS - remove patching rule: commons-codec:commons-codec
* JPMS - remove patching rule: org.jetbrains:annotations
* JPMS - remove patching rule: org.json:json
* JPMS - remove patching rule: errorprone (rules were not creating valid modules)
* JPMS - adjust module name: com.google.common.jimfs

## Version 0.1.2

* make license header configurable via 'license-header.txt' (#48)
Expand Down
23 changes: 1 addition & 22 deletions src/main/kotlin/org.hiero.gradle.base.jpms-modules.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ extraJavaModuleInfo {
module("com.google.dagger:dagger", "dagger")
module("io.perfmark:perfmark-api", "io.perfmark")
module("javax.inject:javax.inject", "javax.inject")
module("commons-codec:commons-codec", "org.apache.commons.codec")
module("com.esaulpaugh:headlong", "com.esaulpaugh.headlong") {
exportAllPackages()
overrideModuleName() // for older versions with 'Automatic-Module-Name: headlong'
Expand All @@ -137,7 +136,6 @@ extraJavaModuleInfo {
exportAllPackages()
requires("org.connid.framework") // this is missing in POM
}
module("org.jetbrains:annotations", "org.jetbrains.annotations")
module("io.tmio:tuweni-units", "tuweni.units")
module("io.tmio:tuweni-bytes", "tuweni.bytes")
module("net.i2p.crypto:eddsa", "net.i2p.crypto.eddsa")
Expand Down Expand Up @@ -217,24 +215,6 @@ extraJavaModuleInfo {
module("net.ltgt.gradle.incap:incap", "net.ltgt.gradle.incap")
module("org.jetbrains.kotlinx:kotlinx-metadata-jvm", "kotlinx.metadata.jvm")

// Annotation processing - error prone
module(
"com.github.kevinstern:software-and-algorithms",
"com.github.kevinstern.software_and_algorithms"
)
module("com.google.auto.value:auto-value-annotations", "com.google.auto.value.annotations")
module("com.google.errorprone:error_prone_annotation", "com.google.errorprone.annotation")
module("com.google.errorprone:error_prone_check_api", "com.google.errorprone.check.api")
module("com.google.errorprone:error_prone_core", "com.google.errorprone.core")
module(
"com.google.errorprone:error_prone_type_annotations",
"com.google.errorprone.type.annotations"
)
module("com.uber.nullaway:nullaway", "com.uber.nullaway")
module("io.github.eisop:dataflow-errorprone", "org.checkerframework.dataflow")
module("io.github.java-diff-utils:java-diff-utils", "io.github.javadiffutils")
module("io.grpc:grpc-java-api-checker", "io.grpc.java.api.checker")

// Testing only
module("io.grpc:grpc-netty-shaded", "io.grpc.netty.shaded") {
exportAllPackages()
Expand All @@ -243,7 +223,7 @@ extraJavaModuleInfo {
requires("jdk.unsupported")
ignoreServiceProvider("reactor.blockhound.integration.BlockHoundIntegration")
}
module("com.google.jimfs:jimfs", "com.google.jimfs")
module("com.google.jimfs:jimfs", "com.google.common.jimfs")
module("io.github.json-snapshot:json-snapshot", "json.snapshot")
module("org.awaitility:awaitility", "awaitility")
module("uk.org.webcompere:system-stubs-core", "uk.org.webcompere.systemstubs.core")
Expand All @@ -263,7 +243,6 @@ extraJavaModuleInfo {
}
module("junit:junit", "junit")
module("org.hamcrest:hamcrest", "org.hamcrest")
module("org.json:json", "org.json")
module("org.mockito:mockito-core", "org.mockito")
module("org.objenesis:objenesis", "org.objenesis")
module("org.rnorth.duct-tape:duct-tape", "org.rnorth.ducttape")
Expand Down
60 changes: 60 additions & 0 deletions src/test/kotlin/org/hiero/gradle/test/JpmsPatchTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: Apache-2.0
package org.hiero.gradle.test

import org.assertj.core.api.Assertions.assertThat
import org.gradle.testkit.runner.TaskOutcome
import org.hiero.gradle.test.fixtures.GradleProject
import org.junit.jupiter.api.Test

class JpmsPatchTest {

@Test
fun `all JPMS patching rules are working`() {
val p = GradleProject().withMinimalStructure()
val versionPatching =
"""
configurations.all { attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) }
dependencies.components.withModule("com.goterl:resource-loader") { this.status = "release" }
dependencies.components.withModule("com.goterl:lazysodium-java") { this.status = "release" }
dependencies.components.all { if(listOf("alpha", "beta", "rc").any { id.version.lowercase().contains(it) }) status = "integration" }
"""
p.aggregationBuildFile(
"""plugins { id("org.hiero.gradle.base.lifecycle") }
dependencies { implementation(project(":module-a")) }
$versionPatching
"""
.trimIndent()
)
p.dependencyVersionsFile(
"""
plugins { id("org.hiero.gradle.base.jpms-modules") }
val modules = extraJavaModuleInfo.moduleSpecs.get().values.map { it.identifier }
dependencies.constraints {
modules.forEach { api("${'$'}it:latest.release") }
api("org.jetbrains:annotations:latest.release")
api("com.google.dagger:dagger-compiler:2.42!!")
api("org.hyperledger.besu:evm:24.3.3!!")
}
"""
.trimIndent()
)
p.moduleBuildFile(
"""
plugins {
id("java-library")
id("org.hiero.gradle.base.jpms-modules")
}
val modules = extraJavaModuleInfo.moduleSpecs.get().values.map { it.moduleName }.distinct()
file("src/main/java/module-info.java").writeText(
"module org.example.module.a {\n${'$'}{modules.joinToString("") { " requires ${'$'}it;\n"}}\n}")
$versionPatching
"""
.trimIndent()
)
p.help() // generate 'module-info.java' through code above

val result = p.run("build")

assertThat(result.task(":module-a:compileJava")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}
}

0 comments on commit 8550d2a

Please sign in to comment.