Skip to content
Draft
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
8 changes: 8 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:tsconfig-to-swcconfig/package_json.bzl", tsconfig_to_swcconfig = "bin")
load("@rules_kotlin//kotlin:core.bzl", "kt_kotlinc_options")

package(default_visibility = ["//visibility:public"])

Expand All @@ -21,6 +22,7 @@ exports_files([
"README.md",
"requirements.txt",
".pylintrc",
"detekt.yml",
])

js_library(
Expand Down Expand Up @@ -97,3 +99,9 @@ tsconfig_to_swcconfig.t2s(
stdout = ".swcrc",
visibility = ["//:__subpackages__"],
)

kt_kotlinc_options(
name = "kt_opts",
jvm_target = "21",
visibility = ["//visibility:public"],
)
40 changes: 40 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,48 @@ pip.parse(

use_repo(pip, "pypi")

####### Kotlin #########
bazel_dep(name = "rules_kotlin", version = "2.2.1")
bazel_dep(name = "rules_detekt", version = "0.8.1.13")
bazel_dep(name = "rules_jvm_external", version = "6.9")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
known_contributing_modules = ["bazel_worker_java", "player-lang"],
artifacts = [
"org.jetbrains.kotlin:kotlin-stdlib:2.3.0",
"org.jetbrains.kotlin:kotlin-test:2.3.0",
"org.jetbrains.kotlin:kotlin-test-junit5:2.3.0",
"org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0",
"io.kotest:kotest-runner-junit5:6.0.7",
"io.kotest:kotest-assertions-core:6.0.7",
"io.kotest:kotest-assertions-json:6.0.7",
"org.junit.jupiter:junit-jupiter-api:5.7.2",
"org.junit.jupiter:junit-jupiter-engine:5.7.2",
"org.junit.jupiter:junit-jupiter-params:5.7.2",
"org.junit.platform:junit-platform-commons:1.7.2",
"org.junit.platform:junit-platform-console:1.7.2",
"org.junit.platform:junit-platform-engine:1.7.2",
"org.junit.platform:junit-platform-launcher:1.7.2",
"org.junit.platform:junit-platform-suite-api:1.7.2",
"org.apiguardian:apiguardian-api:1.0.0",
"org.opentest4j:opentest4j:1.1.1",
"com.intuit.playerui.xlr:xlr-types:0.2.0--canary.4.100-SNAPSHOT",
"com.squareup:kotlinpoet-jvm:2.1.0",
],
repositories = [
"https://repo1.maven.org/maven2",
"https://central.sonatype.com/repository/maven-snapshots",
],
)
use_repo(maven, "maven")
########################

build_constants = use_repo_rule("@rules_player//distribution:defs.bzl", "build_constants")
build_constants(
name = "build_constants",
constants = {
"GROUP": "com.intuit.playerui.lang",
},
version_file = "//:VERSION",
)
135 changes: 50 additions & 85 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Detekt configuration for Player Language Kotlin modules.
# Used with build_upon_default_config = True, so only overrides are needed.
# ktlint handles naming, comments, and formatting — those rulesets are disabled here.

complexity:
active: true
CyclomaticComplexMethod:
active: true
threshold: 25
LongMethod:
active: true
threshold: 80
LongParameterList:
active: true
functionThreshold: 8
constructorThreshold: 10
TooManyFunctions:
active: true
thresholdInFiles: 40
thresholdInClasses: 30
thresholdInInterfaces: 15
thresholdInObjects: 20
NestedBlockDepth:
active: true
threshold: 6
NestedScopeFunctions:
active: true
threshold: 3

coroutines:
active: true

empty-blocks:
active: true

exceptions:
active: true

naming:
active: false

comments:
active: false

potential-bugs:
active: true

style:
active: true
ForbiddenComment:
active: false
MagicNumber:
active: false
MaxLineLength:
active: false
NewLineAtEndOfFile:
active: false
NoTabs:
active: false
OptionalAbstractKeyword:
active: false
BracesOnWhenStatements:
active: false
ReturnCount:
active: false
ThrowsCount:
active: false
TrailingWhitespace:
active: false
WildcardImport:
active: false
UnusedImports:
active: true
UnusedParameter:
active: true
UnusedPrivateClass:
active: true
UnusedPrivateMember:
active: true
UnusedPrivateProperty:
active: true
UnnecessaryAbstractClass:
active: true
UnnecessaryAnnotationUseSiteTarget:
active: true
UnnecessaryApply:
active: true
UnnecessaryFilter:
active: true
UnnecessaryInheritance:
active: true
UnnecessaryLet:
active: true
UnnecessaryParentheses:
active: true
32 changes: 32 additions & 0 deletions dsl/kotlin/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# EditorConfig for Kotlin code style
# https://editorconfig.org/

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
trim_trailing_whitespace = true

[*.kt]
# ktlint specific rules
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_package-name = disabled

# Allow trailing commas
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled

# Function signature - allow multi-line
ktlint_standard_function-signature = disabled

# Disable some strict rules for DSL-style code
ktlint_standard_parameter-list-wrapping = disabled
ktlint_standard_argument-list-wrapping = disabled

[*.kts]
ktlint_standard_no-wildcard-imports = disabled
59 changes: 59 additions & 0 deletions dsl/kotlin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
load("@rules_player//kotlin:defs.bzl", "kt_jvm")
load("@rules_kotlin//kotlin:core.bzl", "kt_compiler_plugin")
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_config")
load("@rules_detekt//detekt:defs.bzl", "detekt_test")
load("@build_constants//:constants.bzl", "GROUP", "VERSION")

package(default_visibility = ["//visibility:public"])

ktlint_config(
name = "lint_config",
editorconfig = ".editorconfig",
)

kt_compiler_plugin(
name = "serialization_plugin",
compile_phase = True,
id = "org.jetbrains.kotlin.serialization",
stubs_phase = True,
deps = ["@rules_kotlin//kotlin/compiler:kotlin-serialization-compiler-plugin"],
)

kt_jvm_library(
name = "kotlin_serialization",
srcs = [],
exported_compiler_plugins = [":serialization_plugin"],
exports = ["@maven//:org_jetbrains_kotlinx_kotlinx_serialization_json"],
)

detekt_test(
name = "detekt",
srcs = glob(["src/main/kotlin/**/*.kt", "src/test/kotlin/**/*.kt"]),
cfgs = ["//:detekt.yml"],
build_upon_default_config = True,
html_report = True,
tags = ["manual"],
)

kt_jvm(
name = "kotlin-dsl",
group = GROUP,
version = VERSION,
lint_config = ":lint_config",
main_opts = "//:kt_opts",
main_deps = [
":kotlin_serialization",
"@maven//:org_jetbrains_kotlin_kotlin_stdlib",
],
test_package = "com.intuit.playerui.lang.dsl",
test_opts = "//:kt_opts",
test_deps = [
"@maven//:io_kotest_kotest_assertions_core",
"@maven//:io_kotest_kotest_assertions_json",
"@maven//:io_kotest_kotest_runner_junit5",
"@maven//:org_jetbrains_kotlin_kotlin_stdlib",
"@maven//:org_junit_platform_junit_platform_console",
],
pom_template = ":pom.tpl",
)
44 changes: 44 additions & 0 deletions dsl/kotlin/pom.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<name>Player Language - {artifactId}</name>
<description>Kotlin DSL for building Player UI content</description>
<url>https://github.com/player-ui/language</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<id>rafbcampos</id>
<name>Rafael Campos</name>
</developer>
<developer>
<id>sugarmanz</id>
<name>Jeremiah Zucker</name>
</developer>
<developer>
<id>brocollie08</id>
<name>Tony Lin</name>
</developer>
</developers>
<scm>
<connection>https://github.com/player-ui/language.git</connection>
<developerConnection>https://github.com/player-ui/language.git</developerConnection>
<tag>v{version}</tag>
<url>https://github.com/player-ui/language.git</url>
</scm>

<groupId>{groupId}</groupId>
<artifactId>{artifactId}</artifactId>
<version>{version}</version>
<packaging>{type}</packaging>

<dependencies>
{dependencies}
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.intuit.playerui.lang.dsl

/**
* DSL marker to prevent scope leakage in nested builder blocks.
* This ensures that methods from outer builders are not accessible
* in nested builder scopes, preventing accidental property assignments
* to the wrong builder.
*/
@DslMarker
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE)
annotation class FluentDslMarker
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.intuit.playerui.lang.dsl.core

/**
* Wrapper for builders that should be wrapped in AssetWrapper format.
* Used by generated builders to wrap nested assets.
*/
@JvmInline
value class AssetWrapperBuilder(
val builder: FluentBuilder<*>,
)
Loading