Skip to content

Commit

Permalink
Update Gradle Build Scripts
Browse files Browse the repository at this point in the history
* Use `ivy-publish` replace of deprecated `Upload` task
* Migrate to Gradle 8
* Remove `buildSrc/src/main/groovy/org/grails/gradle/Upload.java`

Closes gh-799
  • Loading branch information
rainboyan committed Dec 7, 2024
1 parent 244e297 commit 3c9e3da
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 204 deletions.
42 changes: 18 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ subprojects { project ->
apply plugin: 'groovy'
if (!isTestSuite) {
apply plugin: 'maven-publish'
apply plugin: 'ivy-publish'
apply plugin: 'signing'
}
apply plugin: 'eclipse'
Expand All @@ -195,18 +196,29 @@ subprojects { project ->
if (!isTestSuite) {

publishing {
repositories {
ivy {
name = 'graceDist'
url = homeDistDir
patternLayout {
artifact '[artifact]-[revision](-[classifier])(.[ext])'
}
}
}
publications {
maven(MavenPublication) {
from components.java

if (project.name != 'grace-gradle-plugin') {
pom.withXml {
def xml = asNode()
pom.withXml {
def xml = asNode()

xml.children().last() + pomInfo
}
xml.children().last() + pomInfo
}
}

ivy(IvyPublication) {
from components.java
}
}
}

Expand Down Expand Up @@ -258,7 +270,7 @@ subprojects { project ->
toolVersion = checkstyleVersion
configDirectory.set(rootProject.file("gradle/checkstyle"))
}

codenarc {
toolVersion = codenarcVersion
setConfigFile(new File("$rootDir/gradle/codenarc/codenarc.groovy"))
Expand Down Expand Up @@ -384,24 +396,6 @@ subprojects { project ->
exclude group: 'commons-logging', module: 'commons-logging'
}
}

if (!isTestSuite) {
task installToHomeDist(type: org.grails.gradle.Upload) {
configuration = configurations.archives
repositories {
flatDir name: 'libs', dirs: distInstallDir
}
}

project.tasks.withType(org.gradle.api.publish.maven.tasks.PublishToMavenLocal) { org.gradle.api.publish.maven.tasks.PublishToMavenLocal t ->
t.dependsOn installToHomeDist
t.doLast {
ant.copy(todir: homeDistDir, flatten: true, includeEmptyDirs: false) {
fileset dir: distInstallDir
}
}
}
}
}

task clean(type: Delete, group: 'build') {
Expand Down
143 changes: 0 additions & 143 deletions buildSrc/src/main/groovy/org/grails/gradle/Upload.java

This file was deleted.

16 changes: 6 additions & 10 deletions grace-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {
api gradleApi()
api libs.maven.model
api libs.spring.boot.gradle.plugin
api libs.spring.boot.loader.tools
api libs.spring.dependency.management.plugin

documentation libs.jansi
Expand Down Expand Up @@ -151,17 +152,12 @@ publishing {
pom {
name = "Grace Gradle Plugin"
description = "A Gradle plugin for Grace which provides a bunch of useful plugins"
}
}
}
}

project.afterEvaluate {
project.publishing.publications.each { MavenPublication publication->
if (publication.name != "pluginMaven" || publication.name != "maven") {
publication.pom.withXml {
def xml = asNode()
xml.children().last() + pomInfo
withXml {
def xml = asNode()

xml.children().last() + pomInfo
}
}
}
}
Expand Down
57 changes: 30 additions & 27 deletions gradle/assemble.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.apache.tools.ant.filters.ReplaceTokens

apply plugin: org.grails.gradle.GrailsBuildPlugin

def libsConfigurations = []
Expand Down Expand Up @@ -73,16 +71,7 @@ task populateDependencies(type: Sync, dependsOn: configurePopulateDependencies)
includeEmptyDirs = false
}

// Can't use sync task here because this directory contains other things as well.
task sourcesJars(type: Sync) {
into homeSrcDir
from subprojects.findAll { !it.name.startsWith('grace-test-suite') && !it.name.startsWith('grace-dependencies') && !it.name.startsWith('grace-bom') }.sourcesJar*.outputs*.files

// sourcesFor comes from GrailsBuildPlugin
from { sourcesFor(libsConfigurations*.copyRecursive { it.name.startsWith('grace-datastore') }.collect { it.transitive = false; it }) }
}

task grailsCreateStartScripts(type: GrailsCreateStartScripts) {
task grailsCreateStartScripts(type: GrailsCreateStartScripts, dependsOn: populateDependencies) {
description = "Creates OS specific scripts to run grace-shell as a JVM application."
mainClass = 'org.grails.cli.GrailsCli'
applicationName = 'grace'
Expand Down Expand Up @@ -126,15 +115,36 @@ class GrailsCreateStartScripts extends org.gradle.api.tasks.application.CreateSt
}
}

task install(dependsOn: [populateDependencies, grailsCreateStartScripts]) { task ->
task install(dependsOn: populateDependencies) { task ->
subprojects { Project project ->
if(!project.name.startsWith('grace-test-suite')) {
task.dependsOn("$project.name:publishToMavenLocal")
}
}
}

task zipDist(type: Zip, dependsOn: [sourcesJars, install]) {
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")
}
}
}
}

task zipDist(type: Zip, dependsOn: [install, publishToDist, grailsCreateStartScripts]) {
destinationDirectory = "${buildDir}/distributions" as File
archiveBaseName = 'grace'
archiveAppendix = grailsVersion
Expand All @@ -143,7 +153,7 @@ task zipDist(type: Zip, dependsOn: [sourcesJars, install]) {

into("grace-$grailsVersion") {
from(projectDir) {
include 'bin/grace', 'bin/grace.bat', 'lib/', 'media/', 'samples/', 'scripts/', 'LICENSE.txt', 'INSTALL.txt', "src/"
include 'bin/grace', 'bin/grace.bat', 'lib/', 'media/', 'samples/', 'scripts/', 'LICENSE.txt', 'INSTALL.txt'
exclude 'ant/bin', 'src/grace', 'src/war'
}
from(docs.destinationDir) {
Expand All @@ -156,20 +166,13 @@ task zipDist(type: Zip, dependsOn: [sourcesJars, install]) {
into "dist"
exclude "*.zip*"
exclude "*.tar*"
exclude '*-javadoc.jar*', '*-sources.jar*', 'ivy-*'
}
from(homeDistDir) {
into "src"
include '*-sources.jar'
}
}
}

task assemble(dependsOn: zipDist)

task publishToGrailsLocal { task ->
subprojects { Project project ->
if (!project.name.startsWith('grails-test-suite')) {
if (project.name == 'grails-gradle-plugin') {
task.dependsOn("$project.name:publishPluginMavenPublicationToGrailsLocalRepository")
} else {
task.dependsOn("$project.name:publishMavenPublicationToGrailsLocalRepository")
}
}
}
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ spring-boot-cli = { module = "org.springframework.boot:spring-boot-cli", version
spring-boot-configurationProcessor = { module = "org.springframework.boot:spring-boot-configuration-processor", version.ref = "spring-boot" }
spring-boot-dependencies = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "spring-boot" }
spring-boot-gradle-plugin = { module = "org.springframework.boot:spring-boot-gradle-plugin", version.ref = "spring-boot" }
spring-boot-loader-tools = { module = "org.springframework.boot:spring-boot-loader-tools", version.ref = "spring-boot" }
spring-boot-test = { module = "org.springframework.boot:spring-boot-test", version.ref = "spring-boot" }
spring-context = { module = "org.springframework:spring-context", version.ref = "spring-framework" }
spring-contextSupport = { module = "org.springframework:spring-context-support", version.ref = "spring-framework" }
Expand Down

0 comments on commit 3c9e3da

Please sign in to comment.