Skip to content

Commit

Permalink
perf($Gradle): improve Gradle compilation performance
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Jul 31, 2022
1 parent ba9feef commit 772c6c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
19 changes: 13 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,26 @@ subprojects {
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
jvmTarget = VERSION_17.majorVersion
}
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
// Run the compiler as a separate process, https://docs.gradle.org/current/userguide/performance.html#compiler_daemon
options.isFork = true
}

tasks.withType<Test> {
useJUnitPlatform()
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
// https://docs.gradle.org/current/userguide/performance.html#parallel_test_execution
tasks.withType<Test>().configureEach {
// The normal approach is to use some number less than or equal to the number of CPU cores you have, such as this algorithm:
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
// To fork a new test VM after a certain number of tests have run
setForkEvery(100)
}

// Disable for take of building Spring Boot executable jar for most of the subprojects,
Expand All @@ -101,9 +111,6 @@ subprojects {
}
}

// val implementation by configurations
// val annotationProcessor by configurations
// val testImplementation by configurations
dependencies {
val guavaVersion: String by project
val hutoolVersion: String by project
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Gradle configurations
# Out of memory. Java heap space
org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.caching=true

# Project information constants
projectGroupId=com.jmsoftware.maf
Expand Down

0 comments on commit 772c6c0

Please sign in to comment.