Skip to content

Commit 8c0ee19

Browse files
committed
Merge branch 'kt-220' into dev
2 parents 323ab81 + deb4140 commit 8c0ee19

File tree

52 files changed

+1359
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1359
-304
lines changed

.changelog/v2.2.0-0.13.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Kotlin version: `v2.2.0`

.changelog/v2.2.0-Beta1-0.12.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Kotlin version: `v2.2.0-Beta1`

.changelog/v2.2.0-Beta2-0.12.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Kotlin version: `v2.2.0-Beta2`

.changelog/v2.2.0-RC2-0.12.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Kotlin version: `v2.2.0-RC2`

.changelog/v2.2.0-RC2-0.13.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Kotlin version: `v2.2.0-RC2`

.changelog/v2.2.0-RC2-0.13.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Kotlin version: `v2.2.0-RC2`

.github/workflows/publish-release.yml

Lines changed: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ on:
77
workflow_dispatch:
88

99
env:
10-
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
11-
GPG_SECRET_KEY: ${{ secrets.GPG_PRI_KEY }}
12-
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
13-
OSSRH_USER: ${{ secrets.OSS_USERNAME }}
14-
OSSRH_PASSWORD: ${{ secrets.OSS_PASSWORD }}
15-
RELEASE: true
16-
CI: true
10+
JAVA_VERSION: 11
11+
JAVA_DISTRIBUTION: zulu
12+
GRADLE_VERSION: 8.10.2
1713
IS_CI: true
18-
SIMBOT_LOCAL: false
14+
SIGNING_KEY_ID: ${{ secrets.GPG_KEY_ID }}
15+
GPG_KEY_CONTENTS: ${{ secrets.GPG_PRI_KEY }}
16+
SIGNING_PASSWORD: ${{ secrets.GPG_PASSWORD }}
17+
MAVEN_CENTRAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
18+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PORTAL_PASSWORD }}
1919
GRADLE_OPTS: "-Dfile.encoding=UTF-8"
20-
GRADLE_VERSION: 8.10.2
2120

2221
jobs:
2322
test:
@@ -30,77 +29,72 @@ jobs:
3029
- uses: actions/checkout@v4
3130
- uses: actions/setup-java@v4
3231
with:
33-
distribution: 'zulu'
34-
java-version: 11
32+
distribution: ${{ env.JAVA_DISTRIBUTION }}
33+
java-version: ${{ env.JAVA_VERSION }}
34+
cache: 'gradle'
3535
- name: Setup Gradle
36-
uses: gradle/actions/setup-gradle@v3
36+
uses: gradle/actions/setup-gradle@v4
3737
with:
3838
gradle-version: ${{ env.GRADLE_VERSION }}
39-
- run: gradle assemble build -s
39+
- run: gradle assemble build test allTests -s
4040

4141
publish:
4242
name: Publish
4343
needs: test
44-
runs-on: macos-latest
44+
runs-on: ubuntu-latest
4545
steps:
4646
- uses: actions/checkout@v4
47-
# Setup java
48-
# https://github.com/marketplace/actions/setup-java-jdk
4947
- uses: actions/setup-java@v4
5048
with:
51-
distribution: 'zulu'
52-
java-version: 11
49+
distribution: ${{ env.JAVA_DISTRIBUTION }}
50+
java-version: ${{ env.JAVA_VERSION }}
51+
cache: 'gradle'
5352

54-
- name: Test and publish to sonatype
55-
uses: gradle/actions/setup-gradle@v3
53+
- name: Setup Gradle
54+
uses: gradle/actions/setup-gradle@v4
5655
with:
5756
gradle-version: ${{ env.GRADLE_VERSION }}
58-
arguments:
59-
publishToSonatype
60-
closeAndReleaseStagingRepositories
61-
-s
62-
--warning-mode all
63-
-x test
64-
--build-cache
65-
-Porg.gradle.jvmargs="-XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
66-
-Porg.gradle.daemon=false
57+
58+
- name: Publish to Maven Central
59+
run: gradle publishAndReleaseToMavenCentral -s --warning-mode all -x test --build-cache --no-configuration-cache
6760
env:
68-
PLUGIN_AUTO: true
61+
ORG_GRADLE_PROJECT_org.gradle.jvmargs: "-XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
62+
ORG_GRADLE_PROJECT_org.gradle.daemon: "false"
63+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ env.MAVEN_CENTRAL_USERNAME }}
64+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ env.MAVEN_CENTRAL_PASSWORD }}
65+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ env.SIGNING_KEY_ID }}
66+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ env.SIGNING_PASSWORD }}
67+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ env.GPG_KEY_CONTENTS }}
6968

