From 23b94e4eafbf704d0ed74bad4fe152b0a0e331e7 Mon Sep 17 00:00:00 2001 From: Michael Yan Date: Tue, 24 Dec 2024 10:37:19 +0800 Subject: [PATCH] Improve Gradle build scripts Closes gh-820 --- build.gradle | 14 +++++++------ grace-gradle-plugin/build.gradle | 34 ++------------------------------ gradle/assemble.gradle | 16 +++------------ 3 files changed, 13 insertions(+), 51 deletions(-) diff --git a/build.gradle b/build.gradle index e81b2acd3d..ff1f0ea68b 100644 --- a/build.gradle +++ b/build.gradle @@ -138,7 +138,11 @@ subprojects { project -> ext.isTestSuite = project.name.startsWith("grace-test-suite") ext.isCiBuild = project.hasProperty("isCiBuild") || System.getenv().get("CI") as Boolean ext.pomInfo = { - if (project.name != 'grace-gradle-plugin') { + if (project.name == 'grace-gradle-plugin') { + delegate.name "Grace Gradle Plugin" + delegate.description "Grace Framework : A Gradle plugin for Grace which provides a bunch of useful plugins" + } + else { def projectName = project.name.split('-')*.capitalize().join(' ') delegate.name projectName delegate.description "Grace Framework : $projectName" @@ -223,11 +227,9 @@ subprojects { project -> } afterEvaluate { - if (project.name != 'grace-gradle-plugin') { - signing { - required { isReleaseVersion && gradle.taskGraph.hasTask("publish") } - sign publishing.publications.maven - } + signing { + required { isReleaseVersion && gradle.taskGraph.hasTask("publish") } + sign publishing.publications.maven } } diff --git a/grace-gradle-plugin/build.gradle b/grace-gradle-plugin/build.gradle index 19594ae2cf..4f1bf73542 100644 --- a/grace-gradle-plugin/build.gradle +++ b/grace-gradle-plugin/build.gradle @@ -49,6 +49,8 @@ dependencies { } gradlePlugin { + automatedPublishing = false + plugins { graceCore { displayName = "Grace Core Gradle Plugin" @@ -127,38 +129,6 @@ tasks.withType(Copy) { } } -if (isReleaseVersion) { - afterEvaluate { - signing { - required { isReleaseVersion && gradle.taskGraph.hasTask("publish") } - Publication[] publications = new Publication[publishing.publications.size()] - publishing.publications.findAll().toArray(publications) - sign(publications) - } - } - - tasks.withType(Sign) { - onlyIf { isReleaseVersion } - } -} - tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach { shouldRunAfter(tasks.withType(Sign)) } - -publishing { - publications { - pluginMaven(MavenPublication) { - pom { - name = "Grace Gradle Plugin" - description = "A Gradle plugin for Grace which provides a bunch of useful plugins" - - withXml { - def xml = asNode() - - xml.children().last() + pomInfo - } - } - } - } -} diff --git a/gradle/assemble.gradle b/gradle/assemble.gradle index 67a0cb9151..ef7e91196b 100644 --- a/gradle/assemble.gradle +++ b/gradle/assemble.gradle @@ -126,20 +126,10 @@ task install(dependsOn: populateDependencies) { task -> task publishToDist { task -> subprojects { Project project -> if (!project.name.startsWith('grace-test-suite') && !project.name.startsWith('grace-dependencies') && !project.name.startsWith('grace-bom')) { - if (project.name == 'grace-gradle-plugin') { - project.tasks.named("generateMetadataFileForIvyPublication").configure { - enabled = false - } - project.tasks.named("generateMetadataFileForPluginIvyPublication").configure { - enabled = false - } - task.dependsOn("$project.name:publishAllPublicationsToGraceDistRepository") - } else { - project.tasks.named("generateMetadataFileForIvyPublication").configure { - enabled = false - } - task.dependsOn("$project.name:publishAllPublicationsToGraceDistRepository") + project.tasks.named("generateMetadataFileForIvyPublication").configure { + enabled = false } + task.dependsOn("$project.name:publishAllPublicationsToGraceDistRepository") } } }