Skip to content

Commit

Permalink
set up Version Catalog and typesafe project accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
aSemy committed Mar 14, 2023
1 parent df50360 commit 4f49425
Show file tree
Hide file tree
Showing 43 changed files with 434 additions and 377 deletions.
22 changes: 3 additions & 19 deletions build-logic/build.gradle.kts
@@ -1,5 +1,3 @@
import java.util.*

plugins {
`kotlin-dsl`
}
Expand All @@ -10,22 +8,8 @@ kotlin {
}
}

// TODO define versions in Gradle Version Catalog https://github.com/Kotlin/dokka/pull/2884
val properties = file("../gradle.properties").inputStream().use {
Properties().apply { load(it) }
}

val kotlinVersion = properties["kotlin_version"]

dependencies {
// Import Gradle Plugins that will be used in the buildSrc pre-compiled script plugins, and any `build.gradle.kts`
// files in the project.
// Use their Maven coordinates (plus versions), not Gradle plugin IDs!
// This should be the only place that Gradle plugin versions are defined, so they are aligned across all build scripts

implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.12.1")
implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.8.10")
implementation(libs.gradlePlugin.dokka)
implementation(libs.gradlePlugin.kotlin)
implementation(libs.gradlePlugin.shadow)
}
6 changes: 6 additions & 0 deletions build-logic/settings.gradle.kts
Expand Up @@ -14,4 +14,10 @@ dependencyResolutionManagement {
google()
gradlePluginPortal()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
16 changes: 8 additions & 8 deletions build-logic/src/main/kotlin/org/jetbrains/publication.kt
Expand Up @@ -2,13 +2,9 @@ package org.jetbrains

import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
import org.gradle.api.Project
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.SigningExtension
import org.jetbrains.DokkaPublicationChannel.*
Expand All @@ -24,7 +20,10 @@ class DokkaPublicationBuilder {
}


fun Project.registerDokkaArtifactPublication(publicationName: String, configure: DokkaPublicationBuilder.() -> Unit) {
fun Project.registerDokkaArtifactPublication(
publicationName: String,
configure: DokkaPublicationBuilder.() -> Unit
) {
configure<PublishingExtension> {
publications {
register<MavenPublication>(publicationName) {
Expand Down Expand Up @@ -143,9 +142,10 @@ private fun Project.signPublicationsIfKeyPresent(vararg publications: String) {
useInMemoryPgpKeys(signingKey, signingKeyPassphrase)
}
publications.forEach { publicationName ->
extensions.findByType(PublishingExtension::class)!!.publications.findByName(publicationName)?.let {
sign(it)
}
extensions.getByType<PublishingExtension>()
.publications
.findByName(publicationName)
?.let { sign(it) }
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions build.gradle.kts
@@ -1,12 +1,14 @@
import org.jetbrains.ValidatePublications
import org.jetbrains.publicationChannels

@Suppress("DSL_SCOPE_VIOLATION") // fixed in Gradle 8.1 https://github.com/gradle/gradle/pull/23639
plugins {
id("org.jetbrains.conventions.base") apply false
id("org.jetbrains.dokka") version "1.8.10"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("com.gradle.plugin-publish") version "0.20.0"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.12.1"
id("org.jetbrains.conventions.base")
id("org.jetbrains.conventions.dokka")

alias(libs.plugins.kotlinx.binaryCompatibilityValidator)
alias(libs.plugins.gradle.pluginPublish)
alias(libs.plugins.nexusPublish)
}

val dokka_version: String by project
Expand Down
18 changes: 7 additions & 11 deletions core/build.gradle.kts
Expand Up @@ -7,26 +7,22 @@ plugins {
}

dependencies {
api("org.jetbrains:markdown:0.3.1")
api(libs.jetbrainsMarkdown)
implementation(kotlin("reflect"))

val jsoup_version: String by project
implementation("org.jsoup:jsoup:$jsoup_version")
implementation(libs.jsoup)

val jackson_version: String by project
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_version")
val jackson_databind_version: String by project
implementation(libs.jackson.kotlin)
implementation(libs.jackson.xml)
constraints {
implementation("com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version") {
implementation(libs.jackson.databind) {
because("CVE-2022-42003")
}
}

val coroutines_version: String by project
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
implementation(libs.kotlinx.coroutines.core)

testImplementation(project(":core:test-api"))
testImplementation(projects.core.testApi)
testImplementation(kotlin("test-junit"))
}

Expand Down
6 changes: 3 additions & 3 deletions core/content-matcher-test-utils/build.gradle.kts
Expand Up @@ -3,8 +3,8 @@ plugins {
}

dependencies {
implementation(project(":core:test-api"))
implementation(kotlin("stdlib-jdk8"))
implementation(projects.core.testApi)

implementation(kotlin("reflect"))
implementation("com.willowtreeapps.assertk:assertk-jvm:0.25")
implementation(libs.assertk)
}
5 changes: 2 additions & 3 deletions core/test-api/build.gradle.kts
Expand Up @@ -6,10 +6,9 @@ plugins {
}

dependencies {
api(project(":core"))
implementation(project(":kotlin-analysis"))
api(projects.core)
implementation(projects.kotlinAnalysis)
implementation("junit:junit:4.13.2") // TODO: remove dependency to junit
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
}

Expand Down
123 changes: 123 additions & 0 deletions gradle/libs.versions.toml
@@ -0,0 +1,123 @@
[versions]

## compilation ##
jvm = "11"
kotlin = "1.8.10"
kotlin-languageLevel = "1.4"


## libs ##
kotlin-plugin = "213-1.8.10-release-430-IJ6777.52"
kotlinx-coroutines = "1.6.3"
kotlinx-html = "0.7.5"
jsoup = "1.15.3"
idea = "213.6777.52"

jackson = "2.12.7" # jackson 2.13.X does not support kotlin language version 1.4, check before updating
jacksonDatabind = "2.12.7.1" # fixes CVE-2022-42003

freemarker = "2.3.31"

jetbrainsMarkdown = "0.3.1"


apache-maven = "3.5.0"
apache-mavenArtifact = "3.8.5"
apache-mavenArchiver = "2.5"
apache-mavenPluginTools = "3.5.2"

eclipse-jgit = "5.12.0.202106070339-r"

## test ##
junit = "5.9.2"

## gradle plugins ##
gradlePlugin-shadow = "7.1.2"
gradlePlugin-binaryCompatibilityValidator = "0.12.1"
gradlePlugin-nexusPublish = "1.1.0"
gradlePlugin-dokka = "1.7.10"
gradlePlugin-gradlePluginPublish = "0.20.0"
gradlePlugin-gradle = "4.0.1"

## NPM ##
node = "16.13.0"

[libraries]

## Kotlin ##
kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }

kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler", version.ref = "kotlin" }
kotlin-idea = { module = "org.jetbrains.kotlin:idea", version.ref = "kotlin" }
kotlin-common = { module = "org.jetbrains.kotlin:common", version.ref = "kotlin" }
kotlin-core = { module = "org.jetbrains.kotlin:core", version.ref = "kotlin" }
kotlin-native = { module = "org.jetbrains.kotlin:native", version.ref = "kotlin" }

kotlinx-cli = { module = "org.jetbrains.kotlinx:kotlinx-cli", version = "0.3.4" }
kotlinx-html = { module = "org.jetbrains.kotlinx:kotlinx-html", version.ref = "kotlinx-html" }

kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }

kotlinPlugin-common = { module = "org.jetbrains.kotlin:common", version.ref = "kotlin.plugin" }
kotlinPlugin-idea = { module = "org.jetbrains.kotlin:idea", version.ref = "kotlin.plugin" }
kotlinPlugin-core = { module = "org.jetbrains.kotlin:core", version.ref = "kotlin.plugin" }
kotlinPlugin-native = { module = "org.jetbrains.kotlin:native", version.ref = "kotlin.plugin" }

jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
jetbrainsMarkdown = { module = "org.jetbrains:markdown", version.ref = "jetbrainsMarkdown" }
freemarker = { module = "org.freemarker:freemarker", version.ref = "freemarker" }
soywiz-korte = { module = "com.soywiz.korlibs.korte:korte", version = "2.7.0" }

jetbrainsIntelliJ-core = { module = "com.jetbrains.intellij.idea:intellij-core", version.ref = "idea" }
jetbrainsIntelliJ-jpsStandalone = { module = "com.jetbrains.intellij.idea:jps-standalone", version.ref = "idea" }

## Jackson ##
jackson-bom = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
jackson-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
jackson-xml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml", version.ref = "jackson" }

jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jacksonDatabind" }



## Apache Maven ##
apache-mavenArchiver = { module = "org.apache.maven:maven-archiver", version.ref = "apache-mavenArchiver" }
apache-mavenCore = { module = "org.apache.maven:maven-core", version.ref = "apache-maven" }
apache-mavenPluginAnnotations = { module = "org.apache.maven.plugin-tools:maven-plugin-annotations", version.ref = "apache-mavenPluginTools" }
apache-mavenPluginApi = { module = "org.apache.maven:maven-plugin-api", version.ref = "apache-maven" }
apache-mavenArtifact = { module = "org.apache.maven:maven-artifact", version.ref = "apache-mavenArtifact" }


eclipse-jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "eclipse-jgit" }

## logging ##


#############
### test ###
#############

## junit ##

## junit ##
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }

assertk = { module = "com.willowtreeapps.assertk:assertk", version = "0.25" }

### Gradle plugins ###
# The Maven coordinates of Gradle plugins that are used as

gradlePlugin-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "gradlePlugin-dokka" }
gradlePlugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
gradlePlugin-shadow = { module = "gradle.plugin.com.github.johnrengelman:shadow", version.ref = "gradlePlugin-shadow" }
gradlePlugin-android = { module = "com.android.tools.build:gradle", version.ref = "gradlePlugin-gradle" }


[plugins]

kotlinx-binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "gradlePlugin-binaryCompatibilityValidator" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "gradlePlugin-shadow" }
gradle-pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "gradlePlugin-gradlePluginPublish" }
nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "gradlePlugin-nexusPublish" }
11 changes: 4 additions & 7 deletions integration-tests/build.gradle.kts
Expand Up @@ -3,11 +3,8 @@ plugins {
}

