Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update library versions + move to Kotlin Multiplatform #122

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import at.phatbl.shellexec.ShellExec

plugins {
kotlin("jvm") version "1.7.0" apply false
kotlin("jvm") version "1.9.23" apply false
id("at.phatbl.shellexec") version "1.5.2"
}

val htmlBuildDir = "$buildDir/spec/html"
val pdfBuildDir = "$buildDir/spec/pdf"
val htmlBuildDir = "${layout.buildDirectory.get()}/spec/html"
val pdfBuildDir = "${layout.buildDirectory.get()}/spec/pdf"
val resourcesBuildDir = "$htmlBuildDir/resources"
val jsBuildDir = "$resourcesBuildDir/js"

Expand Down
13 changes: 6 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM pandoc/latex:2.14.2-ubuntu
FROM pandoc/latex:3.1.1-ubuntu
MAINTAINER Marat Akhin <[email protected]>

WORKDIR /source
Expand All @@ -12,12 +12,11 @@ RUN apt-get update
RUN apt-get install -y zulu-11

# install packages for the Kotlin spec
RUN apt-get install -y git
RUN apt-get install -y gpp
RUN apt-get install -y librsvg2-bin
RUN apt-get install -y npm
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y ca-certificates curl gnupg git gpp librsvg2-bin
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update
RUN apt-get install -y nodejs

# install more TeX Live packages
Expand Down
14 changes: 9 additions & 5 deletions docs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ plugins {
group = "org.jetbrains.kotlin.spec"
version = "0.1"

val htmlBuildDir = "$buildDir/spec/html"
val pdfBuildDir = "$buildDir/spec/pdf"
val htmlBuildDir = "${layout.buildDirectory.get()}/spec/html"
val pdfBuildDir = "${layout.buildDirectory.get()}/spec/pdf"
val resourcesBuildDir = "$htmlBuildDir/resources"
val jsBuildDir = "$resourcesBuildDir/js"
val scriptsDir = "$projectDir/scripts/build"
Expand All @@ -24,6 +24,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(11)
}

sourceSets {
main {
java.srcDir("src/main/kotlin")
Expand All @@ -40,7 +44,7 @@ dependencies {
}
}
implementation("com.github.ajalt:clikt:2.8.0")
implementation("com.zaxxer:nuprocess:2.0.3")
implementation("com.zaxxer:nuprocess:2.0.6")
implementation("org.antlr:antlr4:4.8")
}

Expand Down Expand Up @@ -91,12 +95,12 @@ tasks.create("prepareShell") {

if (enableStaticMath) {
appendLine("STATIC_MATH_OPTION=--enable-static-math")
appendLine("KATEX_BIN_OPTION=\"--katex=${rootProject.buildDir}/js/node_modules/.bin/katex\"")
appendLine("KATEX_BIN_OPTION=\"--katex=${rootProject.layout.buildDirectory.get()}/js/node_modules/.bin/katex\"")
}
else appendLine("STATIC_MATH_OPTION=--disable-static-math")
}

File("$buildDir/prepare.sh").writeText("$res")
File("${layout.buildDirectory.get()}/prepare.sh").writeText("$res")
}

}
Expand Down
2 changes: 1 addition & 1 deletion docs/html/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val htmlBuildDir = "${project.parent?.buildDir}/spec/html"
val htmlBuildDir = "${project.parent?.layout?.buildDirectory?.get()}/spec/html"
val scriptsDir = "${project.parent?.projectDir}/scripts/build"

