Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use version catalog to manage dependencies to make renovate work again #412

Merged
merged 3 commits into from Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 6 additions & 13 deletions build-logic/build.gradle.kts
@@ -1,16 +1,9 @@
plugins {
kotlin("jvm").version("1.4.32")
`kotlin-dsl`
}
plugins { `kotlin-dsl` }

dependencies {
implementation(kotlin("gradle-plugin"))
implementation("org.jlleitschuh.gradle:ktlint-gradle:11.0.0")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.21.0")
}

repositories {
mavenCentral()
google()
gradlePluginPortal()
implementation(libs.kotlin.plugin)
implementation(libs.ktlint.plugin)
implementation(libs.maven.publish.plugin)
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
16 changes: 16 additions & 0 deletions build-logic/settings.gradle.kts
@@ -0,0 +1,16 @@
@file:Suppress("UnstableApiUsage")

rootProject.name = "build-logic"

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
versionCatalogs {
gabrielittner marked this conversation as resolved.
Show resolved Hide resolved
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
9 changes: 0 additions & 9 deletions build-logic/src/main/kotlin/Versions.kt

This file was deleted.

21 changes: 12 additions & 9 deletions build-logic/src/main/kotlin/shared.gradle.kts
@@ -1,3 +1,7 @@
import org.gradle.accessors.dm.LibrariesForLibs

val libs = the<LibrariesForLibs>()

plugins {
id("java-library")
id("kotlin")
Expand All @@ -15,17 +19,16 @@ repositories {
google()
}


java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8

// Use the kotlin version from the stdlib
val kotlinVersion = KotlinVersion.CURRENT.toString()
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

configurations.all {
// Pin the kotlin version
resolutionStrategy {
force("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
force("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
force(libs.kotlin.stdlib)
force(libs.kotlin.stdlib.jdk8)
force(libs.kotlin.reflect)
}
}
25 changes: 25 additions & 0 deletions gradle/libs.versions.toml
@@ -0,0 +1,25 @@
[versions]
kotlin = "1.6.10"
moshi = "1.13.0"
retrofit = "2.9.0"

[libraries]
okhttp = "com.squareup.okhttp3:okhttp:4.10.0"
dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.6.10"
assertj = "org.assertj:assertj-core:3.19.0"
junit = "junit:junit:4.13.2"

android-plugin = "com.android.tools.build:gradle:7.1.0"
ktlint-plugin = "org.jlleitschuh.gradle:ktlint-gradle:11.0.0"
maven-publish-plugin = "com.vanniktech:gradle-maven-publish-plugin:0.21.0"

kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }

moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi" }

retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
retrofit-converter-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "retrofit" }
10 changes: 5 additions & 5 deletions nexus/build.gradle.kts
Expand Up @@ -3,10 +3,10 @@ plugins {
}

dependencies {
add("kapt", "com.squareup.moshi:moshi-kotlin-codegen:${Version.moshi}")
kapt(libs.moshi.codegen)

implementation("com.squareup.okhttp3:okhttp:${Version.okhttp}")
implementation("com.squareup.moshi:moshi:${Version.moshi}")
implementation("com.squareup.retrofit2:retrofit:${Version.retrofit}")
implementation("com.squareup.retrofit2:converter-moshi:${Version.retrofit}")
implementation(libs.okhttp)
implementation(libs.moshi)
implementation(libs.retrofit)
implementation(libs.retrofit.converter.moshi)
}
30 changes: 16 additions & 14 deletions plugin/build.gradle.kts
Expand Up @@ -3,7 +3,7 @@ plugins {
id("java-gradle-plugin")
}

configure<GradlePluginDevelopmentExtension> {
gradlePlugin {
plugins {
create("mavenPublishPlugin") {
id = "com.vanniktech.maven.publish"
Expand All @@ -21,30 +21,33 @@ configure<GradlePluginDevelopmentExtension> {
}

val integrationTestSourceSet = sourceSets.create("integrationTest") {
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
compileClasspath += sourceSets["main"].output + configurations.testRuntimeClasspath
runtimeClasspath += output + compileClasspath
}
val integrationTestImplementation = configurations.getByName("integrationTestImplementation")
.extendsFrom(configurations.getByName("testImplementation"))
.extendsFrom(configurations.testImplementation.get())

dependencies {
api(gradleApi())
api(kotlin("stdlib"))
api(libs.kotlin.stdlib)

compileOnly("org.jetbrains.dokka:dokka-gradle-plugin:${Version.dokka}")
compileOnly(kotlin("gradle-plugin"))
compileOnly("com.android.tools.build:gradle:${Version.agp}")
compileOnly(libs.dokka)
compileOnly(libs.kotlin.plugin)
compileOnly(libs.android.plugin)

implementation(project(":nexus"))
implementation(projects.nexus)

testImplementation(gradleTestKit())
testImplementation("junit:junit:${Version.junit}")
testImplementation("org.assertj:assertj-core:${Version.assertj}")
testImplementation(libs.junit)
testImplementation(libs.assertj)
}

val integrationTest by tasks.registering(Test::class) {
dependsOn("publishToMavenLocal", project(":nexus").tasks.named("publishToMavenLocal"))
mustRunAfter(tasks.named("test"))
dependsOn(
tasks.publishToMavenLocal,
projects.nexus.dependencyProject.tasks.publishToMavenLocal
)
mustRunAfter(tasks.test)

description = "Runs the integration tests."
group = "verification"
Expand All @@ -63,7 +66,6 @@ val integrationTest by tasks.registering(Test::class) {
)
}

val check = tasks.named("check")
check.configure {
tasks.check {
dependsOn(integrationTest)
}
11 changes: 4 additions & 7 deletions settings.gradle.kts
@@ -1,9 +1,6 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
@Suppress("UnstableApiUsage")
includeBuild("build-logic")
}
rootProject.name = "gradle-maven-publish-plugin"

include(":plugin")
include(":nexus")
includeBuild("build-logic")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")