diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80ce1a30..0051aa82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: - name: Cache Gradle uses: ./.github/actions/cache-gradle - - name: Release a new stable version to Maven Central + - name: Release a new stable version to Maven Central and build demo and theme editor run: ./gradlew publishToSonatype closeSonatypeStagingRepository :flatlaf-demo:build :flatlaf-theme-editor:build -PskipFonts -Prelease -Dorg.gradle.parallel=false env: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/build.gradle.kts b/build.gradle.kts index 8617cecd..1e47e9a8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,9 @@ * limitations under the License. */ +import io.github.gradlenexus.publishplugin.CloseNexusStagingRepository import net.ltgt.gradle.errorprone.errorprone +import org.gradle.kotlin.dsl.withType // initialize version @@ -103,6 +105,17 @@ allprojects { languageVersion.set( JavaLanguageVersion.of( 25 ) ) } ) } + + // mark some publishing related tasks as not compatible with configuration cache + withType().configureEach { + notCompatibleWithConfigurationCache( "not compatible" ) + } + withType().configureEach { + notCompatibleWithConfigurationCache( "not compatible" ) + } + withType().configureEach { + notCompatibleWithConfigurationCache( "not compatible" ) + } } diff --git a/buildSrc/src/main/kotlin/flatlaf-cpp-library.gradle.kts b/buildSrc/src/main/kotlin/flatlaf-cpp-library.gradle.kts index 25213aa2..710a846c 100644 --- a/buildSrc/src/main/kotlin/flatlaf-cpp-library.gradle.kts +++ b/buildSrc/src/main/kotlin/flatlaf-cpp-library.gradle.kts @@ -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().configurationCache.active.get() ) { + doFirst { + println( "Available Tool Chains:" ) + toolChains.forEach { + println( " - $it" ) + } } } } diff --git a/buildSrc/src/main/kotlin/flatlaf-module-info.gradle.kts b/buildSrc/src/main/kotlin/flatlaf-module-info.gradle.kts index 2c3ec39a..6a08144a 100644 --- a/buildSrc/src/main/kotlin/flatlaf-module-info.gradle.kts +++ b/buildSrc/src/main/kotlin/flatlaf-module-info.gradle.kts @@ -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 } } diff --git a/buildSrc/src/main/kotlin/flatlaf-publish.gradle.kts b/buildSrc/src/main/kotlin/flatlaf-publish.gradle.kts index 9960b0df..3d1b1906 100644 --- a/buildSrc/src/main/kotlin/flatlaf-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/flatlaf-publish.gradle.kts @@ -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().configureEach { onlyIf { rootProject.hasProperty( "release" ) } } -// check whether parallel build is enabled -tasks.withType().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().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" + ) } } diff --git a/flatlaf-core/build.gradle.kts b/flatlaf-core/build.gradle.kts index 13f14e07..8fac105d 100644 --- a/flatlaf-core/build.gradle.kts +++ b/flatlaf-core/build.gradle.kts @@ -98,24 +98,30 @@ tasks { group = "verification" dependsOn( "jar" ) + // necessary for configuration cache + val classpath = sigtest.asPath + val signatureFile = "${project.name}-sigtest.txt" + val jarPath = jar.get().outputs.files.asPath + val version = version + doLast { ant.withGroovyBuilder { "taskdef"( "name" to "sigtest", "classname" to "org.netbeans.apitest.Sigtest", - "classpath" to sigtest.asPath ) + "classpath" to classpath ) "sigtest"( "action" to "generate", - "fileName" to "${project.name}-sigtest.txt", - "classpath" to jar.get().outputs.files.asPath, + "fileName" to signatureFile, + "classpath" to jarPath, "packages" to "com.formdev.flatlaf,com.formdev.flatlaf.themes,com.formdev.flatlaf.util", "version" to version, "release" to "1.8", // Java version "failonerror" to "true" ) "fixcrlf"( - "file" to "${project.name}-sigtest.txt", + "file" to signatureFile, "eol" to "lf" ) } } @@ -125,17 +131,23 @@ tasks { group = "verification" dependsOn( "jar" ) + // necessary for configuration cache + val classpath = sigtest.asPath + val signatureFile = "${project.name}-sigtest.txt" + val jarPath = jar.get().outputs.files.asPath + val version = version + doLast { ant.withGroovyBuilder { "taskdef"( "name" to "sigtest", "classname" to "org.netbeans.apitest.Sigtest", - "classpath" to sigtest.asPath ) + "classpath" to classpath ) "sigtest"( "action" to "check", - "fileName" to "${project.name}-sigtest.txt", - "classpath" to jar.get().outputs.files.asPath, + "fileName" to signatureFile, + "classpath" to jarPath, "packages" to "com.formdev.flatlaf,com.formdev.flatlaf.util", "version" to version, "release" to "1.8", // Java version diff --git a/flatlaf-natives/flatlaf-natives-linux/build.gradle.kts b/flatlaf-natives/flatlaf-natives-linux/build.gradle.kts index d73ab05f..8c88740a 100644 --- a/flatlaf-natives/flatlaf-natives-linux/build.gradle.kts +++ b/flatlaf-natives/flatlaf-natives-linux/build.gradle.kts @@ -40,6 +40,11 @@ var javaHome = System.getProperty( "java.home" ) if( javaHome.endsWith( "jre" ) && !file( "${javaHome}/include" ).exists() ) javaHome += "/.." +interface InjectedOps { + @get:Inject val fs: FileSystemOperations + @get:Inject val e: ExecOperations +} + tasks { register( "build-natives" ) { group = "build" @@ -115,16 +120,18 @@ tasks { } } ) + val injectedOps = project.objects.newInstance() + doLast { // copy shared library to flatlaf-core resources - copy { + injectedOps.fs.copy { from( linkedFile ) into( nativesDir ) rename( linkedFile.get().asFile.name, libraryName ) } - -// dump( linkedFile.asFile.get(), true ) } + +// dump( linkedFile, true, injectedOps ) } if( org.gradle.internal.os.OperatingSystem.current().isLinux && @@ -198,43 +205,44 @@ tasks { "-lgtk-3", ) + val injectedOps = project.objects.newInstance() + doLast { // copy shared library to flatlaf-core resources - copy { + injectedOps.fs.copy { from( "$outDir/$libraryName" ) into( nativesDir ) } - -// dump( file( "$outDir/$libraryName" ), false ) } + +// dump( file( "$outDir/$libraryName" ), false, injectedOps ) } } } /*dump -interface InjectedExecOps { @get:Inject val execOps: ExecOperations } -val injected = project.objects.newInstance() - -fun dump( dylib: File, disassemble: Boolean ) { - - val dylibDir = dylib.parent - injected.execOps.exec { commandLine( "size", dylib ); standardOutput = FileOutputStream( "$dylibDir/size.txt" ) } - injected.execOps.exec { - commandLine( "objdump", - // commands - "--archive-headers", - "--section-headers", - "--private-headers", - "--reloc", - "--dynamic-reloc", - "--syms", - // files - dylib ) - standardOutput = FileOutputStream( "$dylibDir/objdump.txt" ) +fun Task.dump( f: Any, disassemble: Boolean, injectedOps: InjectedOps ) { + doLast { + val dylib = if( f is RegularFileProperty) f.get().asFile else f as File + val dylibDir = dylib.parent + injectedOps.e.exec { commandLine( "size", dylib ); standardOutput = FileOutputStream( "$dylibDir/size.txt" ) } + injectedOps.e.exec { + commandLine( "objdump", + // commands + "--archive-headers", + "--section-headers", + "--private-headers", + "--reloc", + "--dynamic-reloc", + "--syms", + // files + dylib ) + standardOutput = FileOutputStream( "$dylibDir/objdump.txt" ) + } + if( disassemble ) + injectedOps.e.exec { commandLine( "objdump", "--disassemble-all", dylib ); standardOutput = FileOutputStream( "$dylibDir/disassemble.txt" ) } + injectedOps.e.exec { commandLine( "objdump", "--full-contents", dylib ); standardOutput = FileOutputStream( "$dylibDir/full-contents.txt" ) } + injectedOps.e.exec { commandLine( "hexdump", dylib ); standardOutput = FileOutputStream( "$dylibDir/hexdump.txt" ) } } - if( disassemble ) - injected.execOps.exec { commandLine( "objdump", "--disassemble-all", dylib ); standardOutput = FileOutputStream( "$dylibDir/disassemble.txt" ) } - injected.execOps.exec { commandLine( "objdump", "--full-contents", dylib ); standardOutput = FileOutputStream( "$dylibDir/full-contents.txt" ) } - injected.execOps.exec { commandLine( "hexdump", dylib ); standardOutput = FileOutputStream( "$dylibDir/hexdump.txt" ) } } dump*/ diff --git a/flatlaf-natives/flatlaf-natives-macos/build.gradle.kts b/flatlaf-natives/flatlaf-natives-macos/build.gradle.kts index 22e91318..ddd45a3c 100644 --- a/flatlaf-natives/flatlaf-natives-macos/build.gradle.kts +++ b/flatlaf-natives/flatlaf-natives-macos/build.gradle.kts @@ -43,8 +43,10 @@ var javaHome = System.getProperty( "java.home" ) if( javaHome.endsWith( "jre" ) ) javaHome += "/.." -interface InjectedExecOps { @get:Inject val execOps: ExecOperations } -val injected = project.objects.newInstance() +interface InjectedOps { + @get:Inject val fs: FileSystemOperations + @get:Inject val e: ExecOperations +} tasks { register( "build-natives" ) { @@ -96,12 +98,14 @@ tasks { } } ) + val injectedOps = project.objects.newInstance() + doLast { // sign shared library -// injected.execOps.exec { commandLine( "codesign", "-s", "FormDev Software GmbH", "--timestamp", "${linkedFile.asFile.get()}" ) } +// injectedOps.e.exec { commandLine( "codesign", "-s", "FormDev Software GmbH", "--timestamp", "${linkedFile.asFile.get()}" ) } // copy shared library to flatlaf-core resources - copy { + injectedOps.fs.copy { from( linkedFile ) into( nativesDir ) rename( linkedFile.get().asFile.name, libraryName ) @@ -110,9 +114,9 @@ tasks { /*dump val dylib = linkedFile.asFile.get() val dylibDir = dylib.parent - injected.execOps.exec { commandLine( "size", dylib ); standardOutput = FileOutputStream( "$dylibDir/size.txt" ) } - injected.execOps.exec { commandLine( "size", "-m", dylib ); standardOutput = FileOutputStream( "$dylibDir/size-m.txt" ) } - injected.execOps.exec { + injectedOps.e.exec { commandLine( "size", dylib ); standardOutput = FileOutputStream( "$dylibDir/size.txt" ) } + injectedOps.e.exec { commandLine( "size", "-m", dylib ); standardOutput = FileOutputStream( "$dylibDir/size-m.txt" ) } + injectedOps.e.exec { commandLine( "objdump", // commands "--archive-headers", @@ -130,8 +134,8 @@ tasks { dylib ) standardOutput = FileOutputStream( "$dylibDir/objdump.txt" ) } - injected.execOps.exec { commandLine( "objdump", "--disassemble-all", dylib ); standardOutput = FileOutputStream( "$dylibDir/disassemble.txt" ) } - injected.execOps.exec { commandLine( "objdump", "--full-contents", dylib ); standardOutput = FileOutputStream( "$dylibDir/full-contents.txt" ) } + injectedOps.e.exec { commandLine( "objdump", "--disassemble-all", dylib ); standardOutput = FileOutputStream( "$dylibDir/disassemble.txt" ) } + injectedOps.e.exec { commandLine( "objdump", "--full-contents", dylib ); standardOutput = FileOutputStream( "$dylibDir/full-contents.txt" ) } dump*/ } } diff --git a/flatlaf-natives/flatlaf-natives-windows/build.gradle.kts b/flatlaf-natives/flatlaf-natives-windows/build.gradle.kts index ed398496..2c5bb490 100644 --- a/flatlaf-natives/flatlaf-natives-windows/build.gradle.kts +++ b/flatlaf-natives/flatlaf-natives-windows/build.gradle.kts @@ -41,8 +41,10 @@ var javaHome = System.getProperty( "java.home" ) if( javaHome.endsWith( "jre" ) ) javaHome += "/.." -interface InjectedExecOps { @get:Inject val execOps: ExecOperations } -val injected = project.objects.newInstance() +interface InjectedOps { + @get:Inject val fs: FileSystemOperations + @get:Inject val e: ExecOperations +} tasks { register( "build-natives" ) { @@ -89,9 +91,11 @@ tasks { } } ) + val injectedOps = project.objects.newInstance() + doLast { // copy shared library to flatlaf-core resources - copy { + injectedOps.fs.copy { from( linkedFile ) into( nativesDir ) rename( linkedFile.get().asFile.name, libraryName ) @@ -101,9 +105,9 @@ tasks { val dumpbin = "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/dumpbin.exe" val dll = linkedFile.asFile.get() val dllDir = dll.parent - injected.execOps.exec { commandLine( dumpbin, "/all", "/rawdata:none", "/out:$dllDir/objdump.txt", dll ) } - injected.execOps.exec { commandLine( dumpbin, "/all", "/out:$dllDir/full-contents.txt", dll ) } - injected.execOps.exec { commandLine( dumpbin, "/disasm", "/out:$dllDir/disassemble.txt", dll ) } + injectedOps.e.exec { commandLine( dumpbin, "/all", "/rawdata:none", "/out:$dllDir/objdump.txt", dll ) } + injectedOps.e.exec { commandLine( dumpbin, "/all", "/out:$dllDir/full-contents.txt", dll ) } + injectedOps.e.exec { commandLine( dumpbin, "/disasm", "/out:$dllDir/disassemble.txt", dll ) } dump*/ } } diff --git a/flatlaf-testing/flatlaf-testing-modular-app/build.gradle.kts b/flatlaf-testing/flatlaf-testing-modular-app/build.gradle.kts index dda559ab..caee5834 100644 --- a/flatlaf-testing/flatlaf-testing-modular-app/build.gradle.kts +++ b/flatlaf-testing/flatlaf-testing-modular-app/build.gradle.kts @@ -32,16 +32,25 @@ flatlafModuleInfo { dependsOn( ":flatlaf-fonts-inter:jar" ) } +interface InjectedOps { + @get:Inject val fs: FileSystemOperations +} + tasks { register( "build-for-debugging" ) { group = "build" dependsOn( "build" ) + // necessary for configuration cache + val jar = project.tasks["jar"].outputs.files + val runtimeJars = configurations.runtimeClasspath.get().files + val injectedOps = project.objects.newInstance() + doLast { - copy { - from( project.tasks["jar"].outputs ) - from( configurations.runtimeClasspath ) + injectedOps.fs.copy { + from( jar ) + from( runtimeJars ) into( "run" ) rename( "-[0-9][0-9.]*[0-9]", "-999" ) } diff --git a/gradle.properties b/gradle.properties index 748f2026..197f4639 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,5 +17,5 @@ flatlaf.releaseVersion = 3.6.2 flatlaf.developmentVersion = 3.7-SNAPSHOT -org.gradle.parallel = true +org.gradle.configuration-cache = true # org.gradle.warning.mode = all