tasks.create<Exec>("build") {
Expand Down
2 changes: 1 addition & 1 deletion docs/htmlSections/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.nio.file.Paths

val htmlBuildDir = "${project.parent?.buildDir}/spec/html"
val htmlBuildDir = "${project.parent?.layout?.buildDirectory?.get()}/spec/html"
val scriptsDir = "${project.parent?.projectDir}/scripts/build"

tasks.create<Exec>("build") {
Expand Down
2 changes: 1 addition & 1 deletion docs/pdf/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val pdfBuildDir = "${project.parent?.buildDir}/spec/pdf"
val pdfBuildDir = "${project.parent?.layout?.buildDirectory}/spec/pdf"
val scriptsDir = "${project.parent?.projectDir}/scripts/build"

tasks.create<Exec>("build") {
Expand Down
2 changes: 1 addition & 1 deletion docs/pdfSections/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.nio.file.Paths

val pdfBuildDir = "${project.parent?.buildDir}/spec/pdf"
val pdfBuildDir = "${project.parent?.layout?.buildDirectory?.get()}/spec/pdf"
val scriptsDir = "${project.parent?.projectDir}/scripts/build"

tasks.create<Exec>("build") {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
20 changes: 15 additions & 5 deletions grammar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.util.regex.Pattern

plugins {
idea
id("org.jetbrains.intellij") version "1.6.0"
id("org.jetbrains.intellij") version "1.17.3"
antlr
`maven-publish`
kotlin("jvm")
Expand Down Expand Up @@ -47,13 +47,21 @@ sourceSets {

dependencies {
implementation("junit:junit:4.13.2")
antlr("org.antlr:antlr4:4.8")
antlr("org.antlr:antlr4:4.13.1")
}

tasks.compileKotlin {
dependsOn("generateGrammarSource")
}

java {
targetCompatibility = JavaVersion.VERSION_11
}

kotlin {
jvmToolchain(11)
}

intellij {
version.set("IC-2022.1")
}
Expand Down Expand Up @@ -155,9 +163,9 @@ tasks.create("prepareDiagnosticsCompilerTests") {

val instrumentTestCodeTask = tasks.named("instrumentTestCode")

tasks.named("inspectClassesForKotlinIC") {
dependsOn(instrumentTestCodeTask)
}
// tasks.named("inspectClassesForKotlinIC") {
// dependsOn(instrumentTestCodeTask)
// }

tasks.withType<Jar> {
dependsOn(instrumentTestCodeTask)
Expand All @@ -172,5 +180,7 @@ tasks.withType<Jar> {
)
}

duplicatesStrategy = DuplicatesStrategy.INCLUDE

from(configurations.runtimeClasspath.get().files.map { if (it.isDirectory) it else zipTree(it) })
}
2 changes: 1 addition & 1 deletion grammar/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
28 changes: 14 additions & 14 deletions web/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.Mode
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput

plugins {
kotlin("js")
kotlin("multiplatform")
}

group = "org.jetbrains.kotlin.spec"
Expand All @@ -12,19 +12,18 @@ val buildMode = findProperty("mode")?.toString() ?: "production" // production |

repositories {
mavenCentral()
jcenter()
}

tasks.create<Copy>("copyKatex") {
dependsOn(":kotlinNpmInstall")
group = "internal"

from("$rootDir/build/js/node_modules/katex/dist")
into("$buildDir/js/katex".also { File(it).mkdirs() })
into("${layout.buildDirectory.get()}/js/katex".also { File(it).mkdirs() })
}

kotlin {
js {
js(IR) {
moduleName = "main"
compilations.all {
packageJson {
Expand All @@ -35,32 +34,33 @@ kotlin {
moduleKind = "amd"
}
}
binaries.executable()
browser {
webpackTask {
webpackTask(Action {
dependsOn("copyKatex")

output.apply {
libraryTarget = KotlinWebpackOutput.Target.AMD
library = "main"
}

destinationDirectory = file("${buildDir}/js")
outputFileName = "main.js"
outputDirectory = file("${layout.buildDirectory.get()}/js")
mainOutputFileName = "main.js"

mode = Mode.valueOf(buildMode.toUpperCase())
mode = Mode.valueOf(buildMode.uppercase())
sourceMaps = (mode == Mode.DEVELOPMENT)
}
})
}
}

sourceSets {
main {
val jsMain by getting {
kotlin.srcDir("src/main/kotlin")
dependencies {
compileOnly("kotlin.js.externals:kotlin-js-jquery:2.0.0-0")
implementation(npm("katex", "0.11.1"))
implementation(npm("katex", "0.16.10"))
implementation(npm("jquery", "2.2.4"))
implementation(npm("kotlin-playground", "1.24.2"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.12.0")
implementation(npm("kotlin-playground", "1.30.0"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
}
}
}
Expand Down
88 changes: 88 additions & 0 deletions web/src/main/kotlin/org/jetbrains/kotlin/spec/JQuery.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package org.jetbrains.kotlin.spec

import org.w3c.dom.Element
import org.w3c.dom.HTMLElement

@JsModule("jquery")
@JsNonModule
external fun `$`(selector: dynamic): JQuery

@JsModule("jquery")
@JsNonModule
external interface JQueryCoordinates {
// var left: Number
var top: Number
}

@JsModule("jquery")
@JsNonModule
external interface JQueryEventObject {
fun stopPropagation()
var currentTarget: Element
var target: Element
var keyCode: Number
// var offsetX: Number
var offsetY: Number
}

@JsModule("jquery")
@JsNonModule
external interface JQuery {
fun offset(): JQueryCoordinates
operator fun get(index: Number): HTMLElement?
fun ready(handler: (jQueryAlias: Any? /*= null*/) -> Any): JQuery
fun attr(attributeName: String): String
fun prop(propertyName: String): Any
fun contents(): JQuery
fun addClass(className: String): JQuery
fun removeClass(className: String): JQuery
fun hasClass(className: String): Boolean
fun toggleClass(className: String, swtch: Boolean? = definedExternally /* null */): JQuery
fun prepend(content1: String, vararg content2: Any): JQuery
fun append(content1: String, vararg content2: Any): JQuery
fun appendTo(target: String): JQuery
fun data(key: String, value: Any): JQuery
fun data(key: String): Any
fun data(): Any
fun get(): Array<HTMLElement>
fun children(selector: String? = definedExternally /* null */): JQuery
fun clone(withDataAndEvents: Boolean? = definedExternally /* null */, deepWithDataAndEvents: Boolean? = definedExternally /* null */): JQuery
fun eq(index: Number): JQuery
fun each(func: (index: Number, elem: Element) -> Any?): JQuery
fun empty(): JQuery
fun filter(func: (index: Number, element: Element) -> Any): JQuery
fun find(selector: String): JQuery
fun find(element: Element): JQuery
fun find(obj: JQuery): JQuery
fun first(): JQuery
fun `is`(selector: String): Boolean
var length: Number
fun parent(selector: String? = definedExternally /* null */): JQuery
fun parents(selector: String? = definedExternally /* null */): JQuery
fun next(selector: String? = definedExternally /* null */): JQuery
fun nextAll(selector: String? = definedExternally /* null */): JQuery
fun prevAll(selector: String? = definedExternally /* null */): JQuery
fun remove(selector: String? = definedExternally /* null */): JQuery
fun before(content1: String, vararg content2: Any): JQuery
fun html(htmlString: String): JQuery
fun css(propertyName: String, value: String): JQuery
fun css(propertyName: String, value: Number): JQuery
fun text(): String
fun focus(): JQuery
fun select(): JQuery
fun click(): JQuery
fun keydown(handler: (eventObject: JQueryEventObject) -> Any): JQuery
fun keyup(handler: (eventObject: JQueryEventObject) -> Any): JQuery
fun width(): Number
fun height(): Number
fun fadeTo(duration: Number, opacity: Number, easing: String? = definedExternally /* null */, complete: Function<*>? = definedExternally /* null */): JQuery
fun show(duration: Number? = definedExternally /* null */, complete: Function<*>? = definedExternally /* null */): JQuery
fun toggle(duration: Number? = definedExternally /* null */, complete: Function<*>? = definedExternally /* null */): JQuery
fun on(events: String, handler: (eventObject: JQueryEventObject, args: Any) -> Any): JQuery
fun on(events: String, selector: String, handler: (eventObject: JQueryEventObject, eventData: Any) -> Any): JQuery
fun scroll(handler: (eventObject: JQueryEventObject) -> Any): JQuery
fun scrollTop(): Number
fun scrollTop(value: Number): JQuery
fun `val`(): Any
fun `val`(value: String): JQuery
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jetbrains.kotlin.spec.entity.test.parameters

import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonPrimitive

/** contains all options which could be defined in testMap.json's tests */
private enum class TestElementKey(val value: String) {
Expand All @@ -26,13 +27,13 @@ class TestInfo(jsonSpecTestInfo: JsonObject, val testNumber: Int) {


init {
fun parse(testElementKey: TestElementKey) = jsonSpecTestInfo[testElementKey.value]?.primitive?.content
fun parse(testElementKey: TestElementKey) = jsonSpecTestInfo[testElementKey.value]?.jsonPrimitive?.content
specVersion = parse(TestElementKey.SPEC_VERSION) ?: ""
casesNumber = parse(TestElementKey.CASES_NUMBER)?.toInt() ?: 1
description = parse(TestElementKey.DESCRIPTION) ?: ""
path = parse(TestElementKey.PATH) ?: ""
unexpectedBehaviour = parse(TestElementKey.UNEXPECTED_BEHAVIOUR)?.toBoolean() ?: false
linkType = parse(TestElementKey.LINK_TYPE)?.let { LinkType.valueOf(it) } ?: LinkType.main
helpers = parse(TestElementKey.HELPERS)?.split(",")?.map { it -> it.trim() }?.toSet() ?: emptySet()
helpers = parse(TestElementKey.HELPERS)?.split(",")?.map(String::trim)?.toSet() ?: emptySet()
}
}
Loading
Loading