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

Make the kotlinpoet module multi-platform and add source set configuration for the JS and wasmJs platforms #1959

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ae89e37
Apply the JS and WasmJs source sets to the main module and move the c…
ForteScarlet Aug 10, 2024
a46a5a7
Migrating the Util.kt to common
ForteScarlet Aug 10, 2024
4d24217
Migrating JvmDefaultWithCompatibility to common
ForteScarlet Aug 10, 2024
52068af
Creating type aliases for JVM platform compatibility
ForteScarlet Aug 10, 2024
02569d1
Migrate types that have no or little use for platform content, such a…
ForteScarlet Aug 10, 2024
92495f2
Migrate NameAllocator to common and add a new CodePoint implementatio…
ForteScarlet Aug 10, 2024
511e8e8
Add the yarn.lock and apply spotless in stages
ForteScarlet Aug 10, 2024
6a9198d
Migrate OriginatingElementsHolder.kt to common
ForteScarlet Aug 10, 2024
43197b0
Migrate Taggable.kt to common
ForteScarlet Aug 10, 2024
5259b9c
Migrate TypeName, WildcardTypeName, ParameterizedTypeName, ClassName,…
ForteScarlet Aug 10, 2024
11522f1
Migrate Documentable to common
ForteScarlet Aug 10, 2024
8c8ddeb
Migrate ContextReceivable and Dynamic to common
ForteScarlet Aug 10, 2024
e31e57c
Migrate MemberName to common
ForteScarlet Aug 10, 2024
462aa07
Migrate TypeAliasTag to common
ForteScarlet Aug 10, 2024
80fb80d
Migrate LineWrapper to common
ForteScarlet Aug 10, 2024
28248a9
Migrate ParameterSpec to common
ForteScarlet Aug 10, 2024
c3719ec
Migrate TypeAliasSpec ad TypeVariableName to common.
ForteScarlet Aug 10, 2024
3dfd12f
Migrate LambdaTypeName to common.
ForteScarlet Aug 10, 2024
d5be4e7
Migrate FunSpec and PropertySpec to common.
ForteScarlet Aug 10, 2024
16a0cf0
Migrate MemberSpecHolder to common.
ForteScarlet Aug 10, 2024
4725895
Migrate TypeSpec and TypeSpecHolder to common.
ForteScarlet Aug 10, 2024
e158bba
Migrate FileSpec to common.
ForteScarlet Aug 10, 2024
3151780
Migrate CodeWriter to common.
ForteScarlet Aug 10, 2024
63440e7
Migrate JvmAnnotations.kt to common.
ForteScarlet Aug 10, 2024
12b6818
Restore functions in Taggable that waited for type migration before t…
ForteScarlet Aug 10, 2024
e44b6fb
Restoring a Temporary TODO in AnnotationSpec
ForteScarlet Aug 10, 2024
0c04c8d
Complementary TypeName.kt missing platform implementation TypeName.no…
ForteScarlet Aug 10, 2024
4e062d9
Apply apiDump
ForteScarlet Aug 10, 2024
97755a2
Fix some of the noisy changes.
ForteScarlet Aug 10, 2024
7afe913
Create an expected typealias Closeable for java.io.Closeable
ForteScarlet Aug 10, 2024
dcfab3f
Adjust and optimize the structure of CodePoint and the logic of some …
ForteScarlet Aug 10, 2024
ca71f03
Edit changelog.md
ForteScarlet Aug 10, 2024
9133127
Try to edit `String.isIdentifier` in `Util.kt` to make it usable on t…
ForteScarlet Aug 26, 2024
36c8e23
Fix some blank lines, typos and indentation issues
ForteScarlet Aug 29, 2024
9343ea2
Remove the browser's tests configuration
ForteScarlet Aug 29, 2024
71a69af
Move `JvmTypeElement.asClassName` to JVM platform
ForteScarlet Aug 29, 2024
8eed20b
Clean up the standalone `Closeable` type and implement `kotlin.AutoCl…
ForteScarlet Aug 29, 2024
584fe49
Remove the browser's tests configuration for js platform
ForteScarlet Sep 2, 2024
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
70 changes: 63 additions & 7 deletions kotlinpoet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
Expand All @@ -23,11 +24,12 @@ spotless {
kotlin {
targetExclude(
// Non-Square licensed files
"src/commonMain/kotlin/com/squareup/kotlinpoet/ClassName.kt",
"src/commonTest/kotlin/com/squareup/kotlinpoet/AbstractTypesTest.kt",
"src/commonTest/kotlin/com/squareup/kotlinpoet/ClassNameTest.kt",
"src/commonTest/kotlin/com/squareup/kotlinpoet/TypesEclipseTest.kt",
"src/commonTest/kotlin/com/squareup/kotlinpoet/TypesTest.kt",
"src/*Main/kotlin/com/squareup/kotlinpoet/ClassName.kt",
"src/*Main/kotlin/com/squareup/kotlinpoet/ClassName.*.kt",
Egorand marked this conversation as resolved.
Show resolved Hide resolved
"src/*Test/kotlin/com/squareup/kotlinpoet/AbstractTypesTest.kt",
"src/*Test/kotlin/com/squareup/kotlinpoet/ClassNameTest.kt",
"src/*Test/kotlin/com/squareup/kotlinpoet/TypesEclipseTest.kt",
"src/*Test/kotlin/com/squareup/kotlinpoet/TypesTest.kt",
)
}
}
Expand All @@ -37,19 +39,61 @@ kotlin {
withJava()
}

js {
browser {
testTask {
useKarma {
useChromeHeadless()
}
}
}
nodejs {
testTask {
useMocha()
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to run the tests in both the browser and on Node. Just Node is fine.

binaries.library()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: delete empty line.

}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser {
testTask {
useKarma {
useChromeHeadless()
}
}
}
nodejs {
testTask {
useMocha()
}
}
binaries.library()
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
allWarningsAsErrors.set(true)
optIn.add("com.squareup.kotlinpoet.DelicateKotlinPoetApi")
freeCompilerArgs.add("-Xexpect-actual-classes")
Egorand marked this conversation as resolved.
Show resolved Hide resolved
}

sourceSets {
val commonMain by getting {
commonMain {
dependencies {
implementation(libs.kotlin.reflect)
}
}
val commonTest by getting {

commonTest {
dependencies {
implementation(kotlin("test"))
}
}

jvmTest {
dependencies {
implementation(libs.kotlin.junit)
implementation(libs.truth)
Expand All @@ -62,6 +106,18 @@ kotlin {
implementation(libs.kotlin.compilerEmbeddable)
}
}

val nonJvmMain by creating {
dependsOn(commonMain.get())
}

jsMain {
dependsOn(nonJvmMain)
}
wasmJsMain {
dependsOn(nonJvmMain)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove empty line.

}
}

Expand Down
1 change: 1 addition & 0 deletions kotlinpoet/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ POM_ARTIFACT_ID=kotlinpoet
POM_NAME=KotlinPoet
POM_DESCRIPTION=Use beautiful Kotlin code to generate beautiful Kotlin code.
POM_PACKAGING=jar
kotlin.mpp.applyDefaultHierarchyTemplate=false
Egorand marked this conversation as resolved.
Show resolved Hide resolved