Skip to content

Commit

Permalink
build: streamline build and sort out dependencies
Browse files Browse the repository at this point in the history
- This commit tries to sort out the dependency chains used, to enable further future decoupling. This will add a lot of exclusions to the POMs, but we can comment out the exclusions in the dependencies blocks if we think this is a problem.
- Streamline the build with composition.
  • Loading branch information
matrei committed Jan 13, 2025
1 parent 124129f commit 53cee6e
Show file tree
Hide file tree
Showing 19 changed files with 785 additions and 404 deletions.
56 changes: 21 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,77 +1,63 @@
io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository

buildscript {
repositories {
maven { url "https://repo.grails.org/grails/core" }
maven { url = 'https://repo.grails.org/grails/core' }
}
dependencies {
classpath platform("org.grails:grails-bom:$grailsVersion")
classpath "io.github.gradle-nexus:publish-plugin:2.0.0"
classpath 'io.github.gradle-nexus:publish-plugin:2.0.0'
}
}

ext {
isCiBuild = (System.getenv().get("CI") as Boolean)
isSnapshot = project.projectVersion.endsWith('-SNAPSHOT')
isCiBuild = System.getenv('CI')
isSnapshot = projectVersion.endsWith('-SNAPSHOT')
isReleaseVersion = !isSnapshot
}

group = "org.grails"
version project.projectVersion
group = 'org.grails'
version = projectVersion

apply plugin: 'java-library'
apply plugin: 'idea'

