Skip to content

Commit 74b2aa9

Browse files
authored
Merge pull request #2223 from digma-ai/improve-build-time
improve build time
2 parents 34c8459 + 130b038 commit 74b2aa9

File tree

6 files changed

+76
-32
lines changed

6 files changed

+76
-32
lines changed

common-build-logic/src/main/kotlin/common/Common.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ import org.gradle.api.Project
44
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
55
import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformExtension
66

7+
//send -Pdigma-no-info-logging to silence some console logging, useful when debugging issues so the log is not too noisy.
8+
const val DIGMA_NO_INFO_LOGGING = "digma-no-info-logging"
9+
10+
//use for messages we want to silence sometimes with DIGMA_NO_INFO_LOGGING
11+
fun Project.withSilenceLogging(consumer: () -> Unit){
12+
if (!hasProperty(DIGMA_NO_INFO_LOGGING)) {
13+
consumer.invoke()
14+
}
15+
}
16+
17+
18+
719
fun properties(key: String, project: Project) = project.findProperty(key).toString()
820

921
fun platformTypeProperty(project: Project) = project.findProperty("platformType") as IntelliJPlatformType

common-build-logic/src/main/kotlin/plugin-library.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import common.logBuildProfile
22
import common.logIntellijPlatformPlugin
3+
import common.withSilenceLogging
34

