-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Declare byte-buddy as 'implementation' dependency instead of shading. #4266
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6745a55
Declare byte-buddy as 'implementation' dependency instead of shading.
sellmair 532900d
fixup! Declare byte-buddy as 'implementation' dependency instead of s…
sellmair 5ef5b78
fixup! Declare byte-buddy as 'implementation' dependency instead of s…
sellmair 4ce02e0
fixup! Declare byte-buddy as 'implementation' dependency instead of s…
sellmair ff72c9d
fixup! Declare byte-buddy as 'implementation' dependency instead of s…
sellmair 6478241
fixup! Declare byte-buddy as 'implementation' dependency instead of s…
sellmair 4aa1b99
fixup! Declare byte-buddy as 'implementation' dependency instead of s…
sellmair c10a35d
Remove shadow plugin from build
sellmair 9480715
Remove a leftover
dkhalanskyjb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,12 @@ | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.* | ||
import java.net.* | ||
import java.nio.file.* | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.file.DuplicatesStrategy | ||
import org.gradle.api.tasks.bundling.Jar | ||
import org.gradle.api.tasks.testing.Test | ||
|
||
plugins { | ||
id("com.github.johnrengelman.shadow") | ||
id("org.jetbrains.kotlinx.kover") // apply plugin to use autocomplete for Kover DSL | ||
} | ||
|
||
configurations { | ||
val shadowDeps by creating | ||
compileOnly.configure { | ||
extendsFrom(shadowDeps) | ||
} | ||
runtimeOnly.configure { | ||
extendsFrom(shadowDeps) | ||
} | ||
} | ||
|
||
val junit_version by properties | ||
val junit5_version by properties | ||
val byte_buddy_version by properties | ||
|
@@ -28,8 +18,8 @@ dependencies { | |
compileOnly("org.junit.jupiter:junit-jupiter-api:$junit5_version") | ||
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junit5_version") | ||
testImplementation("org.junit.platform:junit-platform-testkit:1.7.0") | ||
add("shadowDeps", "net.bytebuddy:byte-buddy:$byte_buddy_version") | ||
add("shadowDeps", "net.bytebuddy:byte-buddy-agent:$byte_buddy_version") | ||
implementation("net.bytebuddy:byte-buddy:$byte_buddy_version") | ||
implementation("net.bytebuddy:byte-buddy-agent:$byte_buddy_version") | ||
compileOnly("io.projectreactor.tools:blockhound:$blockhound_version") | ||
testImplementation("io.projectreactor.tools:blockhound:$blockhound_version") | ||
testImplementation("com.google.code.gson:gson:2.8.6") | ||
|
@@ -50,21 +40,7 @@ tasks.withType<Test>().configureEach { | |
} | ||
} | ||
|
||
val jar by tasks.existing(Jar::class) { | ||
enabled = false | ||
} | ||
|
||
val shadowJar by tasks.existing(ShadowJar::class) { | ||
// Shadow only byte buddy, do not package kotlin stdlib | ||
configurations = listOf(project.configurations["shadowDeps"]) | ||
relocate("net.bytebuddy", "kotlinx.coroutines.repackaged.net.bytebuddy") | ||
/* These classifiers are both set to `null` to trick Gradle into thinking that this jar file is both the | ||
artifact from the `jar` task and the one from `shadowJar`. Without this, Gradle complains that the artifact | ||
from the `jar` task is not present when the compilaton finishes, even if the file with this name exists. */ | ||
archiveClassifier.convention(null as String?) | ||
archiveClassifier = null | ||
archiveBaseName = jar.flatMap { it.archiveBaseName } | ||
archiveVersion = jar.flatMap { it.archiveVersion } | ||
tasks.named<Jar>("jar") { | ||
manifest { | ||
attributes( | ||
mapOf( | ||
|
@@ -74,30 +50,17 @@ val shadowJar by tasks.existing(ShadowJar::class) { | |
) | ||
) | ||
} | ||
|
||
// add module-info.class to the META-INF/versions/9/ directory. | ||
dependsOn(tasks.compileModuleInfoJava) | ||
doLast { | ||
// We can't do that directly with the shadowJar task because it doesn't support replacing existing files. | ||
val zipPath = [email protected]() | ||
val zipUri = URI.create("jar:${zipPath.toUri()}") | ||
val moduleInfoFilePath = tasks.compileModuleInfoJava.get().outputs.files.asFileTree.matching { | ||
include("module-info.class") | ||
}.singleFile.toPath() | ||
FileSystems.newFileSystem(zipUri, emptyMap<String, String>()).use { fs -> | ||
val moduleInfoFile = fs.getPath("META-INF/versions/9/module-info.class") | ||
Files.copy(moduleInfoFilePath, moduleInfoFile, StandardCopyOption.REPLACE_EXISTING) | ||
} | ||
from(tasks.compileModuleInfoJava.get().outputs.files.asFileTree.matching { | ||
include("module-info.class") | ||
}) { | ||
this.duplicatesStrategy = DuplicatesStrategy.INCLUDE | ||
into("META-INF/versions/9") | ||
} | ||
} | ||
|
||
configurations { | ||
// shadowJar is already part of the `shadowRuntimeElements` and `shadowApiElements`, but the other subprojects | ||
// that depend on `kotlinx-coroutines-debug` look at `runtimeElements` and `apiElements`. | ||
artifacts { | ||
add("apiElements", shadowJar) | ||
add("runtimeElements", shadowJar) | ||
} | ||
} | ||
|
||
kover { | ||
reports { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, the list above only has a single bullet point (so it's strange that it's still a list), and also, in addition to JNA and JNA-platform mentioned above,
kotlinx-coroutines-debug
now depends onbyte-buddy
andbyte-buddy-agent
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, I think one of two ways is more efficient than ping-ponging in this review.
Either we merge the contribution as is and you can quickly edit the readme to your liking in a new commit, or you might just want to edit the commit directly pre merge.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a third way, the one we usually take in this library: the contributor carefully looks at the places affected by the proposed change, considers the consequences, and then introduces sweeping, coordinated edits. In other words, instead of making a small isolated change, they consider the bigger picture. A reviewer's job then boils down to highlighting the affected areas the contributor hasn't thought of / didn't know about (without enumerating every specific line of code to change), after which the contributor goes back to researching what the proposed change entails and introduces further sweeping edits. No ping-ponging results, as the list of such areas to consider is typically limited.
Although the third way is preferred, both of the options you've proposed are okay: we're also glad and thankful to accept incomplete contributions if the contributor says: "I'm no longer interested in working on this, you do it." In this scenario, the credit still goes to the contributor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed an update, please provide feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks! I've also left a comment with my review, it's possible that you've missed it:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