mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-12 16:00:38 -05:00
Separate plugins for different Gradle APIs
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.jvm")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(kotlin("stdlib"))
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlin.compilerOptions {
|
||||
@Suppress("DEPRECATION") // we can't use api version greater than 1.4 as minimal supported Gradle version uses kotlin-stdlib 1.4
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_4)
|
||||
@Suppress("DEPRECATION") // we can't use language version greater than 1.5 as minimal supported Gradle embeds Kotlin 1.4
|
||||
languageVersion.set(KotlinVersion.KOTLIN_1_5)
|
||||
jvmTarget.set(JvmTarget.JVM_1_8)
|
||||
optIn.add("kotlin.RequiresOptIn")
|
||||
freeCompilerArgs.addAll(
|
||||
listOf(
|
||||
"-Xskip-prerelease-check",
|
||||
"-Xsuppress-version-warnings",
|
||||
// We have to override the default value for `-Xsam-conversions` to `class`
|
||||
// otherwise the compiler would compile lambdas using invokedynamic,
|
||||
// such lambdas are not serializable so are not compatible with Gradle configuration cache.
|
||||
// It doesn't lead to a significant difference in binaries sizes, and previously (before LV 1.5) the `class` value was set by default.
|
||||
"-Xsam-conversions=class",
|
||||
),
|
||||
)
|
||||
}
|
||||
60
buildSrc/src/main/kotlin/plugin-conventions.gradle.kts
Normal file
60
buildSrc/src/main/kotlin/plugin-conventions.gradle.kts
Normal file
@@ -0,0 +1,60 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
id("gradle-kotlin-conventions")
|
||||
id("io.github.goooler.shadow")
|
||||
`java-gradle-plugin`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
}
|
||||
|
||||
configure<GradlePluginDevelopmentExtension> {
|
||||
plugins {
|
||||
register("gradle2nix") {
|
||||
id = "org.nixos.gradle2nix"
|
||||
displayName = "gradle2nix"
|
||||
description = "Expose Gradle tooling model for the gradle2nix tool"
|
||||
implementationClass = "org.nixos.gradle2nix.Gradle2NixPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
"api" {
|
||||
dependencies.remove(project.dependencies.gradleApi())
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
"jar" {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
named("shadowJar", ShadowJar::class) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
isPreserveFileTimestamps = false
|
||||
isReproducibleFileOrder = true
|
||||
val mode644 = 0b110100100
|
||||
val mode755 = 0b111101101
|
||||
fileMode = mode644
|
||||
dirMode = mode755
|
||||
filesMatching("**/bin/*") { mode = mode755 }
|
||||
filesMatching("**/bin/*.bat") { mode = mode644 }
|
||||
|
||||
relocate("kotlinx", "${project.group}.shadow.kotlinx")
|
||||
relocate("org.intellij", "${project.group}.shadow.intellij")
|
||||
relocate("org.jetbrains", "${project.group}.shadow.jetbrains")
|
||||
|
||||
dependencies {
|
||||
exclude { it.moduleGroup == "org.jetbrains.kotlin" && it.moduleName == "kotlin-stdlib" }
|
||||
exclude { it.moduleGroup == "org.jetbrains.kotlin" && it.moduleName == "kotlin-stdlib-common" }
|
||||
exclude { it.moduleGroup == "org.jetbrains.kotlin" && it.moduleName == "kotlin-stdlib-jdk7" }
|
||||
exclude { it.moduleGroup == "org.jetbrains.kotlin" && it.moduleName == "kotlin-stdlib-jdk8" }
|
||||
exclude { it.moduleGroup == "org.jetbrains.kotlin" && it.moduleName == "kotlin-reflect" }
|
||||
exclude { it.moduleGroup == "org.jetbrains.kotlin" && it.moduleName == "kotlin-script-runtime" }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user