Skip to content

Commit

Permalink
Update jetbrains/markdown to the latest version (#3655)
Browse files Browse the repository at this point in the history
Remove fastutil workaround as it doesn't any more depend on it
  • Loading branch information
whyoleg committed Jun 26, 2024
1 parent 16139b8 commit 47e4e8d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 109 deletions.
52 changes: 1 addition & 51 deletions dokka-subprojects/analysis-kotlin-descriptors/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 26,8 @@ dependencies {
implementation(projects.dokkaSubprojects.analysisKotlinDescriptorsIde)
}

tasks.withType<ShadowJar>().configureEach {
tasks.shadowJar {
// service files are merged to make sure all Dokka plugins
// from the dependencies are loaded, and not just a single one.
mergeServiceFiles()
}

/**
* hack for shadow jar and fastutil because of kotlin-compiler
*
* KT issue: https://youtrack.jetbrains.com/issue/KT-47150
*
* what is happening here?
* 1. we create intermediate `shadowDependenciesJar` with dependencies but without fastutil classes in it
* 2. then we create final `shadowJar` with full fastutil from maven and dependencies from `shadowDependenciesJar` instead of original dependencies
*
* why do we need this?
* because `kotlin-compiler` artifact includes unshaded (not-relocated) STRIPPED `fastutil` dependency,
* STRIPPED here means, that it doesn't provide full `fastutil` classpath, but only a part of it which is used
* and so when shadowJar task is executed it takes classes from `fastutil` from `kotlin-compiler` and adds it to shadow-jar
* then adds all other classes from `fastutil` coming from `markdown-jb`,
* but because `fastutil` from `kotlin-compiler` is STRIPPED, some classes (like `IntStack`) has no some methods
* and so such classes are not replaced afterward by `shadowJar` task - it visits every class once
*
*/

val shadowOverride: Configuration by configurations.creating {
description = "dependencies which we need to replace with original ones because `kotlin-compiler` minimizes them"
attributes {
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME))
}
}

dependencies {
shadowOverride(libs.fastutil)
}

val shadowDependenciesJar by tasks.registering(ShadowJar::class) {
group = "shadow"
description = "Create a shadow jar from dependencies without fastutil"

archiveClassifier = "dependencies"
destinationDirectory = project.layout.buildDirectory.dir("shadowDependenciesLibs")

// we need to create JAR with dependencies, but without fastutil,
// so we include `runtimeClasspath` configuration (the same configuration which is used by default `shadowJar` task)
// and include `fastutil` from the result
configurations = listOf(project.configurations.runtimeClasspath.get())
exclude("it/unimi/dsi/fastutil/**")
}

tasks.shadowJar {
// override configurations to remove dependencies handled in `shadowJarDependencies`
configurations = emptyList()
from(shadowOverride, shadowDependenciesJar)
}
52 changes: 1 addition & 51 deletions dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,58 59,8 @@ dependencies {
compileOnly(libs.kotlinx.coroutines.core)
}

tasks.withType<ShadowJar>().configureEach {
tasks.shadowJar {
// service files are merged to make sure all Dokka plugins
// from the dependencies are loaded, and not just a single one.
mergeServiceFiles()
}

/**
* hack for shadow jar and fastutil because of kotlin-compiler
*
* KT issue: https://youtrack.jetbrains.com/issue/KT-47150
*
* what is happening here?
* 1. we create intermediate `shadowDependenciesJar` with dependencies but without fastutil classes in it
* 2. then we create final `shadowJar` with full fastutil from maven and dependencies from `shadowDependenciesJar` instead of original dependencies
*
* why do we need this?
* because `kotlin-compiler` artifact includes unshaded (not-relocated) STRIPPED `fastutil` dependency,
* STRIPPED here means, that it doesn't provide full `fastutil` classpath, but only a part of it which is used
* and so when shadowJar task is executed it takes classes from `fastutil` from `kotlin-compiler` and adds it to shadow-jar
* then adds all other classes from `fastutil` coming from `markdown-jb`,
* but because `fastutil` from `kotlin-compiler` is STRIPPED, some classes (like `IntStack`) has no some methods
* and so such classes are not replaced afterward by `shadowJar` task - it visits every class once
*
*/

val shadowOverride: Configuration by configurations.creating {
description = "dependencies which we need to replace with original ones because `kotlin-compiler` minimizes them"
attributes {
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME))
}
}

dependencies {
shadowOverride(libs.fastutil)
}

val shadowDependenciesJar by tasks.registering(ShadowJar::class) {
group = "shadow"
description = "Create a shadow jar from dependencies without fastutil"

archiveClassifier = "dependencies"
destinationDirectory = project.layout.buildDirectory.dir("shadowDependenciesLibs")

// we need to create JAR with dependencies, but without fastutil,
// so we include `runtimeClasspath` configuration (the same configuration which is used by default `shadowJar` task)
// and include `fastutil` from the result
configurations = listOf(project.configurations.runtimeClasspath.get())
exclude("it/unimi/dsi/fastutil/**")
}

tasks.shadowJar {
// override configurations to remove dependencies handled in `shadowJarDependencies`
configurations = emptyList()
from(shadowOverride, shadowDependenciesJar)
}
8 changes: 1 addition & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 29,7 @@ korlibs-template = "4.0.10"
kotlinx-html = "0.9.1"

## Markdown
jetbrains-markdown = "0.5.2"
# This version SHOULD be compatible with both used in `koltin-compiler` and in `jetbrains-markdown`
# version used in `kotlin-compiler` is located in https://github.com/JetBrains/kotlin/blob/c9ad09f4dcaae7792cdf27fbdc8c718443d0ad51/gradle/versions.properties#L14
# verison used in `jetbrains-markdown` is located in https://github.com/JetBrains/markdown/blob/0f10d90f8f75a6c261e6f5a4f23d29c6cf088a92/build.gradle.kts#L92
# In most cases using the latest version should work (be careful during MAJOR or MINOR version changes)
fastutil = "8.5.12"
jetbrains-markdown = "0.7.3"

## JSON
jackson = "2.12.7" # jackson 2.13.X does not support kotlin language version 1.4, check before updating
Expand Down Expand Up @@ -113,7 108,6 @@ korlibs-template = { module = "com.soywiz.korlibs.korte:korte-jvm", version.ref

#### Markdown ####
jetbrains-markdown = { module = "org.jetbrains:markdown", version.ref = "jetbrains-markdown" }
fastutil = { module = "it.unimi.dsi:fastutil", version.ref = "fastutil" }

#### Jackson ####
jackson-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
Expand Down

0 comments on commit 47e4e8d

Please sign in to comment.