Skip to content

Commit 1b61faa

Browse files
authored
Remove the warning on kotlin plugin warning (#9711)
* fix: Kotlin plugin warning Build scripts use the `buildscript` way to configure the project's plugins, which is not recommended anymore since quite a few versions in gradle. ``` The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build. This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal. Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects. If the parent project does not need the plugin, add 'apply false' to the plugin line. See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl The Kotlin plugin was loaded in the following projects: ':dd-java-agent:agent-ci-visibility', ':dd-java-agent:agent-llmobs' ``` * style: make scalafmt happy * style: make google-java-format happy * fix: Exclude generated files and more generally anything in the build directory * fix: Single kotlin plugin version but configure each projects
1 parent dbf4b9d commit 1b61faa

File tree

51 files changed

+818
-669
lines changed

Some content is hidden

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

51 files changed

+818
-669
lines changed

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ plugins {
1313
id("com.gradleup.shadow") version "8.3.6" apply false
1414
id("me.champeau.jmh") version "0.7.3" apply false
1515
id("org.gradle.playframework") version "0.13" apply false
16+
kotlin("jvm") version libs.versions.kotlin.plugin apply false
1617
}
1718

1819
description = "dd-trace-java"

buildSrc/src/main/groovy/InstrumentPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class InstrumentPlugin implements Plugin<Project> {
3535
InstrumentExtension extension = project.extensions.create('instrument', InstrumentExtension)
3636

3737
project.tasks.matching {
38-
it.name in ['compileJava', 'compileScala', 'compileKotlin', 'compileGroovy'] ||
38+
it.name in ['compileJava', 'compileScala', 'compileGroovy'] ||
3939
it.name =~ /compileMain_.+Java/
4040
}.all {
4141
AbstractCompile compileTask = it as AbstractCompile

dd-java-agent/agent-ci-visibility/build.gradle

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,8 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22

3-
buildscript {
4-
repositories {
5-
mavenLocal()
6-
if (project.rootProject.hasProperty("gradlePluginProxy")) {
7-
maven {
8-
url project.rootProject.property("gradlePluginProxy")
9-
allowInsecureProtocol = true
10-
}
11-
}
12-
if (project.rootProject.hasProperty("mavenRepositoryProxy")) {
13-
maven {
14-
url project.rootProject.property("mavenRepositoryProxy")
15-
allowInsecureProtocol = true
16-
}
17-
}
18-
gradlePluginPortal()
19-
mavenCentral()
20-
}
21-
22-
dependencies {
23-
classpath group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: libs.versions.kotlin.get()
24-
}
25-
}
26-
273
plugins {
284
id 'com.gradleup.shadow'
5+
id 'org.jetbrains.kotlin.jvm' version libs.versions.kotlin.plugin
296
}
307

318
apply from: "$rootDir/gradle/java.gradle"

dd-java-agent/agent-llmobs/build.gradle

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2-
3-
buildscript {
4-
repositories {
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
classpath group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: libs.versions.kotlin.get()
10-
}
11-
}
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
124

135
plugins {
146
id 'com.gradleup.shadow'
7+
id 'org.jetbrains.kotlin.jvm'
158
}
169

1710
apply from: "$rootDir/gradle/java.gradle"
1811
apply from: "$rootDir/gradle/version.gradle"
1912
apply from: "$rootDir/gradle/test-with-kotlin.gradle"
2013

14+
kotlin {
15+
compilerOptions {
16+
jvmTarget = JvmTarget.JVM_1_8
17+
apiVersion = KotlinVersion.KOTLIN_1_6
18+
languageVersion = KotlinVersion.KOTLIN_1_6
19+
}
20+
}
21+
2122
minimumBranchCoverage = 0.0
2223
minimumInstructionCoverage = 0.0
2324

dd-java-agent/benchmark-integration/play-perftest/app/controllers/HomeController.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ import javax.inject.Inject
77

88
import play.api.mvc._
99

10-
/**
11-
* This controller creates an `Action` to handle HTTP requests to the
10+
/** This controller creates an `Action` to handle HTTP requests to the
1211
* application's work page which does busy wait to simulate some work
1312
*/
14-
class HomeController @Inject()(cc: ControllerComponents) extends AbstractController(cc) {
13+
class HomeController @Inject() (cc: ControllerComponents) extends AbstractController(cc) {
1514

16-
/**
17-
* Create an Action to perform busy wait
15+
/** Create an Action to perform busy wait
1816
*/
1917
def doGet(workTimeMS: Option[Long], error: Option[String]) = Action {
2018
implicit request: Request[AnyContent] =>

dd-java-agent/instrumentation/akka/akka-actor-2.5/src/akka23Test/scala/AkkaActors.scala

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,27 @@ class AkkaActors extends AutoCloseable {
7878

7979
object AkkaActors {
8080
// If we can't load the Version class, then assume 2.3
81-
val isAkka23: Boolean = try {
82-
Class.forName("akka.Version")
83-
false
84-
} catch {
85-
case _: Throwable => true
86-
}
81+
val isAkka23: Boolean =
82+
try {
83+
Class.forName("akka.Version")
84+
false
85+
} catch {
86+
case _: Throwable => true
87+
}
8788

8889
// The way to terminate an actor system has changed between versions
8990
val terminate: (ActorSystem) => Unit = {
90-
val t = try {
91-
ActorSystem.getClass.getMethod("terminate")
92-
} catch {
93-
case _: Throwable => try {
94-
ActorSystem.getClass.getMethod("awaitTermination")
91+
val t =
92+
try {
93+
ActorSystem.getClass.getMethod("terminate")
9594
} catch {
96-
case _: Throwable => null
95+
case _: Throwable =>
96+
try {
97+
ActorSystem.getClass.getMethod("awaitTermination")
98+
} catch {
99+
case _: Throwable => null
100+
}
97101
}
98-
}
99102
if (t ne null) {
100103
{ system: ActorSystem =>
101104
t.invoke(system)

0 commit comments

Comments
 (0)