prep migrating buildSrc plugins to includeBuild plugins

This commit is contained in:
Adam 2022-09-12 21:38:01 +02:00
parent c8815726b1
commit d82f25c6ee
6 changed files with 232 additions and 0 deletions

View file

@ -0,0 +1,24 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`kotlin-dsl`
kotlin("jvm") version embeddedKotlinVersion
}
val gradleJvmTarget = "11"
kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget))
}
kotlinDslPluginOptions {
jvmTarget.set(gradleJvmTarget)
}
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = gradleJvmTarget
}
}

View file

@ -0,0 +1,25 @@
rootProject.name = "settings-plugins"
@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
mavenCentral()
gradlePluginPortal()
}
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
}
}
}

View file

@ -0,0 +1,77 @@
@file:Suppress("PackageDirectoryMismatch")
package org.gradle.kotlin.dsl
import org.gradle.api.artifacts.dsl.RepositoryHandler
fun RepositoryHandler.jitpack() {
maven("https://jitpack.io")
}
fun RepositoryHandler.myMavenLocal(enabled: Boolean = true) {
if (enabled) {
println("Maven local is enabled")
mavenLocal {
content {
// includeGroup("dev.adamko")
// includeGroup("dev.adamko.kxtsgen")
includeGroup("io.kotest")
}
}
}
}
fun RepositoryHandler.sonatypeSnapshot() {
maven("https://oss.sonatype.org/content/repositories/snapshots") {
mavenContent {
snapshotsOnly()
includeGroup("io.kotest")
}
}
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
mavenContent {
snapshotsOnly()
includeGroup("io.kotest")
}
}
}
fun RepositoryHandler.nodeDistributions() {
// Declare the Node.js download repository
ivy("https://nodejs.org/dist/") {
name = "Node Distributions at $url"
patternLayout { artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]") }
metadataSources { artifact() }
content { includeModule("org.nodejs", "node") }
}
}
fun RepositoryHandler.yarnDistributions() {
ivy("https://github.com/yarnpkg/yarn/releases/download") {
name = "Yarn Distributions at $url"
patternLayout { artifact("v[revision]/[artifact](-v[revision]).[ext]") }
metadataSources { artifact() }
content { includeModule("com.yarnpkg", "yarn") }
}
}
// https://stackoverflow.com/a/34327202/4161471
// example: implementation("jmeter-gradle-plugin:jmeter-gradle-plugin:1.0.3@zip")
fun RepositoryHandler.gitHub() {
ivy("https://github.com/") {
patternLayout {
artifact("/[organisation]/[module]/archive/[revision].[ext]")
}
metadataSources { artifact() }
content {
includeGroup("jmeter-gradle-plugin")
}
}
}

View file

@ -0,0 +1,44 @@
package kafkatorio.convention.settings
@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature
dependencyResolutionManagement {
// https://github.com/gradle/gradle/issues/15754#issuecomment-763614651
// https://github.com/gradle/gradle/blob/09fcaacc9848f09aa584b4119be9271bee6916e6/build-logic/build-logic-base/settings-plugin/src/main/kotlin/gradlebuild.repositories.settings.gradle.kts#L68
// Cannot use 'FAIL_ON_PROJECT_REPOS' because
// - the 'gradle-guides-plugin' adds a repo (which it should not do)
// - the 'kotlin-gradle-plugin' adds a repo (and removes it afterwards) to download NodeJS
// repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
myMavenLocal()
mavenCentral()
jitpack()
gradlePluginPortal()
// Declare the Node.js download repository
nodeDistributions()
yarnDistributions()
maven("https://raw.githubusercontent.com/adamko-dev/kotka-streams/artifacts/m2") {
content { includeGroup("dev.adamko.kotka") }
}
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") {
content { includeGroup("org.jetbrains.kotlinx") }
}
sonatypeSnapshot()
}
pluginManagement {
repositories {
myMavenLocal()
gradlePluginPortal()
mavenCentral()
jitpack()
sonatypeSnapshot()
}
}
}