Gradle: use configuration cache

This commit is contained in:
Karl Tauber
2025-11-25 11:51:41 +01:00
parent 19c86cf1f7
commit c8e2e78955
11 changed files with 135 additions and 86 deletions

View File

@@ -14,6 +14,8 @@
* limitations under the License.
*/
import org.gradle.kotlin.dsl.support.serviceOf
plugins {
`cpp-library`
}
@@ -37,9 +39,14 @@ tasks {
doFirst {
println( "Used Tool Chain:" )
println( " - ${toolChain.get()}" )
println( "Available Tool Chains:" )
toolChains.forEach {
println( " - $it" )
}
if( !project.gradle.serviceOf<BuildFeatures>().configurationCache.active.get() ) {
doFirst {
println( "Available Tool Chains:" )
toolChains.forEach {
println( " - $it" )
}
}
}
}

View File

@@ -45,10 +45,11 @@ if( !exclude ) {
setSrcDirs( listOf( "src/main/module-info", "src/main/java", "src/main/java9" ) )
// exclude Java 8 source file if an equally named Java 9+ source file exists
val projectDir = projectDir // necessary for configuration cache
exclude {
if( it.isDirectory )
return@exclude false
val java9file = file( "${projectDir}/src/main/java9/${it.path}" )
val java9file = File( "${projectDir}/src/main/java9/${it.path}" )
java9file.exists() && java9file != it.file
}
}

View File

@@ -85,27 +85,6 @@ publishing {
}
}
}
/*
repositories {
maven {
name = "MavenCentral"
val releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/"
url = uri( if( rootProject.hasProperty( "release" ) ) releasesRepoUrl else snapshotsRepoUrl )
credentials {
// get from gradle.properties
val sonatypeUsername: String? by project
val sonatypePassword: String? by project
username = System.getenv( "SONATYPE_USERNAME" ) ?: sonatypeUsername
password = System.getenv( "SONATYPE_PASSWORD" ) ?: sonatypePassword
}
}
}
*/
}
signing {
@@ -125,10 +104,22 @@ tasks.withType<Sign>().configureEach {
onlyIf { rootProject.hasProperty( "release" ) }
}
// check whether parallel build is enabled
tasks.withType<AbstractPublishToMaven>().configureEach {
doFirst {
if( System.getProperty( "org.gradle.parallel" ) == "true" )
throw RuntimeException( "Publishing does not work correctly with enabled parallel build. Disable parallel build with VM option '-Dorg.gradle.parallel=false'." )
tasks {
// check whether parallel build is enabled
withType<AbstractPublishToMaven>().configureEach {
doFirst {
if( System.getProperty( "org.gradle.parallel" ) == "true" )
throw RuntimeException( "Publishing does not work correctly with enabled parallel build. Disable parallel build with VM option '-Dorg.gradle.parallel=false'." )
}
}
register( "publishToSonatypeAndCloseStagingRepo" ) {
group = "publishing"
description = "Publish to Sonatype Maven Central and close staging repository"
dependsOn(
"publishToSonatype",
":closeSonatypeStagingRepository"
)
}
}