7069
publish-gradle-plugin:
7170
name: Publish Gradle Plugin
7271
runs-on: ubuntu-latest
7372
needs: publish
7473
steps:
75-
# 检出仓库代码
7674
- name: Check out repo
7775
uses: actions/checkout@v4
7876

79-
# Setup java
80-
# https://github.com/marketplace/actions/setup-java-jdk
81-
- name: Setup Java 11
77+
- name: Setup Java
8278
uses: actions/setup-java@v4
8379
with:
84-
distribution: 'zulu'
85-
java-version: 11
80+
distribution: ${{ env.JAVA_DISTRIBUTION }}
81+
java-version: ${{ env.JAVA_VERSION }}
82+
cache: 'gradle'
8683

87-
- name: Publish to gradle
88-
uses: gradle/actions/setup-gradle@v3
84+
- name: Setup Gradle
85+
uses: gradle/actions/setup-gradle@v4
8986
with:
9087
gradle-version: ${{ env.GRADLE_VERSION }}
91-
arguments: |
92-
build
93-
publishPlugins
94-
-s
95-
--warning-mode all
96-
-x test
97-
--build-cache
98-
-Porg.gradle.jvmargs="-XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
99-
-Porg.gradle.daemon=false
100-
-Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }}
101-
-Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
88+
89+
- name: Publish to gradle
90+
run: |
91+
gradle build publishPlugins -s --warning-mode all -x test --build-cache
10292
env:
10393
PLUGIN_AUTO: true
94+
ORG_GRADLE_PROJECT_org.gradle.jvmargs: "-XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
95+
ORG_GRADLE_PROJECT_org.gradle.daemon: "false"
96+
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
97+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
10498

10599
create-release:
106100
name: Create release
@@ -112,22 +106,22 @@ jobs:
112106
- uses: actions/checkout@v4
113107
- uses: actions/setup-java@v4
114108
with:
115-
distribution: 'zulu'
116-
java-version: 11
109+
distribution: ${{ env.JAVA_DISTRIBUTION }}
110+
java-version: ${{ env.JAVA_VERSION }}
111+
cache: 'gradle'
117112

118-
- name: Create changelog
119-
uses: gradle/actions/setup-gradle@v3
113+
- name: Setup Gradle
114+
uses: gradle/actions/setup-gradle@v4
120115
with:
121116
gradle-version: ${{ env.GRADLE_VERSION }}
122-
arguments: createChangelog
123117