allprojects { prj ->
allprojects {
repositories {
mavenCentral()
maven { url = 'https://repo.grails.org/grails/core' }
// mavenLocal() // Keep, this will be uncommented and used by CI (groovy-joint-workflow)
if (groovyVersion?.endsWith('-SNAPSHOT')) {
if (findProperty('groovyVersion')?.endsWith('-SNAPSHOT')) {
maven {
name = 'ASF Snapshot repo'
url = 'https://repository.apache.org/content/repositories/snapshots'
}
}

if (System.getenv("GITHUB_MAVEN_PASSWORD") && !grailsVersion.endsWith('-SNAPSHOT')) {
System.out.println("Adding Grails Core Repo for project: ${prj.name}")
if (System.getenv('GITHUB_MAVEN_PASSWORD') && !grailsVersion.endsWith('-SNAPSHOT')) {
System.out.println("Adding Grails Core Staging Repo for project: $name")
maven {
url = 'https://maven.pkg.github.com/grails/grails-core'
credentials {
username = 'DOES_NOT_MATTER'
password = System.getenv("GITHUB_MAVEN_PASSWORD")
password = System.getenv('GITHUB_MAVEN_PASSWORD')
}
}
}
}

apply plugin: 'groovy'
}

if (isReleaseVersion) {
apply plugin: "io.github.gradle-nexus.publish-plugin"

apply plugin: 'io.github.gradle-nexus.publish-plugin'
nexusPublishing {
repositories {
sonatype {
def ossUser = System.getenv('SONATYPE_USERNAME') ?: project.findProperty('sonatypeOssUsername') ?: ''
def ossPass = System.getenv('SONATYPE_PASSWORD') ?: project.findProperty('sonatypeOssPassword') ?: ''
def ossStagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID') ?: project.findProperty('sonatypeOssStagingProfileId') ?: ''
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
username = ossUser
password = ossPass
stagingProfileId = ossStagingProfileId
nexusUrl = uri('https://s01.oss.sonatype.org/service/local')
username = System.getenv('SONATYPE_USERNAME') ?: project.findProperty('sonatypeOssUsername') ?: ''
password = System.getenv('SONATYPE_PASSWORD') ?: project.findProperty('sonatypeOssPassword') ?: ''
stagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID') ?: project.findProperty('sonatypeOssStagingProfileId') ?: ''
}
}
transitionCheckOptions {
maxRetries.set(60)
delayBetween.set(java.time.Duration.ofMillis(4000))
}
}

//do not generate extra load on Nexus with new staging repository if signing fails
tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach {
shouldRunAfter(tasks.withType(Sign))
tasks.withType(InitializeNexusStagingRepository).configureEach {
shouldRunAfter = tasks.withType(Sign)
}
}

apply from: rootProject.layout.projectDirectory.file('gradle/aggregate-groovydoc.gradle')
apply from: layout.projectDirectory.file('gradle/documentation-config.gradle')
48 changes: 20 additions & 28 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,28 @@ import grails.doc.gradle.PublishGuide

buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
maven { url = 'https://repo.grails.org/grails/core' }
}
dependencies {
classpath platform("org.grails:grails-bom:$grailsVersion")
classpath "org.grails:grails-docs"
classpath "org.grails:grails-docs:$grailsVersion"
}
}

version rootProject.version

apply plugin: 'groovy'

//TODO: PublishGuide should eventually ensure the build directory exists
// TODO: PublishGuide should eventually ensure the build directory exists
tasks.register('docsBuild') {
doFirst {
project.layout.buildDirectory.get().asFile.mkdirs()
}

// Do not cache this task since the directory must exist if publishGuide is going to run
outputs.upToDateWhen { false }
}

tasks.register('publishGuide', PublishGuide) {
dependsOn 'docsBuild'

group = JavaBasePlugin.DOCUMENTATION_GROUP
group = 'documentation'
description = 'Generate Guide'
dependsOn('docsBuild')

targetDir = project.layout.buildDirectory.dir('docs').get().asFile
outputs.dir(targetDir) // ensure gradle understands what this task generates
Expand All @@ -41,37 +35,35 @@ tasks.register('publishGuide', PublishGuide) {
resourcesDir = project.file('src/main/docs/resources')
properties = [
'safe' : 'UNSAFE', // Make sure any asciidoc security is disabled
'version' : project.version,
'version' : projectVersion,
'title' : 'Groovy Server Pages (GSP)',
'subtitle' : 'GSP (Groovy Server Pages) - A server-side view rendering technology based on Groovy',
// TODO: The javaee documentation has not been updated to jakarata
// TODO: The javaee documentation has not been updated to jakarta
'javaee' : 'https://docs.oracle.com/javaee/7/api/',
'jakartaee' : 'https://jakarta.ee/specifications/platform/10/apidocs/',
'javase' : 'https://docs.oracle.com/en/java/javase/17/docs/api/index.html',
'groovyapi' : "https://docs.groovy-lang.org/$groovyVersion/html/gapi/",
'groovyjdk' : "https://docs.groovy-lang.org/$groovyVersion/html/groovy-jdk/",
'groovyapi' : "https://docs.groovy-lang.org/latest/html/gapi/",
'groovyjdk' : "https://docs.groovy-lang.org/latest/html/groovy-jdk/",
'grailsapi' : "https://docs.grails.org/$grailsVersion/api/",
'grailsdocs' : "https://docs.grails.org/$grailsVersion/",
'gormapi' : 'http://gorm.grails.org/latest/api/',
'grailsdocs' : "https://docs.grails.org/$grailsVersion/",
'gormapi' : 'https://gorm.grails.org/latest/api/',
'springapi' : 'https://docs.spring.io/spring/docs/current/javadoc-api/',
'commandLineRef': "https://docs.grails.org/$grailsVersion/ref/Command%20Line",
'controllersRef': "https://docs.grails.org/$grailsVersion/ref/Controllers"
] as Properties

doLast {
File destination = project.layout.buildDirectory.file("docs/guide/index.html").get().asFile
File destination = project.layout.buildDirectory.file('docs/guide/index.html').get().asFile
destination.delete()

project.layout.buildDirectory.file('docs/guide/single.html').get().asFile.renameTo(destination)
project.layout.buildDirectory.file('docs/index.html').get().asFile.text = '''
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="refresh" content="0; url=guide/index.html" />
</head>
</body>
</html>
'''
<html lang="en">
<head>
<title>Redirecting...</title>
<meta http-equiv="refresh" content="0; url=guide/index.html" />
</head>
<body></body>
</html>
'''.stripIndent(8)
}
}
91 changes: 28 additions & 63 deletions examples/sitemesh3/build.gradle
Original file line number Diff line number Diff line change
@@ -1,78 +1,43 @@
buildscript {
repositories {
maven { url "https://repo.grails.org/grails/core" }
maven { url = 'https://repo.grails.org/grails/core' }
}
dependencies {
classpath platform("org.grails:grails-bom:$grailsVersion")
classpath "org.grails:grails-gradle-plugin"
classpath 'org.grails:grails-gradle-plugin'
}
}

plugins {
id "war"
id "com.bertramlabs.asset-pipeline" version "5.0.5"
}

apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"org.grails.grails-plugin"

version '0.0.1'
group 'org.sitemesh.grails.plugins.sitemesh3'
version = '0.0.1'
group = 'org.sitemesh.grails.plugins.sitemesh3'

apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin: 'org.grails.grails-web'
apply plugin: 'org.grails.grails-gsp'

dependencies {
// for testing purposes
// implementation files('lib/sitemesh-3.1.0-SNAPSHOT.jar', 'lib/spring-boot-starter-sitemesh-3.1.0-SNAPSHOT-plain.jar')
console "org.grails:grails-console"

implementation "org.grails:grails-plugin-databinding"
implementation "org.grails:grails-plugin-i18n"
implementation "org.grails:grails-plugin-interceptors"
implementation "org.grails:grails-plugin-rest"
implementation "org.grails:grails-plugin-services"
implementation "org.grails:grails-plugin-url-mappings"
implementation "org.grails:grails-web-boot"
implementation project(':grails-plugin-gsp')
implementation project(':grails-plugin-sitemesh3')

runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails"
runtimeOnly "com.h2database:h2"
runtimeOnly "org.apache.tomcat:tomcat-jdbc"
runtimeOnly "org.fusesource.jansi:jansi"
runtimeOnly "org.grails.plugins:hibernate5"
runtimeOnly "org.grails.plugins:scaffolding"
runtimeOnly "org.grails:grails-core"
runtimeOnly "org.grails:grails-logging"
runtimeOnly "org.springframework.boot:spring-boot-autoconfigure"
runtimeOnly "org.springframework.boot:spring-boot-starter-actuator"
runtimeOnly "org.springframework.boot:spring-boot-starter-logging"
runtimeOnly "org.springframework.boot:spring-boot-starter-tomcat"
runtimeOnly "org.springframework.boot:spring-boot-starter-validation"

runtimeOnly "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:$jstlVersion"
runtimeOnly "org.glassfish.web:jakarta.servlet.jsp.jstl:$jstlVersion"
runtimeOnly 'org.apache.tomcat.embed:tomcat-embed-jasper:10.1.0' // jsp example
implementation platform("org.grails:grails-bom:$grailsVersion")

testImplementation 'org.grails:grails-gorm-testing-support'
testImplementation 'org.grails:grails-web-testing-support'
testImplementation 'org.spockframework:spock-core'
integrationTestImplementation testFixtures ("org.grails.plugins:geb")
}

tasks.withType(Test) {
useJUnitPlatform()
}

assets {
minifyJs = true
minifyCss = true
packagePlugin = true
implementation project(':grails-plugin-sitemesh3')
implementation 'org.grails:grails-core'
implementation 'org.grails:grails-plugin-controllers'

runtimeOnly project(':grails-plugin-gsp')
runtimeOnly 'com.bertramlabs.plugins:asset-pipeline-grails'
runtimeOnly 'org.grails:grails-plugin-url-mappings'
runtimeOnly 'org.grails:grails-plugin-i18n'
runtimeOnly 'org.springframework.boot:spring-boot-autoconfigure'
runtimeOnly 'org.springframework.boot:spring-boot-starter-logging'
runtimeOnly 'org.springframework.boot:spring-boot-starter-tomcat'

// JSP support
runtimeOnly 'jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api'
runtimeOnly 'org.apache.tomcat.embed:tomcat-embed-jasper'
runtimeOnly 'org.glassfish.web:jakarta.servlet.jsp.jstl'

integrationTestImplementation testFixtures('org.grails.plugins:geb')
integrationTestImplementation 'org.grails:grails-testing-support'
}

bootRun {
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}
apply from: rootProject.layout.projectDirectory.file('gradle/java-config.gradle')
apply from: rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
10 changes: 6 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ projectVersion=7.0.0-SNAPSHOT
# for docs
githubBranch = 7.0.x

grailsVersion=7.0.0-SNAPSHOT
javaVersion=17

commonsTextVersion=1.13.0
elApiVersion=6.0.1
grailsVersion=7.0.0-SNAPSHOT
groovyVersion=4.0.24
jspApiVersion=4.0.0
jstlVersion=3.0.1
sitemeshLibraryVersion=3.2.2
sitemeshVersion=3.2.2

# This prevents the Grails Gradle Plugin from unnecessarily excluding slf4j-simple in the generated POMs
# https://github.com/grails/grails-gradle-plugin/issues/222
slf4jPreventExclusion=true

org.gradle.caching=true
Expand Down
30 changes: 0 additions & 30 deletions gradle/aggregate-groovydoc.gradle

This file was deleted.

43 changes: 43 additions & 0 deletions gradle/documentation-config.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
configurations.register('documentation')

dependencies {
documentation "org.apache.groovy:groovy-groovydoc:4.0.24"
documentation "org.apache.groovy:groovy-ant:4.0.24"
}

tasks.register('cleanDocs', Delete) {
group = 'documentation'
delete(rootProject.layout.buildDirectory.dir('docs'))
}

tasks.register('groovydoc', Groovydoc) {
group = 'documentation'
description = 'Copies Groovy API Documentation for all supporting projects'
Set<Project> groovyDocProjects = rootProject.subprojects.findAll {
it.name != 'docs' && !it.name.startsWith('examples')
}
def groovydocClasspath = files(configurations.documentation + groovyDocProjects.configurations.compileClasspath)
classpath = groovydocClasspath
groovyClasspath = groovydocClasspath
docTitle = "Groovy Server Pages (GSP) - ${project.name} - ${project.version}"
access = GroovydocAccess.PRIVATE
includeAuthor = true
includeMainForScripts = false
processScripts = false
dependsOn = [tasks.named('cleanDocs')] + groovyDocProjects.collect { it.tasks.named('groovydoc') }
destinationDir = project.layout.buildDirectory.dir('docs/api').get().asFile
source = groovyDocProjects.sourceSets.main.groovy.srcDirs
doLast { delete(rootProject.layout.buildDirectory.dir('tmp')) }
}

tasks.register('docs') {
group = 'documentation'
dependsOn(':groovydoc', 'docs:publishGuide')
finalizedBy('copyGuide')
}

tasks.register('copyGuide', Copy) {
group = 'documentation'
from(project(':docs').tasks.named('publishGuide'))
into rootProject.layout.buildDirectory.dir('docs')
}
Loading

0 comments on commit 53cee6e

Please sign in to comment.