dependencies {
implementation(kotlin("stdlib"))
api(project(":test-utils"))
val coroutines_version: String by project
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
val jsoup_version: String by project
implementation("org.jsoup:jsoup:$jsoup_version")
implementation("org.eclipse.jgit:org.eclipse.jgit:5.12.0.202106070339-r")
api(projects.testUtils)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.jsoup)
implementation(libs.eclipse.jgit)
}
8 changes: 3 additions & 5 deletions integration-tests/cli/build.gradle.kts
Expand Up @@ -10,9 +10,8 @@ evaluationDependsOn(":runners:cli")
evaluationDependsOn(":plugins:base")

dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("test-junit"))
implementation(project(":integration-tests"))
implementation(projects.integrationTests)
}

/* Create a fat base plugin jar for cli tests */
Expand All @@ -23,8 +22,8 @@ val basePluginShadow: Configuration by configurations.creating {
}

dependencies {
basePluginShadow(project(":plugins:base"))
basePluginShadow(project(":kotlin-analysis")) // compileOnly in base plugin
basePluginShadow(projects.plugins.base)
basePluginShadow(projects.kotlinAnalysis) // compileOnly in base plugin
}

val basePluginShadowJar by tasks.register("basePluginShadowJar", ShadowJar::class) {
Expand All @@ -41,4 +40,3 @@ tasks.integrationTest {
dependsOn(cliJar)
dependsOn(basePluginShadowJar)
}

7 changes: 3 additions & 4 deletions integration-tests/gradle/build.gradle.kts
Expand Up @@ -5,13 +5,12 @@ plugins {
}

dependencies {
implementation(project(":integration-tests"))
implementation(kotlin("stdlib"))
implementation(projects.integrationTests)

implementation(kotlin("test-junit"))
implementation(gradleTestKit())

val jsoup_version: String by project
implementation("org.jsoup:jsoup:$jsoup_version")
implementation(libs.jsoup)
}

tasks.integrationTest {
Expand Down
Expand Up @@ -14,7 +14,5 @@ android {
}

dependencies {
implementation(kotlin("stdlib"))
implementation("androidx.appcompat:appcompat:1.1.0")
}

Expand Up @@ -21,7 +21,6 @@ version = "1.8.10-SNAPSHOT"
apply(from = "../template.root.gradle.kts")

dependencies {
implementation(kotlin("stdlib"))
testImplementation(kotlin("test-junit"))
}

Expand Down
Expand Up @@ -2,7 +2,3 @@ plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
}

dependencies {
implementation(kotlin("stdlib"))
}
Expand Up @@ -2,7 +2,3 @@ plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
}

dependencies {
implementation(kotlin("stdlib"))
}
Expand Up @@ -13,10 +13,9 @@ kotlin {
}

dependencies {
implementation(kotlin("stdlib"))
implementation(npm("is-sorted", "1.0.5"))

val reactVersion = properties["react_version"]
implementation("org.jetbrains.kotlin-wrappers:kotlin-react:$reactVersion")
implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom:$reactVersion")
}
}

0 comments on commit 4f49425

Please sign in to comment.