Skip to content

Commit

Permalink
Implement included build structure to separate versions of Kotlin bet…
Browse files Browse the repository at this point in the history
…ween compiler plugin and other modules
  • Loading branch information
Iaroslav Postovalov committed Oct 24, 2023
1 parent f5f5fd1 commit c075d4b
Show file tree
Hide file tree
Showing 40 changed files with 394 additions and 323 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,3 @@ jobs:
- uses: gradle/gradle-build-action@v2.7.1
with:
arguments: detekt --stacktrace
- uses: github/codeql-action/upload-sarif@v2
if: ${{ always() }}
with:
sarif_file: ./build/reports/detekt/merge.sarif
category: detekt
152 changes: 75 additions & 77 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import io.gitlab.arturbosch.detekt.Detekt
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.cqfn.diktat.plugin.gradle.DiktatExtension
import org.cqfn.diktat.plugin.gradle.DiktatGradlePlugin
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.detekt)
alias(libs.plugins.diktat)
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 = rootProject.layout.buildDirectory.file("reports/detekt/merge.sarif")
alias(libs.plugins.kotlin.jvm)
}

group = "org.jetbrains.reflekt"
Expand All @@ -26,6 +19,7 @@ description = "Reflekt is a compile-time reflection library that leverages the f

allprojects {
apply(plugin = "kotlin")
apply(plugin = "maven-publish")

tasks.withType<KotlinCompile<*>> {
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
Expand All @@ -44,97 +38,101 @@ allprojects {

repositories {
mavenCentral()
// 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("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",
gradle.includedBuild("using-embedded-kotlin").task(":reflekt-dsl:jar")
)
}

apply<DiktatGradlePlugin>()
configure<DiktatExtension> {
diktatConfigFile = rootProject.file("diktat-analysis.yml")

inputs {
include("src/main/**/*.kt")
}
}

configureDiktat()
apply<DetektPlugin>()

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

tasks.withType<Detekt> {
finalizedBy(detektReportMerge)
reports.sarif.required = true
detektReportMerge.get().input.from(sarifReportFile)
publishing.repositories.maven("https://packages.jetbrains.team/maven/p/reflekt/reflekt") {
name = "SpacePackages"

credentials {
username = System.getenv("JB_SPACE_CLIENT_ID").orEmpty()
password = System.getenv("JB_SPACE_CLIENT_SECRET").orEmpty()
}
}
}

createDiktatTask()
configure<DiktatExtension> {
diktatConfigFile = rootProject.file("diktat-analysis.yml")
inputs {
include("./*.kts")
}
}

subprojects {
apply(plugin = "maven-publish")
tasks.register("diktatCheckAll") {
group = LifecycleBasePlugin.VERIFICATION_GROUP

allprojects {
this@register.dependsOn(tasks.getByName("diktatCheck"))
}

if (this@subprojects.name != "reflekt-plugin") {
apply(plugin = "org.jetbrains.dokka")
this@register.dependsOn(gradle.includedBuild("using-embedded-kotlin").task(":diktatCheckAll"))
}

tasks.withType<DokkaTaskPartial> {
dokkaSourceSets.configureEach {
sourceLink {
localDirectory = this@subprojects.file("src/main/kotlin")
tasks.register("diktatFixAll") {
group = LifecycleBasePlugin.VERIFICATION_GROUP

remoteUrl =
URL("https://github.com/JetBrains-Research/${rootProject.name}/tree/master/${this@subprojects.name}/src/main/kotlin/")
}
}
}
allprojects {
this@register.dependsOn(tasks.getByName("diktatFix"))
}
this@register.dependsOn(gradle.includedBuild("using-embedded-kotlin").task(":diktatFixAll"))
}

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:git@github.com:JetBrains-Research/${rootProject.name}.git"
developerConnection = "scm:git:git@github.com:JetBrains-Research/${rootProject.name}.git"
url = "git@github.com:JetBrains-Research/${rootProject.name}.git"
}
}
}
}
}
}
subprojects {
publishing.publications.create<MavenPublication>("mavenJava") {

publishing {
repositories {
maven("https://packages.jetbrains.team/maven/p/reflekt/reflekt") {
name = "SpacePackages"
from(this@subprojects.components["java"])

credentials {
username = System.getenv("JB_SPACE_CLIENT_ID").orEmpty()
password = System.getenv("JB_SPACE_CLIENT_SECRET").orEmpty()
pom {
description = rootProject.description
inceptionYear = "2020"
url = "https://github.com/JetBrains-Research/reflekt"

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

scm {
connection = "scm:git:git@github.com:JetBrains-Research/reflekt.git"
developerConnection = "scm:git:git@github.com:JetBrains-Research/reflekt.git"
url = "git@github.com:JetBrains-Research/reflekt.git"
}
}
}
}

for (it in listOf("publishAllPublicationsToSpacePackagesRepository", "publishToMavenLocal")) {
tasks[it].dependsOn(
gradle.includedBuild("using-embedded-kotlin").task(":reflekt-core:$it"),
gradle.includedBuild("using-embedded-kotlin").task(":reflekt-dsl:$it"),
gradle.includedBuild("using-embedded-kotlin").task(":gradle-plugin:$it"),
)
}
29 changes: 0 additions & 29 deletions buildSrc/build.gradle.kts

This file was deleted.

20 changes: 0 additions & 20 deletions buildSrc/settings.gradle.kts

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ which will help keep your pull request simple and easy to apply.

## Search and fix formatting issues
0. Run building without running detekt: `./gradlew build`
1. To run detekt static analysis checks, use: `./gradlew detektCheckAll` (associated with gitHub Action)
2. To run diktat static analysis checks, use: `./gradlew diktatCheckAll` (associated with gitHub Action)
1. To run detekt static analysis checks, use: `./gradlew detekt` (associated with GitHub Action)
2. To run diktat static analysis checks, use: `./gradlew diktatCheckAll` (associated with GitHub Action)
3. To try to automatically fix issues detected by diktat, use: `./gradlew diktatFixAll`
4. Make sure you're following our Kotlin docs formatting rules.
<details>
Expand Down
13 changes: 8 additions & 5 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ group = rootProject.group
version = rootProject.version

plugins {
id("org.jetbrains.reflekt") version "1.8.21"
id("org.jetbrains.kotlin.jvm") version "1.8.21"
id("org.jetbrains.reflekt") version "1.8.20"
kotlin("jvm") version "1.8.20"
}

allprojects {
Expand All @@ -14,6 +14,11 @@ allprojects {
plugin("org.jetbrains.reflekt")
}

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

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
Expand All @@ -23,7 +28,7 @@ allprojects {
}

dependencies {
implementation("org.jetbrains.reflekt", "reflekt-dsl", "1.8.21")
implementation("org.jetbrains.reflekt", "reflekt-dsl", "1.8.20")
}

repositories {
Expand All @@ -33,6 +38,4 @@ allprojects {
// Uncomment to use a released version
// maven("https://packages.jetbrains.team/maven/p/reflekt/reflekt")
}

reflekt.enabled = true
}
Binary file modified examples/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion examples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit c075d4b

Please sign in to comment.