Skip to content

Commit c8edc3e

Browse files
committed
WARN log prefix
1 parent b6c2ebd commit c8edc3e

File tree

6 files changed

+58
-64
lines changed

6 files changed

+58
-64
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,8 @@ try this:
864864
_build.gradle.kts_
865865
866866
```kotlin
867+
import love.forte.plugin.suspendtrans.configuration.SuspendTransformConfigurations
868+
867869
plugins {
868870
// ...
869871
}
@@ -872,7 +874,7 @@ suspendTransformPlugin {
872874
transformers {
873875
addJsPromise {
874876
addCopyAnnotationExclude {
875-
// The generated function does not include `@JsExport.Ignore`.
877+
// The generated function does not include (copy) `@JsExport.Ignore`.
876878
from(kotlinJsExportIgnoreClassInfo)
877879
}
878880
}

plugins/suspend-transform-plugin-gradle/src/main/kotlin/love/forte/plugin/suspendtrans/gradle/SuspendTransformGradleExtension.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ open class SuspendTransformGradleExtension : love.forte.plugin.suspendtrans.Susp
2020
@Deprecated("Please use the " +
2121
"`love.forte.plugin.suspendtrans.configuration.SuspendTransformConfiguration` " +
2222
"(`suspendTransformPlugin { ... }`) instead.")
23-
override var enabled: Boolean = false
23+
override var enabled: Boolean = true
2424

2525
/**
2626
* 是否增加 `love.forte.plugin.suspend-transform:suspend-transform-annotation` 的运行时。

plugins/suspend-transform-plugin-gradle/src/main/kotlin/love/forte/plugin/suspendtrans/gradle/SuspendTransformGradlePlugin.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ open class SuspendTransformGradlePlugin : KotlinCompilerPluginSupportPlugin {
5757
val isApplicable = project.plugins.hasPlugin(SuspendTransformGradlePlugin::class.java)
5858
&& project.configOrNull?.enabled?.get() != false
5959

60-
project.logger.info("Is suspend transform plugin applicable for {}: {}", kotlinCompilation, isApplicable)
60+
project.logger.debug("Is suspend transform plugin applicable for {}: {}", kotlinCompilation, isApplicable)
6161

6262
return isApplicable
6363
}
@@ -77,7 +77,7 @@ open class SuspendTransformGradlePlugin : KotlinCompilerPluginSupportPlugin {
7777
val target = kotlinCompilation.target
7878
val project = target.project
7979

80-
project.logger.info("Apply suspend transform plugin to compilation {}, target: {}", kotlinCompilation, target)
80+
project.logger.debug("Apply suspend transform plugin to compilation {}, target: {}", kotlinCompilation, target)
8181

8282
val extension = resolveExtension(project)
8383
return project.provider { extension.toSubpluginOptions(target, project) }
@@ -92,15 +92,18 @@ open class SuspendTransformGradlePlugin : KotlinCompilerPluginSupportPlugin {
9292
if (oldExtension.enabled && oldExtension.transformers.isNotEmpty()) {
9393
val dontShowWarn =
9494
project.providers.gradleProperty("love.forte.plugin.suspend-transform.suppressDeprecatedExtensionWarn")
95-
.map { it.toBoolean() }.getOrElse(false)
95+
.orNull.toBoolean()
9696

97-
val msg = "The `love.forte.plugin.suspendtrans.gradle.SuspendTransformGradleExtension` " +
98-
"(`suspendTransform { ... }`) is deprecated, " +
97+
98+
val msg = "WARN: The `love.forte.plugin.suspendtrans.gradle.SuspendTransformGradleExtension` " +
99+
"(`suspendTransform { ... }`) is deprecated, \n" +
99100
"please use `love.forte.plugin.suspendtrans.gradle.SuspendTransformPluginExtension` " +
100-
"(`suspendTransformPlugin { ... }`) instead. " +
101+
"(`suspendTransformPlugin { ... }`) instead. \n" +
101102
"The SuspendTransformGradleExtension property " +
102103
"will currently be aggregated with `SuspendTransformPluginExtension`, " +
103-
"but it will soon be deprecated completely. "
104+
"but it will soon be deprecated completely. \n" +
105+
"Add 'love.forte.plugin.suspend-transform.suppressDeprecatedExtensionWarn=true' " +
106+
"to gradle.properties to suppress this warning."
104107

105108
if (!dontShowWarn) {
106109
project.logger.warn(msg)
@@ -252,18 +255,21 @@ private fun DeprecatedIncludeAnnotation.toIncludeAnnotation(): IncludeAnnotation
252255
)
253256
}
254257

255-
private fun SuspendTransformPluginExtension.toSubpluginOptions(target: KotlinTarget, project: Project): List<SubpluginOption> {
258+
private fun SuspendTransformPluginExtension.toSubpluginOptions(
259+
target: KotlinTarget,
260+
project: Project
261+
): List<SubpluginOption> {
256262
// If not enabled or transformer is empty.
257263
val cliConfig = SuspendTransformCliOptions.CLI_CONFIGURATION
258264
val configuration = toConfiguration()
259265
return if (configuration.enabled && configuration.transformers.isNotEmpty()) {
260266
if (project.logger.isInfoEnabled) {
261267
val count = configuration.transformers.values.sumOf { it.size }
262-
project.logger.info("The suspend transform is enabled with {} transformer(s) for {}", count, target)
268+
project.logger.debug("The suspend transform is enabled with {} transformer(s) for {}", count, target)
263269
}
264270
listOf(SubpluginOption(cliConfig.optionName, configuration.encodeToHex()))
265271
} else {
266-
project.logger.info("The suspend transform is disabled or transformers are empty for {}.", target)
272+
project.logger.debug("The suspend transform is disabled or transformers are empty for {}.", target)
267273
emptyList()
268274
}
269275
}

tests/test-jvm/build.gradle.kts

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import jdk.tools.jlink.resources.plugins
21
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
32

43
plugins {
@@ -33,56 +32,22 @@ dependencies {
3332
api(libs.kotlinx.coroutines.core)
3433
}
3534

36-
suspendTransformPlugin {
35+
@Suppress("DEPRECATION")
36+
suspendTransform {
37+
enabled = true
3738
includeAnnotation = false
3839
includeRuntime = false
39-
transformers {
40-
useDefault()
41-
42-
// For blocking
43-
// addJvm {
44-
// markAnnotation {
45-
// classInfo {
46-
// packageName = "com.example"
47-
// className = "JTrans"
48-
// }
49-
// baseNameProperty = "blockingBaseName"
50-
// suffixProperty = "blockingSuffix"
51-
// asPropertyProperty = "blockingAsProperty"
52-
// defaultSuffix = "Blocking"
53-
// defaultAsProperty = false
54-
// }
55-
//
56-
// transformFunctionInfo {
57-
// packageName = "com.example"
58-
// functionName = "inBlock"
59-
// }
60-
//
61-
// // other config...
62-
// }
63-
//
64-
// // For async
65-
// addJvm {
66-
// markAnnotation {
67-
// classInfo {
68-
// packageName = "com.example"
69-
// className = "JTrans"
70-
// }
71-
// baseNameProperty = "asyncBaseName"
72-
// suffixProperty = "asyncSuffix"
73-
// asPropertyProperty = "asyncAsProperty"
74-
// defaultSuffix = "Async"
75-
// defaultAsProperty = false
76-
// }
77-
//
78-
// transformFunctionInfo {
79-
// packageName = "com.example"
80-
// functionName = "inAsync"
81-
// }
82-
// }
83-
}
40+
useDefault()
8441
}
8542

43+
// suspendTransformPlugin {
44+
// includeAnnotation = false
45+
// includeRuntime = false
46+
// transformers {
47+
// useDefault()
48+
// }
49+
// }
50+
8651
/*
8752
> val blockingBaseName: String = "",
8853
> val blockingSuffix: String = "Blocking",

tests/test-kmp/build.gradle.kts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import jdk.tools.jlink.resources.plugins
2-
1+
import love.forte.plugin.suspendtrans.ClassInfo
2+
import love.forte.plugin.suspendtrans.SuspendTransformConfiguration
33

44
plugins {
55
kotlin("multiplatform")
@@ -81,11 +81,23 @@ tasks.withType<JavaCompile> {
8181
suspendTransformPlugin {
8282
includeRuntime = false
8383
includeAnnotation = false
84-
transformers {
85-
useDefault()
86-
}
8784
}
8885

86+
@Suppress("DEPRECATION")
87+
suspendTransform {
88+
includeRuntime = false
89+
includeAnnotation = false
90+
useJvmDefault()
91+
addJsTransformers(
92+
SuspendTransformConfiguration.jsPromiseTransformer.copy(
93+
copyAnnotationExcludes = listOf(
94+
ClassInfo("kotlin.js", "JsExport.Ignore")
95+
)
96+
)
97+
)
98+
}
99+
100+
89101
tasks.withType<Test> {
90102
useJUnitPlatform()
91103
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
package example
22

3+
import love.forte.plugin.suspendtrans.annotation.JsPromise
34
import love.forte.plugin.suspendtrans.annotation.JvmAsync
45
import love.forte.plugin.suspendtrans.annotation.JvmBlocking
6+
import kotlin.js.ExperimentalJsExport
7+
import kotlin.js.JsExport
58

69
/**
710
*
811
* @author ForteScarlet
912
*/
13+
@OptIn(ExperimentalJsExport::class)
14+
@JsExport
1015
interface MyInterface {
1116
@JvmBlocking
1217
@JvmAsync
18+
@JsPromise
19+
@JsExport.Ignore
1320
suspend fun delete()
1421
@JvmBlocking
1522
@JvmAsync
23+
@JsPromise(baseName = "delete2")
24+
@JsExport.Ignore
1625
suspend fun delete(vararg value: String)
1726
}

0 commit comments

Comments
 (0)