Skip to content

Commit

Permalink
Update Kotlin to 1.8.20, all necessary accompanying changes (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderTvis authored Sep 11, 2023
1 parent 356fb32 commit f5f5fd1
Show file tree
Hide file tree
Showing 60 changed files with 585 additions and 483 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
- uses: github/codeql-action/upload-sarif@v2
if: ${{ always() }}
with:
sarif_file: ./build/reflekt/reports/detekt/merge.sarif
sarif_file: ./build/reports/detekt/merge.sarif
category: detekt
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: build/reflekt/dokka/htmlMultiModule
folder: build/dokka/htmlMultiModule
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ for Java and Kotlin in the `build.gradle.kts` file:
```kotlin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

kotlin.jvmToolchain(11)

tasks.withType<KotlinCompile> {
kotlinOptions {
useIR = true
jvmTarget = "11"
// Current Reflekt version does not support incremental compilation process
incremental = false
}
Expand Down
77 changes: 55 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,37 @@ import io.gitlab.arturbosch.detekt.DetektPlugin
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import io.gitlab.arturbosch.detekt.report.ReportMergeTask
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.jetbrains.reflekt.buildutils.*
import java.net.URL

@Suppress("DSL_SCOPE_VIOLATION") // https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
`maven-publish`
alias(libs.plugins.kosogor)
alias(libs.plugins.buildconfig) apply false
alias(libs.plugins.dokka)
id(libs.plugins.kotlin.jvm.get().pluginId)
}

val detektReportMerge by tasks.registering(ReportMergeTask::class) {
output.set(rootProject.buildDir.resolve("reports/detekt/merge.sarif"))
output = rootProject.layout.buildDirectory.file("reports/detekt/merge.sarif")
}

group = "org.jetbrains.reflekt"
version = libs.versions.kotlin.asProvider().get()
version = libs.versions.kotlin.get()
description = "Reflekt is a compile-time reflection library that leverages the flows of the standard reflection approach and can find classes, objects " +
"(singleton classes) or functions by some conditions in compile-time."

allprojects {
apply {
plugin("kotlin")
apply(plugin = "kotlin")

tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
tasks.withType<KotlinCompile<*>> {
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}

java {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
Expand All @@ -39,34 +44,31 @@ allprojects {

repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
// Uncomment it for using the last kotlin compiler version
// The full list of the build can be found here:
// https://teamcity.jetbrains.com/buildConfiguration/Kotlin_KotlinPublic_BuildNumber?mode=builds&tag=bootstrap
// (see builds with <boostrap> tag)
// Note: uncomment it also in the settings.gradle.kts
// maven {
// url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
// }
// maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
}

// We should publish the project in the local maven repository before the tests running
tasks.withType<Test> {
dependsOn(tasks.withType<PublishToMavenLocal> {}, ":reflekt-plugin:jar", ":reflekt-dsl:jar")
dependsOn(tasks.withType<PublishToMavenLocal>(), ":reflekt-plugin:jar", ":reflekt-dsl:jar")
}

configureDiktat()
apply<DetektPlugin>()

configure<DetektExtension> {
config = rootProject.files("detekt.yml")
config.setFrom(rootProject.files("detekt.yml"))
buildUponDefaultConfig = true
debug = true
}

tasks.withType<Detekt> {
finalizedBy(detektReportMerge)
reports.sarif.required.set(true)
reports.sarif.required = true
detektReportMerge.get().input.from(sarifReportFile)
}
}
Expand All @@ -82,24 +84,55 @@ subprojects {
tasks.withType<DokkaTaskPartial> {
dokkaSourceSets.configureEach {
sourceLink {
localDirectory.set(this@subprojects.file("src/main/kotlin"))
localDirectory = this@subprojects.file("src/main/kotlin")

remoteUrl.set(
remoteUrl =
URL("https://github.com/JetBrains-Research/${rootProject.name}/tree/master/${this@subprojects.name}/src/main/kotlin/")
)
}
}
}
}

if (this@subprojects.name != "gradle-plugin") {
publishing {
publications {
@Suppress("unused")
val mavenJava by creating(MavenPublication::class) {
from(this@subprojects.components["java"])

pom {
description = rootProject.description
inceptionYear = "2020"
url = "https://github.com/JetBrains-Research/${rootProject.name}"

licenses {
license {
comments = "Open-source license"
distribution = "repo"
name = "Apache License"
url = "https://github.com/JetBrains-Research/${rootProject.name}/blob/master/LICENSE"
}
}

scm {
connection = "scm:git:[email protected]:JetBrains-Research/${rootProject.name}.git"
developerConnection = "scm:git:[email protected]:JetBrains-Research/${rootProject.name}.git"
url = "[email protected]:JetBrains-Research/${rootProject.name}.git"
}
}
}
}
}
}

publishing {
repositories {
maven {
maven("https://packages.jetbrains.team/maven/p/reflekt/reflekt") {
name = "SpacePackages"
url = uri("https://packages.jetbrains.team/maven/p/reflekt/reflekt")

credentials {
username = System.getenv("JB_SPACE_CLIENT_ID")?.takeIf { it.isNotBlank() } ?: ""
password = System.getenv("JB_SPACE_CLIENT_SECRET")?.takeIf { it.isNotBlank() } ?: ""
username = System.getenv("JB_SPACE_CLIENT_ID").orEmpty()
password = System.getenv("JB_SPACE_CLIENT_SECRET").orEmpty()
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ plugins {
repositories {
mavenCentral()
google()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
// Uncomment it for using the last kotlin compiler version
// The full list of the build can be found here:
// https://teamcity.jetbrains.com/buildConfiguration/Kotlin_KotlinPublic_BuildNumber?mode=builds&tag=bootstrap
// (see builds with <boostrap> tag)
// Note: uncomment it also in the settings.gradle.kts
// maven {
// url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
// }
// maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
}

dependencies {
Expand All @@ -22,8 +19,11 @@ dependencies {
implementation(libs.gradle.plugin.detekt)
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "11"
}
java {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
5 changes: 1 addition & 4 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
// Uncomment it for using the last kotlin compiler version
// The full list of the build can be found here:
// https://teamcity.jetbrains.com/buildConfiguration/Kotlin_KotlinPublic_BuildNumber?mode=builds&tag=bootstrap
// (see builds with <boostrap> tag)
// Note: uncomment it also in the build.gradle.kts
// maven {
// url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
// }
// maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
}
}
2 changes: 2 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ style:
active: false
ReturnCount:
max: 3
DestructuringDeclarationWithTooManyEntries:
active: false
2 changes: 2 additions & 0 deletions diktat-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@
enabled: false
- name: IDENTIFIER_LENGTH
enabled: false
- name: KDOC_DUPLICATE_PROPERTY
enabled: false
14 changes: 5 additions & 9 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import org.jetbrains.reflekt.plugin.reflekt
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = rootProject.group
version = rootProject.version

plugins {
id("org.jetbrains.reflekt") version "1.8.0-dev-6"
id("org.jetbrains.kotlin.jvm") version "1.8.0-dev-6"
id("org.jetbrains.reflekt") version "1.8.21"
id("org.jetbrains.kotlin.jvm") version "1.8.21"
}

allprojects {
Expand All @@ -24,19 +23,16 @@ allprojects {
}

dependencies {
implementation("org.jetbrains.reflekt", "reflekt-dsl", "1.8.0-dev-6")
implementation("org.jetbrains.reflekt", "reflekt-dsl", "1.8.21")
}

repositories {
mavenCentral()
mavenLocal()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
// Uncomment to use a released version
// maven(url = uri("https://packages.jetbrains.team/maven/p/reflekt/reflekt"))
}

reflekt {
enabled = true
// maven("https://packages.jetbrains.team/maven/p/reflekt/reflekt")
}

reflekt.enabled = true
}
2 changes: 1 addition & 1 deletion examples/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pluginManagement {
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
// add the dependency to Reflekt Maven repository
// Uncomment to use a released version
// maven(url = uri("https://packages.jetbrains.team/maven/p/reflekt/reflekt"))
// maven("https://packages.jetbrains.team/maven/p/reflekt/reflekt")
gradlePluginPortal()
}
}
27 changes: 13 additions & 14 deletions gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import tanvd.kosogor.proxy.publishPlugin

@Suppress("DSL_SCOPE_VIOLATION") // https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
`kotlin-dsl`
alias(libs.plugins.kotlin.plugin.serialization)
alias(libs.plugins.plugin.publish)
}

group = rootProject.group
version = rootProject.version

dependencies {
implementation(kotlin("gradle-plugin-api"))
implementation(embeddedKotlin("gradle-plugin-api"))
implementation(projects.reflektCore)
api(projects.reflektDsl)
implementation(libs.kotlinx.serialization.protobuf)
}

publishPlugin {
id = "org.jetbrains.reflekt"
displayName = "Reflekt"
implementationClass = "org.jetbrains.reflekt.plugin.ReflektSubPlugin"
version = project.version.toString()

info {
description = "Compile-time reflection library"
website = "https://github.com/JetBrains-Research/reflekt"
vcsUrl = "https://github.com/JetBrains-Research/reflekt"
tags.addAll(listOf("kotlin", "reflection", "reflekt"))
gradlePlugin {
website = "https://github.com/JetBrains-Research/reflekt"
vcsUrl = "https://github.com/JetBrains-Research/reflekt"
plugins {
val reflekt by creating {
id = "org.jetbrains.reflekt"
displayName = "Gradle Reflekt plugin"
description = rootProject.description
implementationClass = "org.jetbrains.reflekt.plugin.ReflektSubPlugin"
tags.addAll(listOf("kotlin", "reflection", "reflekt"))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
package org.jetbrains.reflekt.plugin

import org.gradle.api.Project

/**
* Users can configure this extension in their build.gradle like this:
* reflekt {
* enabled = false
* // ... set other members on the ReflektGradleExtension class
* }
*/
@PublishedApi
internal val Project.reflekt: ReflektGradleExtension
get() = project.extensions.findByType(ReflektGradleExtension::class.java) ?: run {
extensions.create("reflekt", ReflektGradleExtension::class.java)
}

/**
* Gradle extension class containing the configuration information for the plugin
* Gradle extension class containing the configuration information for the plugin.
*/
open class ReflektGradleExtension {
/** If `false`, this plugin won't actually be applied */
/** If `false`, this plugin won't actually be applied. */
var enabled: Boolean = true

/**
* Path to which code should be generated.
*
* It would be automatically added to source set and marked
* as generated in IntelliJ IDEA
* It would be automatically added to the source set and marked as generated in IntelliJ IDEA.
*/
var generationPath: String = "build/src/main/kotlin-gen"

Expand All @@ -35,12 +19,3 @@ open class ReflektGradleExtension {
* as a library for ReflektImpl file generation. */
var toSaveMetadata: Boolean = false
}

/**
* Reflekt Generator configuration extension.
*
* @param configure
*/
inline fun Project.reflekt(configure: ReflektGradleExtension.() -> Unit) {
reflekt.apply(configure)
}
Loading

0 comments on commit f5f5fd1

Please sign in to comment.