Skip to content

Commit 3781a82

Browse files
committed
Repackage byte-buddy along with debug agent (so it shouldn't be a dependency of target process), use shadow plugin for that to avoid clashes with other byte-buddy versions and publish shadow jar instead of regular one for debug module
1 parent 7a6fd89 commit 3781a82

File tree

4 files changed

+45
-22
lines changed

4 files changed

+45
-22
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ buildscript {
4040
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
4141

4242
// JMH plugins
43-
classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
43+
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2"
4444
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.7"
4545
classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
4646
}

core/kotlinx-coroutines-debug/build.gradle

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
apply plugin: "com.github.johnrengelman.shadow"
6+
57
dependencies {
68
compile "net.bytebuddy:byte-buddy:$byte_buddy_version"
79
compile "net.bytebuddy:byte-buddy-agent:$byte_buddy_version"
@@ -13,3 +15,13 @@ jar {
1315
attributes "Can-Redefine-Classes": "true"
1416
}
1517
}
18+
19+
shadowJar {
20+
classifier null
21+
// Shadow only byte buddy, do not package kotlin stdlib
22+
dependencies {
23+
include(dependency("net.bytebuddy:byte-buddy:$byte_buddy_version"))
24+
include(dependency("net.bytebuddy:byte-buddy-agent:$byte_buddy_version"))
25+
}
26+
relocate 'net.bytebuddy', 'kotlinx.coroutines.repackaged.net.bytebuddy'
27+
}

core/kotlinx-coroutines-debug/src/CoroutineState.kt

+10-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,16 @@ public data class CoroutineState internal constructor(
9797
* Current state of the coroutine.
9898
*/
9999
public enum class State {
100-
CREATED, // Not yet started
100+
/**
101+
* Created, but not yet started
102+
*/
103+
CREATED,
104+
/**
105+
* Started and running
106+
*/
101107
RUNNING,
108+
/**
109+
* Suspended
110+
*/
102111
SUSPENDED
103112
}

gradle/publish-bintray.gradle

+22-20
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ apply plugin: 'maven'
88
apply plugin: 'maven-publish'
99
apply plugin: 'com.jfrog.bintray'
1010
apply plugin: 'com.jfrog.artifactory'
11+
apply plugin: "com.github.johnrengelman.shadow"
1112

1213
apply from: project.rootProject.file('gradle/maven-central.gradle')
1314

@@ -16,13 +17,13 @@ def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
1617

1718
// ------------- tasks
1819

19-
def isNative = project.name.endsWith("native")
20+
def isNative() { return project.name.endsWith("native") }
2021
def bUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
2122
def bKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
2223

2324
task sourcesJar(type: Jar) {
2425
classifier = 'sources'
25-
if (!isNative) {
26+
if (!isNative()) {
2627
from sourceSets.main.allSource
2728
}
2829

@@ -32,19 +33,15 @@ task sourcesJar(type: Jar) {
3233
}
3334
}
3435

36+
3537
publishing {
3638
repositories {
3739
maven { url = 'https://kotlin.bintray.com/kotlinx' }
3840
}
3941

4042
publications {
41-
maven(MavenPublication) {
42-
if (!isNative) {
43-
from components.java
44-
artifact javadocJar
45-
artifact sourcesJar
46-
}
47-
pom.withXml(configureMavenCentralMetadata)
43+
maven(MavenPublication) { publication ->
44+
preparePublication(publication)
4845
}
4946
}
5047
}
@@ -58,15 +55,8 @@ artifactory {
5855
password = bKey
5956
}
6057

61-
publications {
62-
maven(MavenPublication) {
63-
if (!isNative) {
64-
from components.java
65-
artifact javadocJar
66-
artifact sourcesJar
67-
}
68-
pom.withXml(configureMavenCentralMetadata)
69-
}
58+
maven(MavenPublication) { publication ->
59+
preparePublication(publication)
7060
}
7161

7262
defaults {
@@ -75,9 +65,21 @@ artifactory {
7565
}
7666
}
7767

68+
def preparePublication(MavenPublication publication) {
69+
if (!isNative()) {
70+
if (project.name == "kotlinx-coroutines-debug") {
71+
project.shadow.component(publication)
72+
} else {
73+
publication.from components.java
74+
}
75+
publication.artifact javadocJar
76+
publication.artifact sourcesJar
77+
}
78+
publication.pom.withXml(configureMavenCentralMetadata)
79+
}
80+
7881
task publishDevelopSnapshot() {
7982
def branch = System.getenv('currentBranch')
80-
println "Current branch: $branch"
8183
if (branch == "develop") {
8284
dependsOn(":artifactoryPublish")
8385
}
@@ -112,7 +114,7 @@ bintrayUpload.doFirst {
112114
}
113115

114116
// TODO :kludge this is required to disable publish of metadata for all but native
115-
if (!isNative) {
117+
if (!isNative()) {
116118
afterEvaluate {
117119
publishing.publications.each { pub ->
118120
pub.gradleModuleMetadataFile = null

0 commit comments

Comments
 (0)