-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore "build: update JPMS patch rules (#42)"
This reverts commit d5f774c. Signed-off-by: Jendrik Johannes <[email protected]>
- Loading branch information
Showing
3 changed files
with
69 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |