Skip to content

Commit 656d46d

Browse files
committed
perf: 尝试更新Kotlin到v1.8.0
1 parent fce86eb commit 656d46d

30 files changed

+571
-1048
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ allprojects {
1212
description = IProject.DESCRIPTION
1313

1414
repositories {
15-
mavenLocal()
1615
mavenCentral()
1716
gradlePluginPortal()
17+
mavenLocal()
1818
//maven {
1919
// url = URI("")
2020
//}

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ val dokkaPluginVersion = "1.7.20"
1414
dependencies {
1515
api(gradleApi())
1616
api(kotlin("gradle-plugin", kotlinVersion))
17+
api(kotlin("serialization", kotlinVersion))
1718
api("org.jetbrains.dokka:dokka-gradle-plugin:$dokkaPluginVersion")
1819

1920
api("com.gradle.publish:plugin-publish-plugin:0.12.0")

buildSrc/src/main/kotlin/suspend-transform.jvm-maven-publish.gradle.kts

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import utils.systemProperty
2-
import utils.by
3-
41
plugins {
52
id("org.jetbrains.dokka")
63
signing
@@ -15,54 +12,53 @@ plugins {
1512
// }
1613

1714

18-
1915
val (sonatypeUsername, sonatypePassword) = sonatypeUserInfoOrNull
2016

2117
val sonatypeContains = sonatypeUserInfoOrNull != null
2218

23-
val jarJavadoc by tasks.registering(Jar::class) {
24-
archiveClassifier.set("javadoc")
25-
// from(tasks.findByName("dokkaHtml"))
26-
}
27-
28-
val jarSources by tasks.registering(Jar::class) {
29-
archiveClassifier.set("sources")
30-
from(sourceSets["main"].allSource)
31-
}
32-
33-
publishing {
34-
publications {
35-
create<MavenPublication>("suspendTransformJvmDist") {
36-
from(components["java"])
37-
artifact(jarSources)
38-
artifact(jarJavadoc)
39-
40-
groupId = project.group.toString()
41-
artifactId = project.name
42-
version = project.version.toString()
43-
}
19+
val jarJavadoc by tasks.registering(Jar::class) {
20+
archiveClassifier.set("javadoc")
21+
// from(tasks.findByName("dokkaHtml"))
22+
}
23+
24+
val jarSources by tasks.registering(Jar::class) {
25+
archiveClassifier.set("sources")
26+
from(sourceSets["main"].allSource)
27+
}
28+
29+
publishing {
30+
publications {
31+
create<MavenPublication>("suspendTransformJvmDist") {
32+
from(components["java"])
33+
artifact(jarSources)
34+
artifact(jarJavadoc)
35+
36+
groupId = project.group.toString()
37+
artifactId = project.name
38+
version = project.version.toString()
39+
}
4440

45-
configureEach {
46-
if (this is MavenPublication) {
47-
pom {
48-
setupPom(project)
49-
}
41+
configureEach {
42+
if (this is MavenPublication) {
43+
pom {
44+
setupPom(project)
5045
}
5146
}
52-
53-
repositories {
54-
mavenLocal()
55-
mavenCentral()
56-
if (sonatypeContains) {
57-
if (project.version.toString().contains("SNAPSHOT", true)) {
58-
configPublishMaven(Sonatype.Snapshot, sonatypeUsername, sonatypePassword)
59-
} else {
60-
configPublishMaven(Sonatype.Central, sonatypeUsername, sonatypePassword)
61-
}
47+
}
48+
49+
repositories {
50+
mavenCentral()
51+
if (sonatypeContains) {
52+
if (project.version.toString().contains("SNAPSHOT", true)) {
53+
configPublishMaven(Sonatype.Snapshot, sonatypeUsername, sonatypePassword)
54+
} else {
55+
configPublishMaven(Sonatype.Central, sonatypeUsername, sonatypePassword)
6256
}
6357
}
58+
mavenLocal()
6459
}
6560
}
61+
}
6662

6763

6864
signing {

buildSrc/src/main/kotlin/suspend-transform.multiplatform-maven-publish.gradle.kts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import gradle.kotlin.dsl.accessors._59a6e08710bd766406b34ec8c4dcd1fe.publishing
21
import gradle.kotlin.dsl.accessors._59a6e08710bd766406b34ec8c4dcd1fe.signing
3-
import utils.systemProperty
42
import utils.by
53

64
plugins {
@@ -25,23 +23,23 @@ publishing {
2523
if (this !is MavenPublication) {
2624
return@configureEach
2725
}
28-
26+
2927
artifact(jarJavadoc)
30-
28+
3129
pom {
3230
setupPom(project)
3331
}
3432
}
35-
33+
3634
repositories {
37-
mavenLocal()
3835
if (sonatypeContains) {
3936
if (project.version.toString().contains("SNAPSHOT", true)) {
4037
configPublishMaven(Sonatype.Snapshot, sonatypeUsername, sonatypePassword)
4138
} else {
4239
configPublishMaven(Sonatype.Central, sonatypeUsername, sonatypePassword)
4340
}
4441
}
42+
mavenLocal()
4543
}
4644
}
4745
}
@@ -67,4 +65,4 @@ fun MavenPublication.jar(taskName: String, config: Action<Jar>) = artifact(tasks
6765
fun MavenPublication.javadocJar(taskName: String, config: Jar.() -> Unit = {}) = jar(taskName) {
6866
archiveClassifier by "javadoc"
6967
config()
70-
}
68+
}

buildSrc/src/main/kotlin/suspend-transform.nexus-publish.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ if (!isPublishConfigurable) {
1919
}
2020

2121

22-
if (isPublishConfigurable) {
23-
val (sonatypeUsername, sonatypePassword) = sonatypeUserInfo
22+
//if (isPublishConfigurable) {
2423
nexusPublishing {
2524
logger.info("[NEXUS] - project.group: ${project.group}")
2625
logger.info("[NEXUS] - project.version: ${project.version}")
@@ -43,6 +42,7 @@ if (isPublishConfigurable) {
4342
repositories {
4443
sonatype {
4544
snapshotRepositoryUrl by uri(Sonatype.Snapshot.URL)
45+
val (sonatypeUsername, sonatypePassword) = sonatypeUserInfoOrNull ?: return@sonatype
4646
username by sonatypeUsername
4747
password by sonatypePassword
4848
}
@@ -51,7 +51,7 @@ if (isPublishConfigurable) {
5151

5252

5353
logger.info("[nexus-publishing-configure] - [{}] configured.", name)
54-
}
54+
//}
5555

5656

5757

compiler/suspend-transform-plugin/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
java
55
kotlin("jvm")
66
kotlin("kapt")
7+
kotlin("plugin.serialization")
78
id("com.github.gmazzo.buildconfig")
89
//id("com.bnorm.power.kotlin-power-assert")
910
id("suspend-transform.jvm-maven-publish")
@@ -16,6 +17,7 @@ dependencies {
1617
compileOnly(kotlin("stdlib"))
1718
compileOnly(kotlin("compiler"))
1819
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
20+
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
1921

2022
// compileOnly(kotlin("compiler-embeddable"))
2123

compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/CliOptions.kt

Lines changed: 17 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,37 @@
11
package love.forte.plugin.suspendtrans
22

3+
import kotlinx.serialization.json.Json
34
import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption
45
import kotlin.reflect.KMutableProperty
56

6-
private typealias ExcludeAnnotation = SuspendTransformConfiguration.ExcludeAnnotation
7-
8-
private const val REPEAT_MARK = "\$&+"
9-
10-
private fun includeAnnotationEncode(value: List<SuspendTransformConfiguration.IncludeAnnotation>): String {
11-
return value.joinToString(",") { if (it.repeatable) "${it.name}$REPEAT_MARK" else it.name }
12-
}
13-
14-
private fun includeAnnotationDecode(value: String): List<SuspendTransformConfiguration.IncludeAnnotation> {
15-
return value.split(",").map {
16-
val annotationName = it.substringBeforeLast(REPEAT_MARK)
17-
val repeat = annotationName != it
18-
SuspendTransformConfiguration.IncludeAnnotation(annotationName, repeat)
19-
}
7+
private val defaultJson = Json {
8+
isLenient = true
9+
ignoreUnknownKeys = true
10+
encodeDefaults = true
2011
}
2112

2213
object CliOptions {
2314

2415
const val CONFIGURATION = "configuration"
25-
val ENABLED = option("enabled") {
26-
inc { enabled = it.toBoolean() }
27-
out { enabled.toString() }
28-
}
29-
30-
object Jvm {
31-
32-
val ORIGIN_FUNCTION_INCLUDE_ANNOTATIONS = option("jvm.originFunctionIncludeAnnotations") {
33-
inc { jvm.originFunctionIncludeAnnotations = includeAnnotationDecode(it) }
34-
// TODO
35-
out { includeAnnotationEncode(jvm.originFunctionIncludeAnnotations ?: emptyList()) }
36-
}
37-
38-
39-
//region blocking
40-
val JVM_BLOCKING_FUNCTION_NAME = option("jvm.jvmBlockingFunctionName") {
41-
// TODO
42-
withNullableProp { jvm::jvmBlockingFunctionName }
43-
}
44-
45-
//region blocking mark
46-
const val JVM_BLOCKING_MARK_ANNOTATION = "jvm.jvmBlockingMarkAnnotation"
47-
48-
val JVM_BLOCKING_MARK_ANNOTATION_ANNOTATION_NAME =
49-
JVM_BLOCKING_MARK_ANNOTATION.option("annotationName") {
50-
withProp { jvm.jvmBlockingMarkAnnotation::annotationName }
51-
}
52-
val JVM_BLOCKING_MARK_ANNOTATION_BASE_NAME_PROPERTY =
53-
JVM_BLOCKING_MARK_ANNOTATION.option("baseNameProperty") {
54-
withProp { jvm.jvmBlockingMarkAnnotation::baseNameProperty }
55-
}
56-
val JVM_BLOCKING_MARK_ANNOTATION_SUFFIX_PROPERTY =
57-
JVM_BLOCKING_MARK_ANNOTATION.option("suffixProperty") {
58-
withProp { jvm.jvmBlockingMarkAnnotation::suffixProperty }
59-
}
60-
val JVM_BLOCKING_MARK_ANNOTATION_AS_PROPERTY_PROPERTY =
61-
JVM_BLOCKING_MARK_ANNOTATION.option("asPropertyProperty") {
62-
withProp { jvm.jvmBlockingMarkAnnotation::asPropertyProperty }
63-
}
64-
//endregion
65-
66-
val COPY_ANNOTATIONS_TO_SYNTHETIC_BLOCKING_FUNCTION =
67-
option("jvm.copyAnnotationsToSyntheticBlockingFunction") {
68-
inc { jvm.copyAnnotationsToSyntheticBlockingFunction = it.toBoolean() }
69-
out { jvm.copyAnnotationsToSyntheticBlockingFunction.toString() }
70-
}
71-
const val COPY_ANNOTATIONS_TO_SYNTHETIC_BLOCKING_FUNCTION_EXCLUDES =
72-
"jvm.copyAnnotationsToSyntheticBlockingFunctionExcludes"
73-
74-
val COPY_ANNOTATIONS_TO_SYNTHETIC_BLOCKING_FUNCTION_EXCLUDES_NAME =
75-
COPY_ANNOTATIONS_TO_SYNTHETIC_BLOCKING_FUNCTION_EXCLUDES.option("name") {
76-
inc { jvm.copyAnnotationsToSyntheticBlockingFunctionExcludes = it.split(",").map(::ExcludeAnnotation) }
77-
out { jvm.copyAnnotationsToSyntheticBlockingFunctionExcludes.joinToString(",") { it.name } }
78-
79-
}
80-
81-
val SYNTHETIC_BLOCKING_FUNCTION_INCLUDE_ANNOTATIONS =
82-
option("jvm.syntheticBlockingFunctionIncludeAnnotations") {
83-
inc { jvm.syntheticBlockingFunctionIncludeAnnotations = includeAnnotationDecode(it) }
84-
// TODO
85-
out { includeAnnotationEncode(jvm.syntheticBlockingFunctionIncludeAnnotations ?: emptyList()) }
86-
}
87-
88-
//endregion
89-
90-
91-
//region async
92-
val JVM_ASYNC_FUNCTION_NAME = option("jvm.jvmAsyncFunctionName") {
93-
// TODO
94-
withNullableProp { jvm::jvmAsyncFunctionName }
95-
}
96-
97-
//region async mark
98-
const val JVM_ASYNC_MARK_ANNOTATION = "jvm.jvmAsyncMarkAnnotation"
99-
100-
val JVM_ASYNC_MARK_ANNOTATION_ANNOTATION_NAME =
101-
JVM_ASYNC_MARK_ANNOTATION.option("annotationName") {
102-
withProp { jvm.jvmAsyncMarkAnnotation::annotationName }
103-
}
104-
val JVM_ASYNC_MARK_ANNOTATION_BASE_NAME_PROPERTY =
105-
JVM_ASYNC_MARK_ANNOTATION.option("baseNameProperty") {
106-
withProp { jvm.jvmAsyncMarkAnnotation::baseNameProperty }
107-
}
108-
val JVM_ASYNC_MARK_ANNOTATION_SUFFIX_PROPERTY =
109-
JVM_ASYNC_MARK_ANNOTATION.option("suffixProperty") {
110-
withProp { jvm.jvmAsyncMarkAnnotation::suffixProperty }
111-
}
112-
val JVM_ASYNC_MARK_ANNOTATION_AS_PROPERTY_PROPERTY =
113-
JVM_ASYNC_MARK_ANNOTATION.option("asPropertyProperty") {
114-
withProp { jvm.jvmAsyncMarkAnnotation::asPropertyProperty }
115-
}
116-
//endregion
117-
118-
119-
val SYNTHETIC_ASYNC_FUNCTION_INCLUDE_ANNOTATIONS = option("jvm.syntheticAsyncFunctionIncludeAnnotations") {
120-
inc { jvm.syntheticAsyncFunctionIncludeAnnotations = includeAnnotationDecode(it) }
121-
// TODO
122-
out { includeAnnotationEncode(jvm.syntheticAsyncFunctionIncludeAnnotations ?: emptyList()) }
123-
}
124-
125-
val COPY_ANNOTATIONS_TO_SYNTHETIC_ASYNC_FUNCTION =
126-
option("jvm.copyAnnotationsToSyntheticAsyncFunction") {
127-
inc { jvm.copyAnnotationsToSyntheticAsyncFunction = it.toBoolean() }
128-
out { jvm.copyAnnotationsToSyntheticAsyncFunction.toString() }
129-
}
130-
const val COPY_ANNOTATIONS_TO_SYNTHETIC_ASYNC_FUNCTION_EXCLUDES =
131-
"jvm.copyAnnotationsToSyntheticAsyncFunctionExcludes"
132-
133-
val COPY_ANNOTATIONS_TO_SYNTHETIC_ASYNC_FUNCTION_EXCLUDES_NAME =
134-
COPY_ANNOTATIONS_TO_SYNTHETIC_ASYNC_FUNCTION_EXCLUDES.option("name") {
135-
inc { jvm.copyAnnotationsToSyntheticAsyncFunctionExcludes = it.split(",").map(::ExcludeAnnotation) }
136-
out { jvm.copyAnnotationsToSyntheticAsyncFunctionExcludes.joinToString(",") { it.name } }
137-
}
138-
139-
//endregion
140-
14116

17+
private val RAW_CONFIGURATION = option(
18+
name = "raw_configuration",
19+
valueDescription = "Serialize the results in JSON format for configuration information",
20+
description = "Serialize the results in JSON format for configuration information",
21+
) {
22+
inc { defaultJson.decodeFromString(SuspendTransformConfiguration.serializer(), it) }
23+
out { defaultJson.encodeToString(SuspendTransformConfiguration.serializer(), this) }
14224
}
14325

144-
object Js
26+
private val ENABLED = option("enabled") {
27+
inc { enabled = it.toBoolean() }
28+
out { enabled.toString() }
29+
}
14530

14631

14732
val allOptions: List<ICliOption> = listOf(
14833
ENABLED,
149-
Jvm.ORIGIN_FUNCTION_INCLUDE_ANNOTATIONS,
150-
Jvm.JVM_BLOCKING_FUNCTION_NAME,
151-
Jvm.JVM_BLOCKING_MARK_ANNOTATION_ANNOTATION_NAME,
152-
Jvm.JVM_BLOCKING_MARK_ANNOTATION_BASE_NAME_PROPERTY,
153-
Jvm.JVM_BLOCKING_MARK_ANNOTATION_SUFFIX_PROPERTY,
154-
Jvm.JVM_BLOCKING_MARK_ANNOTATION_AS_PROPERTY_PROPERTY,
155-
Jvm.COPY_ANNOTATIONS_TO_SYNTHETIC_BLOCKING_FUNCTION,
156-
Jvm.COPY_ANNOTATIONS_TO_SYNTHETIC_BLOCKING_FUNCTION_EXCLUDES_NAME,
157-
Jvm.SYNTHETIC_BLOCKING_FUNCTION_INCLUDE_ANNOTATIONS,
158-
Jvm.JVM_ASYNC_FUNCTION_NAME,
159-
Jvm.JVM_ASYNC_MARK_ANNOTATION_ANNOTATION_NAME,
160-
Jvm.JVM_ASYNC_MARK_ANNOTATION_BASE_NAME_PROPERTY,
161-
Jvm.JVM_ASYNC_MARK_ANNOTATION_SUFFIX_PROPERTY,
162-
Jvm.JVM_ASYNC_MARK_ANNOTATION_AS_PROPERTY_PROPERTY,
163-
Jvm.SYNTHETIC_ASYNC_FUNCTION_INCLUDE_ANNOTATIONS,
164-
Jvm.COPY_ANNOTATIONS_TO_SYNTHETIC_ASYNC_FUNCTION,
165-
Jvm.COPY_ANNOTATIONS_TO_SYNTHETIC_ASYNC_FUNCTION_EXCLUDES_NAME,
34+
RAW_CONFIGURATION
16635
)
16736
val allOptionsMap = allOptions.associateBy { it.oName }
16837

0 commit comments

Comments
 (0)