• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5apply plugin: "com.github.johnrengelman.shadow"
6
7configurations {
8    shadowDeps // shaded dependencies, not included into the resulting .pom file
9    compileOnly.extendsFrom(shadowDeps)
10    runtimeOnly.extendsFrom(shadowDeps)
11}
12
13dependencies {
14    compileOnly "junit:junit:$junit_version"
15    compileOnly "org.junit.jupiter:junit-jupiter-api:$junit5_version"
16    testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit5_version"
17    testImplementation "org.junit.platform:junit-platform-testkit:1.7.0"
18    shadowDeps "net.bytebuddy:byte-buddy:$byte_buddy_version"
19    shadowDeps "net.bytebuddy:byte-buddy-agent:$byte_buddy_version"
20    compileOnly "io.projectreactor.tools:blockhound:$blockhound_version"
21    testImplementation "io.projectreactor.tools:blockhound:$blockhound_version"
22    testImplementation "com.google.code.gson:gson:2.8.6"
23    api "net.java.dev.jna:jna:$jna_version"
24    api "net.java.dev.jna:jna-platform:$jna_version"
25}
26
27java {
28    /* This is needed to be able to run JUnit5 tests. Otherwise, Gradle complains that it can't find the
29    JVM1.6-compatible version of the `junit-jupiter-api` artifact. */
30    disableAutoTargetJvm()
31}
32
33jar {
34    setEnabled(false)
35}
36
37// This is a rough estimation of what shadow plugin has been doing with our default configuration prior to
38// 1.6.2: https://github.com/johnrengelman/shadow/blob/1ff12fc816629ae5bc331fa3889c8ecfcaee7b27/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.groovy#L72-L82
39// We just emulate it here for backwards compatibility
40shadowJar.configure {
41    def classpath = project.objects.fileCollection().from { ->
42        project.configurations.findByName('runtimeClasspath')
43    }
44    doFirst {
45        manifest.attributes 'Class-Path': classpath.collect { "${it.name}" }.findAll { it }.join(' ')
46    }
47}
48
49def shadowJarTask = shadowJar {
50    classifier null
51    // Shadow only byte buddy, do not package kotlin stdlib
52    configurations = [project.configurations.shadowDeps]
53    relocate('net.bytebuddy', 'kotlinx.coroutines.repackaged.net.bytebuddy')
54
55    manifest {
56        attributes "Premain-Class": "kotlinx.coroutines.debug.AgentPremain"
57        attributes "Can-Redefine-Classes": "true"
58    }
59}
60
61configurations {
62    artifacts {
63        add("apiElements", shadowJarTask)
64        add("runtimeElements", shadowJarTask)
65    }
66}
67
68def commonKoverExcludes =
69        // Never used, safety mechanism
70        ["kotlinx.coroutines.debug.internal.NoOpProbesKt"]
71
72tasks.koverHtmlReport {
73    excludes = commonKoverExcludes
74}
75
76tasks.koverVerify {
77    excludes = commonKoverExcludes
78}
79