Skip to content

Commit

Permalink
remove moditet plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlauvlwj committed Jul 16, 2024
1 parent cdc7eb9 commit ea8d2c0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ repositories {

dependencies {
api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
api("org.moditect:moditect-gradle-plugin:1.0.0-rc3")
api("org.moditect:moditect:1.0.0.RC1")
api("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.6")
}
43 changes: 25 additions & 18 deletions buildSrc/src/main/kotlin/ktorm.modularity.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@

plugins {
id("kotlin")
id("org.moditect.gradleplugin")
}

moditect {
// Generate a multi-release jar, the module descriptor will be located at META-INF/versions/9/module-info.class
addMainModuleInfo {
jvmVersion.set("9")
overwriteExistingFiles.set(true)
module {
moduleInfoFile = file("src/main/moditect/module-info.java")
val moditect by tasks.registering {
doLast {
// Generate a multi-release modulized jar, module descriptor position: META-INF/versions/9/module-info.class
val inputJar = tasks.jar.flatMap { it.archiveFile }.map { it.asFile.toPath() }.get()
val outputDir = file("build/moditect").apply { mkdirs() }.toPath()
val moduleInfo = file("src/main/moditect/module-info.java").readText()
val version = project.version.toString()
org.moditect.commands.AddModuleInfo(moduleInfo, null, version, inputJar, outputDir, "9", true).run()

// Replace the original jar with the modulized jar.
copy {
from(outputDir.resolve(inputJar.fileName))
into(inputJar.parent)
}
}
}

// Let kotlin compiler know the module descriptor.
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
sourceSets.main {
kotlin.srcDir("src/main/moditect")
}
tasks {
moditect {
dependsOn(jar)
}
jar {
finalizedBy(moditect)
}
}

// Workaround to avoid circular task dependencies, see https://github.com/moditect/moditect-gradle-plugin/issues/14
afterEvaluate {
val compileJava = tasks.compileJava.get()
val addDependenciesModuleInfo = tasks.addDependenciesModuleInfo.get()
compileJava.setDependsOn(compileJava.dependsOn - addDependenciesModuleInfo)
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
// Let kotlin compiler know the module descriptor.
sourceSets.main {
kotlin.srcDir("src/main/moditect")
}
}
2 changes: 1 addition & 1 deletion ktorm-core/ktorm-core.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ val testOutput by configurations.creating {
}

val testJar by tasks.registering(Jar::class) {
dependsOn("testClasses")
dependsOn(tasks.testClasses)
from(sourceSets.test.map { it.output })
archiveClassifier.set("test")
}
Expand Down

0 comments on commit ea8d2c0

Please sign in to comment.