45
plugins {
56
id("digma-base")
@@ -25,8 +26,10 @@ dependencies {
2526

2627
afterEvaluate {
2728
if (gradle.startParameter.taskNames.contains("buildPlugin")) {
28-
logBuildProfile(project)
29-
logIntellijPlatformPlugin(project, intellijPlatform)
29+
withSilenceLogging {
30+
logBuildProfile(project)
31+
logIntellijPlatformPlugin(project, intellijPlatform)
32+
}
3033
}
3134
}
3235

common-build-logic/src/main/kotlin/plugin-project.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import common.logBuildProfile
22
import common.logIntellijPlatformPlugin
33
import common.properties
4+
import common.withSilenceLogging
5+
import gradle.kotlin.dsl.accessors._44bd68d24449dd49451fa0f0c4976aa6.intellijPlatform
46

57
plugins {
68
id("digma-base")
@@ -25,8 +27,10 @@ intellijPlatform {
2527

2628
afterEvaluate {
2729
if (gradle.startParameter.taskNames.contains("buildPlugin")) {
28-
logBuildProfile(project)
29-
logIntellijPlatformPlugin(project, intellijPlatform)
30+
withSilenceLogging {
31+
logBuildProfile(project)
32+
logIntellijPlatformPlugin(project, intellijPlatform)
33+
}
3034
}
3135
}
3236

gradle.properties

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ pluginRepositoryUrl=https://github.com/digma-ai/digma-intellij-plugin.git
3030
kotlin.stdlib.default.dependency=false
3131

3232
# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
33-
## todo: we have some tasks that are incompatible with configuration cache, injectPosthogTokenUrlTask and rider rd-gen tasks.
34-
## change to true to see the errors and fix
35-
org.gradle.configuration-cache = false
36-
org.gradle.configuration-cache.problems = warn
33+
#org.gradle.configuration-cache = false
34+
#org.gradle.configuration-cache.problems = warn
3735

3836
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
3937
org.gradle.caching = true

jvm-common/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import common.BuildProfiles
22
import common.currentProfile
33
import common.dynamicPlatformType
44
import common.platformVersion
5+
import common.withSilenceLogging
56
import de.undercouch.gradle.tasks.download.Download
67
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
78
import java.util.Properties
@@ -69,7 +70,10 @@ tasks {
6970
)
7071
)
7172

72-
logger.lifecycle("${project.name}: jars to download $properties")
73+
withSilenceLogging {
74+
logger.lifecycle("${project.name}: jars to download $properties")
75+
}
76+
7377

7478
dest(File(project.sourceSets.main.get().output.resourcesDir, "otelJars"))
7579
overwrite(false)

rider/build.gradle.kts

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import com.jetbrains.plugin.structure.base.utils.isFile
22
import common.BuildProfiles
33
import common.BuildProfiles.greaterThan
4+
import common.DIGMA_NO_INFO_LOGGING
45
import common.currentProfile
56
import common.withCurrentProfile
7+
import common.withSilenceLogging
68
import org.apache.tools.ant.filters.ReplaceTokens
79
import org.jetbrains.intellij.platform.gradle.Constants
810
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
@@ -18,7 +20,7 @@ plugins {
1820

1921
private val dotnetPluginId = "Digma.Rider.Plugin"
2022
private val buildConfiguration = "Debug"
21-
private val solutionFile = "$dotnetPluginId/Digma.Rider.Plugin.sln"
23+
private val solutionFile = "Digma.Rider.Plugin.sln"
2224
private val dotnetProjectDir = layout.projectDirectory.dir(dotnetPluginId)
2325
private val nugetConfigFile = dotnetProjectDir.file("nuget.config").asFile
2426
private val pluginPropsFile = dotnetProjectDir.file("Plugin.props").asFile
@@ -71,9 +73,11 @@ val riderSdkTestProjectFile by lazy {
7173
}
7274

7375
project.afterEvaluate {
74-
logger.lifecycle("Rider Sdk Path: $riderSdkPath")
75-
logger.lifecycle("Rider Sdk project file: $riderSdkProjectFile")
76-
logger.lifecycle("Rider Sdk test project file: $riderSdkTestProjectFile")
76+
withSilenceLogging {
77+
logger.lifecycle("Rider Sdk Path: $riderSdkPath")
78+
logger.lifecycle("Rider Sdk project file: $riderSdkProjectFile")
79+
logger.lifecycle("Rider Sdk test project file: $riderSdkTestProjectFile")
80+
}
7781
}
7882

7983

@@ -111,7 +115,9 @@ tasks {
111115
</configuration>
112116
""".trimIndent()
113117

114-
logger.lifecycle("Writing nuget.config to $path, content $content")
118+
withSilenceLogging {
119+
logger.lifecycle("Writing nuget.config to $path, content $content")
120+
}
115121
val bytes = content.toByteArray()
116122
nugetConfigFile.writeBytes(bytes)
117123
}
@@ -164,9 +170,9 @@ tasks {
164170
val tokens = mutableMapOf<String, String>()
165171

166172
//up to p233 the version should be 4.0.0, and 4.3.0 after p233
167-
val traceSourceVersion = if(project.currentProfile().profile.greaterThan(BuildProfiles.Profile.p233)){
173+
val traceSourceVersion = if (project.currentProfile().profile.greaterThan(BuildProfiles.Profile.p233)) {
168174
"4.3.0"
169-
}else{
175+
} else {
170176
"4.0.0"
171177
}
172178

@@ -188,7 +194,7 @@ tasks {
188194

189195
//call prepare before loading the project to Rider
190196
val prepare by registering {
191-
dependsOn(generateNuGetConfig, initPluginProps,initPluginTestProps, rdGen)
197+
dependsOn(generateNuGetConfig, initPluginProps, initPluginTestProps, rdGen)
192198
}
193199

194200

@@ -219,24 +225,38 @@ tasks {
219225
//for diagnostics add argument "/v:diag"
220226

221227
//about /r: in development we sometimes need to build with different profiles, for example 232 and then 241.
222-
// sometimes the conpileDotnet task will fail and looks like its using the wrong assemblies. /r(estore) fixes it.
228+
// sometimes the compileDotnet task will fail and looks like its using the wrong assemblies. /r(estore) fixes it.
229+
230+
withSilenceLogging {
231+
logger.lifecycle("compileDotNet:Plugin.props: ${pluginPropsFile.readText()}")
232+
logger.lifecycle("compileDotNet:nuget.config: ${nugetConfigFile.readText()}")
233+
}
234+
235+
val argsList = mutableListOf(
236+
"msbuild",
237+
"/r",
238+
"/p:Configuration=$buildConfiguration",
239+
"/t:Rebuild",
240+
"/nodeReuse:False",
241+
"/fl",
242+
"/bl:${project.layout.buildDirectory.get().asFile.absolutePath}/dotnet/msbuild.binlog"
243+
)
244+
245+
if (project.hasProperty(DIGMA_NO_INFO_LOGGING)) {
246+
argsList.add("-noConsoleLogger")
247+
}
223248

224-
logger.lifecycle("compileDotNet:Plugin.props: ${pluginPropsFile.readText()}")
225-
logger.lifecycle("compileDotNet:nuget.config: ${nugetConfigFile.readText()}")
249+
argsList.add(solutionFile)
250+
251+
withSilenceLogging {
252+
logger.lifecycle("dotnet args: [${argsList.joinToString(" ")}]")
253+
}
226254

227255
exec {
228256
executable = "dotnet"
229-
args = listOf(
230-
"msbuild",
231-
"/r",
232-
"/p:Configuration=$buildConfiguration",
233-
"/t:Clean;Restore;Rebuild",
234-
"/nodeReuse:False",
235-
"/fl",
236-
"/bl:${project.layout.buildDirectory.get().asFile.absolutePath}/dotnet/msbuild.binlog",
237-
solutionFile
238-
)
239-
workingDir = projectDir
257+
args = argsList.toList()
258+
259+
workingDir = dotnetProjectDir.asFile
240260
}
241261
}
242262
}
@@ -284,7 +304,10 @@ val riderModel: Configuration by configurations.creating {
284304
artifacts {
285305
add(riderModel.name, provider {
286306
intellijPlatform.platformPath.resolve("lib/rd/rider-model.jar").also {
287-
logger.lifecycle("rider-model.jar: $it")
307+
withSilenceLogging {
308+
logger.lifecycle("rider-model.jar: $it")
309+
}
310+
288311
check(it.isFile) {
289312
"rider-model.jar is not found at $it"
290313
}

0 commit comments

Comments
 (0)