Skip to content

Commit

Permalink
Upgrades to Kotlin and Gradle versions (#208)
Browse files Browse the repository at this point in the history
* Upgraded Kotlin to 1.8; Upgraded Gradle to 7.6; Addressing code deprecation warnings; Removed Jackson dependency for JVMTest subset

* Upgraded Kotlin to 1.8.20; Upgraded Gradle to 8.1.1
  • Loading branch information
severn-everett committed May 31, 2023
1 parent 3466e6f commit 18bc15c
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 83 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
[![Kotlin Stable](https://kotl.in/badges/stable.svg)](https://kotlinlang.org/docs/components-stability.html)
[![Official JetBrains Project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-green.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
[![Kotlin](https://img.shields.io/badge/kotlin-1.7.10-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/kotlin-1.8.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![npm](https://img.shields.io/npm/v/kotlinx-html.svg)](https://www.npmjs.com/package/kotlinx-html)
[![TeamCity (simple build status)](https://teamcity.jetbrains.com/app/rest/builds/aggregated/strob:\(branch:\(buildType:\(id:KotlinTools_KotlinxHtml_BuildGradleMasterBranch\),policy:active_history_and_active_vcs_branches\),locator:\(buildType:\(id:KotlinTools_KotlinxHtml_BuildGradleMasterBranch\)\)\)/statusIcon.svg)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=KotlinTools_KotlinxHtml_BuildGradleMasterBranch&branch_Kotlin_KotlinX=%3Cdefault%3E&tab=buildTypeStatusDiv&guest=1)

Expand Down
11 changes: 3 additions & 8 deletions build.gradle.kts
@@ -1,14 +1,12 @@
import Build_gradle.MavenPomFile
import kotlinx.html.js.packageJson
import org.apache.tools.ant.taskdefs.condition.Os
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsSetupTask

/**
* This build script supports following parameters:
* -PversionTag - works together with "branch-build" profile and overrides "-SNAPSHOT" suffix of the version.
*/
plugins {
kotlin("multiplatform") version "1.7.10"
kotlin("multiplatform") version "1.8.20"
id("maven-publish")
id("signing")
}
Expand Down Expand Up @@ -192,16 +190,13 @@ kotlin {

val jvmMain by getting {
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("stdlib"))
}
}

val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
/* Jackson is required to parse declarations.json. */
implementation("com.fasterxml.jackson.core:jackson-core:2.10.1")
implementation("com.fasterxml.jackson.core:jackson-databind:2.10.1")
}
}

Expand Down Expand Up @@ -244,7 +239,7 @@ tasks.withType<Jar> {
"Build-Jdk" to System.getProperty("java.version"),
"Implementation-Vendor" to "JetBrains s.r.o.",
"Implementation-Version" to archiveVersion.get(),
"Created-By" to org.gradle.util.GradleVersion.current()
"Created-By" to GradleVersion.current()
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
@@ -1,12 +1,12 @@
plugins {
kotlin("jvm") version "1.7.10"
kotlin("jvm") version "1.8.20"
}

repositories {
mavenCentral()
}

dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("stdlib"))
implementation("com.sun.xsom:xsom:20140925")
}
Expand Up @@ -41,7 +41,7 @@ fun Appendable.facade(facade: AttributeFacade) {
}

facade.attributes.filter { !isAttributeExcluded(it.name) }.forEach { attribute ->
if (attribute.name.isLowerCase() || attribute.name.toLowerCase() !in facade.attributeNames) {
if (attribute.name.isLowerCase() || attribute.name.lowercase() !in facade.attributeNames) {
attributeProperty(attribute, receiver = facadeName, indent = 0)
}
}
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/kotlinx/html/generate/codegen.kt
Expand Up @@ -35,11 +35,11 @@ fun Appendable.import(name : String) {
fun Appendable.doNotEditWarning() {
append("/")
append("*".repeat(79))
appendln()
appendLine()
append(" DO NOT EDIT")
appendln()
appendLine()
append(" This file was generated by module generate")
appendln()
appendLine()
append("*".repeat(79))
append("/")
}
Expand Down Expand Up @@ -211,7 +211,7 @@ fun <O : Appendable> O.defineIs(expression : CharSequence) : O {
return this
}

fun Appendable.emptyLine() { appendln() }
fun Appendable.emptyLine() { appendLine() }

fun <T> T.with(block : T.() -> Unit) : T {
block()
Expand Down
8 changes: 5 additions & 3 deletions buildSrc/src/main/kotlin/kotlinx/html/generate/enums.kt
@@ -1,5 +1,7 @@
package kotlinx.html.generate

import java.util.*

val reservedNames = setOf("class", "val", "var", "object", "true", "false", "as", "is", "for")

fun String.replaceIfReserved() = if (this in reservedNames) "html" + this.capitalize() else this
Expand All @@ -10,7 +12,7 @@ fun List<String>.toAttributeValues() : List<AttributeEnumValue> =
fun Appendable.enumObject(attribute : AttributeInfo) {
val name = attribute.enumTypeName

appendln("@Suppress(\"unused\")")
appendLine("@Suppress(\"unused\")")
clazz(Clazz(name, isObject = true)) {
attribute.enumValues.forEach {
append(" ")
Expand All @@ -32,7 +34,7 @@ fun Appendable.enum(attribute : AttributeInfo) {
val name = attribute.enumTypeName
val realValue = Var("realValue", "String", false, true)

appendln("@Suppress(\"unused\")")
appendLine("@Suppress(\"unused\")")
append("enum ")
clazz(Clazz(name, variables = listOf(realValue), parents = listOf("AttributeEnum"))) {
attribute.enumValues.forEachIndexed { idx, it ->
Expand All @@ -45,7 +47,7 @@ fun Appendable.enum(attribute : AttributeInfo) {
append(",")
}

appendln()
appendLine()
}
}

Expand Down
Expand Up @@ -5,7 +5,7 @@ fun String.humanize() : String {
return "empty"
}

val fixedAllUpper = if (all { it.isUpperCase() }) toLowerCase() else this
val fixedAllUpper = if (all { it.isUpperCase() }) lowercase() else this
val fixedFirstUpper = fixedAllUpper.decapitalize()

return fixedFirstUpper.replaceHyphensToCamelCase().makeCamelCaseByDictionary().replaceMistakesAndUglyWords().decapitalize()
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/kotlinx/html/generate/kdoc.kt
Expand Up @@ -15,7 +15,7 @@ fun fillKdocRepositoryExtension() {
KdocRepository.tags = parseDocInfos()
}

val TagInfo.kdoc: KDocInfo? get() = KdocRepository.tags[this.name.toLowerCase()]
val TagInfo.kdoc: KDocInfo? get() = KdocRepository.tags[this.name.lowercase()]

private fun parseDocInfos(): Map<String, KDocInfo> {
val html = parseDocInfo(HTML_TABLE_URL)
Expand All @@ -30,7 +30,7 @@ private fun parseDocInfo(xmlPath: URL): List<KDocInfo> {

return xml.getElementsByTagName("tag").asList().map { node ->
KDocInfo(
name = node.getAttributeString("name").toLowerCase(),
name = node.getAttributeString("name").lowercase(),
description = node.getAttributeString("description").capitalize(),
helpref = node.getAttributeString("helpref")
)
Expand Down
14 changes: 7 additions & 7 deletions buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt
Expand Up @@ -63,8 +63,8 @@ fun generate(packg: String, todir: String, jsdir: String) {
emptyLine()

Repository.tags.values.filterIgnored().forEach {
val contentlessTag = it.name.toLowerCase() in contentlessTags
if (it.possibleChildren.isEmpty() && it.name.toLowerCase() !in emptyTags && !contentlessTag) {
val contentlessTag = it.name.lowercase() in contentlessTags
if (it.possibleChildren.isEmpty() && it.name.lowercase() !in emptyTags && !contentlessTag) {
consumerBuilderShared(it, false)
} else if (contentlessTag) {
deprecated("This tag doesn't support content or requires unsafe (try unsafe {})")
Expand Down Expand Up @@ -92,8 +92,8 @@ fun generate(packg: String, todir: String, jsdir: String) {
emptyLine()

Repository.tags.values.filterIgnored().forEach {
val contentlessTag = it.name.toLowerCase() in contentlessTags
if (it.possibleChildren.isEmpty() && it.name.toLowerCase() !in emptyTags && !contentlessTag) {
val contentlessTag = it.name.lowercase() in contentlessTags
if (it.possibleChildren.isEmpty() && it.name.lowercase() !in emptyTags && !contentlessTag) {
consumerBuilderJS(it, false)
} else if (contentlessTag) {
deprecated("This tag doesn't support content or requires unsafe (try unsafe {})")
Expand Down Expand Up @@ -272,10 +272,10 @@ fun generate(packg: String, todir: String, jsdir: String) {
}

append(";")
appendln()
appendLine()

variable(Var(name = "text", type = "String"))
appendln()
appendLine()
getter()
defineIs(StringBuilder().apply {
append("&".quote())
Expand All @@ -285,7 +285,7 @@ fun generate(packg: String, todir: String, jsdir: String) {
append(" + ")
append(";".quote())
})
appendln()
appendLine()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/kotlinx/html/generate/model.kt
Expand Up @@ -73,7 +73,7 @@ data class AttributeInfo(
val HasType.typeName : String
get() = if (type == AttributeType.ENUM) enumTypeName else type.typeName

fun String.isLowerCase() = this.toLowerCase() == this
fun String.isLowerCase() = this.lowercase() == this

data class TagInfo(
val name : String,
Expand All @@ -84,7 +84,7 @@ data class TagInfo(
val suggestedAttributes : Set<String>,
val tagGroupNames: List<String>
) {
val className: String = name.humanize().toUpperCase()
val className: String = name.humanize().uppercase()
val memberName: String = name.humanize().replaceIfReserved()
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/kotlinx/html/generate/rules.kt
Expand Up @@ -47,7 +47,7 @@ val tagIgnoreList = setOf(
"menu", "menuitem"
)

fun Iterable<TagInfo>.filterIgnored() = filter { it.name.toLowerCase() !in tagIgnoreList }
fun Iterable<TagInfo>.filterIgnored() = filter { it.name.lowercase() !in tagIgnoreList }

val globalSuggestedAttributeNames = setOf("class")

Expand Down
Expand Up @@ -23,8 +23,8 @@ track
wbr""".lines().toSet()

fun Appendable.htmlTagBuilders(receiver : String, tag : TagInfo) {
val contentlessTag = tag.name.toLowerCase() in contentlessTags
val probablyContentOnly = tag.possibleChildren.isEmpty() && tag.name.toLowerCase() !in emptyTags && !contentlessTag
val contentlessTag = tag.name.lowercase() in contentlessTags
val probablyContentOnly = tag.possibleChildren.isEmpty() && tag.name.lowercase() !in emptyTags && !contentlessTag
htmlTagBuilderMethod(receiver, tag, true)
if (probablyContentOnly) {
htmlTagBuilderMethod(receiver, tag, false)
Expand Down

0 comments on commit 18bc15c

Please sign in to comment.