124-
# https://github.com/softprops/action-gh-release
125-
# Create gitHub release
118+
- name: Create changelog
119+
run: gradle createChangelog
120+
126121
- name: Create Github Release
127122
uses: softprops/action-gh-release@v2
128123
with:
129124
token: ${{ secrets.FORTE_TOKEN }}
130-
# draft: true
131125
body_path: .changelog/${{ github.ref_name }}.md
132126
generate_release_notes: true
133-
prerelease: ${{ contains(github.ref_name, 'preview') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }}
127+
prerelease: ${{ contains(github.ref_name, 'preview') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') || contains(github.ref_name, 'RC') }}

.github/workflows/test-branch.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ concurrency:
1717
cancel-in-progress: true
1818

1919
env:
20+
JAVA_VERSION: 11
21+
JAVA_DISTRIBUTION: zulu
22+
GRADLE_VERSION: 8.10.2
2023
IS_CI: true
2124
GRADLE_OPTS: "-Dfile.encoding=UTF-8"
22-
GRADLE_VERSION: 8.10.2
2325

2426
jobs:
2527
build-test:
@@ -32,28 +34,24 @@ jobs:
3234
- uses: actions/checkout@v4
3335
- uses: actions/setup-java@v4
3436
with:
35-
distribution: 'zulu'
36-
java-version: 11
37+
distribution: ${{ env.JAVA_DISTRIBUTION }}
38+
java-version: ${{ env.JAVA_VERSION }}
3739
cache: 'gradle'
3840

39-
- name: Run All Tests
40-
uses: gradle/actions/setup-gradle@v3
41+
- name: Setup Gradle
42+
uses: gradle/actions/setup-gradle@v4
4143
with:
4244
gradle-version: ${{ env.GRADLE_VERSION }}
43-
arguments: |
44-
assemble
45-
build
46-
test
47-
--info
48-
--warning-mode all
49-
# --build-cache
50-
# -Porg.gradle.daemon=false
51-
# -Porg.gradle.jvmargs="-Xmx4g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
45+
46+
- name: Run All Tests
47+
run: gradle assemble build test -s --warning-mode all
48+
env:
49+
ORG_GRADLE_PROJECT_org.gradle.jvmargs: "-XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
5250

5351
- name: Upload test reports
5452
uses: actions/upload-artifact@v4
55-
if: ${{ always() }}
53+
if: always()
5654
with:
57-
name: test-reports-${{ matrix.os }}
55+
name: test-reports-${{ runner.os }}
5856
path: '**/build/reports/tests'
5957
retention-days: 7

.run/createChangelog.run.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="createChangelog" type="GradleRunConfiguration" factoryName="Gradle">
3+
<ExternalSystemSettings>
4+
<option name="executionName" />
5+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
6+
<option name="externalSystemIdString" value="GRADLE" />
7+
<option name="scriptParameters" value="-i" />
8+
<option name="taskDescriptions">
9+
<list />
10+
</option>
11+
<option name="taskNames">
12+
<list>
13+
<option value="createChangelog" />
14+
</list>
15+
</option>
16+
<option name="vmOptions" />
17+
</ExternalSystemSettings>
18+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
19+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
20+
<DebugAllEnabled>false</DebugAllEnabled>
21+
<RunAsTest>false</RunAsTest>
22+
<method v="2" />
23+
</configuration>
24+
</component>

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,69 @@ class Foo {
117117
}
118118
```
119119

120+
### MarkName
121+
122+
> since v0.13.0, [#96](https://github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin/pull/96)
123+
124+
You can use `markName` to add a name mark annotation (e.g. `@JvmName`, `@JsName`) to the generated synthetic function.
125+
126+
For example the JVM:
127+
128+
```kotlin
129+
class Foo {
130+
@JvmBlocking(markName = "namedWaitAndGet")
131+
suspend fun waitAndGet(): String {
132+
delay(5)
133+
return "Hello"
134+
}
135+
}
136+
```
137+
138+
compiled 👇
139+
140+
```kotlin
141+
class Foo {
142+
// Hide from Java
143+
@JvmSynthetic
144+
suspend fun waitAndGet(): String {
145+
delay(5)
146+
return "Hello"
147+
}
148+
@Api4J // RequiresOptIn annotation, provide warnings to Kotlin
149+
@JvmName("namedWaitAndGet") // From the `markName`'s value
150+
fun waitAndGetBlocking(): String = runInBlocking { waitAndGet() } // 'runInBlocking' from the runtime provided by the plugin
151+
}
152+
```
153+
154+
Note: `@JvmName` has limitations on non-final functions, and even the compiler may prevent compilation.
155+
156+
For example the JS:
157+
158+
```kotlin
159+
class Foo {
160+
@JsPromise(markName = "namedWaitAndGet")
161+
suspend fun waitAndGet(): String {
162+
delay(5)
163+
return "Hello"
164+
}
165+
}
166+
```
167+
168+
compiled 👇
169+
170+
```kotlin
171+
class Foo {
172+
suspend fun waitAndGet(): String {
173+
delay(5)
174+
return "Hello"
175+
}
176+
177+
@Api4Js // RequiresOptIn annotation, provide warnings to Kotlin
178+
@JsName("namedWaitAndGet") // From the `markName`'s value
179+
fun waitAndGetAsync(): Promise<String> = runInAsync { waitAndGet() } // 'runInAsync' from the runtime provided by the plugin
180+
}
181+
```
182+
120183
## Usage
121184

122185
### The version
@@ -246,7 +309,7 @@ You can also disable them and add dependencies manually.
246309
```Kotlin
247310
plugin {
248311
kotlin("jvm") version "..." // Take the Kotlin/JVM as an example
249-
id("love.forte.plugin.suspend-transform") version "2.1.20-0.12.0"
312+
id("love.forte.plugin.suspend-transform") version "<VERSION>"
250313
}
251314

252315
dependencies {

0 commit comments

Comments
 (0)