Skip to content

Commit

Permalink
Grace: update gradle build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboyan committed Feb 27, 2024
1 parent 4e3956a commit 417fd46
Show file tree
Hide file tree
Showing 56 changed files with 667 additions and 614 deletions.
183 changes: 103 additions & 80 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ buildscript {
dependencies {
classpath "io.github.gradle-nexus:publish-plugin:$gradleNexusPublishPluginVersion"
classpath "com.netflix.nebula:gradle-extra-configurations-plugin:$gradleExtraConfigurationsPluginVersion"
classpath "io.sdkman:gradle-sdkvendor-plugin:$gradleSdkVendorVersion"
classpath "org.gradle:test-retry-gradle-plugin:$gradleTestRetryPlugin"
classpath "org.codenarc:CodeNarc:$codenarcVersion"
}
Expand All @@ -30,17 +31,17 @@ ext {
homeSrcDir = file("src")
}

ext."signing.keyId" = System.getenv("SIGNING_KEY") ?: project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : null
ext."signing.password" = System.getenv("SIGNING_PASSPHRASE") ?: project.hasProperty("signing.password") ? project.getProperty('signing.password') : null
ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : null

// Groovy is added as a dependency to both the 'groovy' and 'compile'
// configurations, so place the dependency in a shared variable. The
// 'compile' is required so that Groovy appears as a dependency in the
// artifacts' POMs.
ext.jointBuildGroovyJarProperty = System.getProperty('groovy.jar')
ext.groovyDependency = null

ext."signing.keyId" = System.getenv("SIGNING_KEY") ?: project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : null
ext."signing.password" = System.getenv("SIGNING_PASSPHRASE") ?: project.hasProperty("signing.password") ? project.getProperty('signing.password') : null
ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : null

if (jointBuildGroovyJarProperty) {
def jointBuildGroovyJar = file(jointBuildGroovyJarProperty)
if (jointBuildGroovyJar.exists()) {
Expand All @@ -56,41 +57,40 @@ if (jointBuildGroovyJarProperty) {
}

version = grailsVersion
group = "org.grails"
group = "org.graceframework"

apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: "io.github.gradle-nexus.publish-plugin"

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

nexusPublishing {
repositories {
sonatype {
def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : ''
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
username = ossUser
password = ossPass
stagingProfileId = ossStagingProfileId
}
nexusPublishing {
repositories {
sonatype {
def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : ''
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
username = ossUser
password = ossPass
stagingProfileId = ossStagingProfileId
}
}

transitionCheckOptions {
maxRetries.set(40)
delayBetween.set(java.time.Duration.ofMillis(2000))
}
transitionCheckOptions {
maxRetries.set(40)
delayBetween.set(java.time.Duration.ofMillis(2000))
}
}

allprojects {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://repo.grails.org/grails/core" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
if (project.projectVersion.endsWith('-SNAPSHOT')) {
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
}
}

configurations {
Expand Down Expand Up @@ -131,18 +131,21 @@ apply from: "gradle/idea.gradle"

subprojects { project ->
version = grailsVersion
group = "org.grails"
group = "org.graceframework"

configurations {
documentation
}

ext.isTestSuite = project.name.startsWith("grails-test-suite")
ext.isTestSuite = project.name.startsWith("grace-test-suite")
ext.isCiBuild = project.hasProperty("isCiBuild") || System.getenv().get("CI") as Boolean
ext.pomInfo = {
delegate.name 'Grails Framework'
delegate.description 'Grails Web Application Framework'
delegate.url 'https://grails.org/'
if (project.name != 'grace-gradle-plugin') {
def projectName = project.name.split('-')*.capitalize().join(' ')
delegate.name projectName
delegate.description "Grace Framework : $projectName"
}
delegate.url 'https://github.com/graceframework/grace-framework'

delegate.licenses {
delegate.license {
Expand All @@ -153,26 +156,15 @@ subprojects { project ->
}

delegate.scm {
delegate.url 'scm:[email protected]:rainboyan/grails-framework.git'
delegate.connection 'scm:[email protected]:rainboyan/grails-framework.git'
delegate.developerConnection 'scm:[email protected]:rainboyan/grails-framework.git'
delegate.url 'scm:[email protected]:graceframework/grace-framework.git'
delegate.connection 'scm:[email protected]:graceframework/grace-framework.git'
delegate.developerConnection 'scm:[email protected]:graceframework/grace-framework.git'
}

delegate.developers {
delegate.developer {
delegate.id 'graemerocher'
delegate.name 'Graeme Rocher'
}
delegate.developer {
delegate.id 'jeffscottbrown'
delegate.name 'Jeff Brown'
}
delegate.developer {
delegate.id 'lhotari'
delegate.name 'Lari Hotari'
}
delegate.developer {
delegate.id 'rainboyan'
delegate.email '[email protected]'
delegate.name 'Michael Yan'
}
}
Expand Down Expand Up @@ -203,40 +195,31 @@ subprojects { project ->
}

if (!isTestSuite) {
publishing {
if (isBuildSnapshot) {
repositories {
maven {
credentials {
def u = System.getenv("ARTIFACTORY_USERNAME") ?: project.hasProperty("artifactoryPublishUsername") ? project.artifactoryPublishUsername : ''
def p = System.getenv("ARTIFACTORY_PASSWORD") ?: project.hasProperty("artifactoryPublishPassword") ? project.artifactoryPublishPassword : ''
username = u
password = p
}
url "https://repo.grails.org/grails/libs-snapshots-local"
}
}
}

if (project.name in ['grails-bom', 'grails-dependencies', 'grails-gradle-plugin']) return

publishing {
publications {
mavenJava(MavenPublication) {
maven(MavenPublication) {
from components.java

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

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

// signing {
// required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
// sign publishing.publications.mavenJava
// }
afterEvaluate {
if (project.name != 'grace-gradle-plugin') {
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
sign publishing.publications.maven
}
}
}

tasks.withType(Sign) {
onlyIf { isReleaseVersion }
Expand All @@ -258,18 +241,36 @@ subprojects { project ->

}

if (project.name in ['grails-bom', 'grails-dependencies']) return
if (project.name == 'grace-dependencies') return
if (project.name == 'grace-bom') return

sourceCompatibility = 11
targetCompatibility = 11

jar {
if (project.name =~ /^(grace-web|grace-plugin-|grace-test-suite|grace-test)/) {
dependencies {
api libs.javax.servlet
// MockHttpServletRequest/Response/Context used in many classes
api libs.spring.test, {
exclude group: 'commons-logging', module:'commons-logging'
}
}
}

if (project.name =~ /^(grace-plugin-datasource|grace-test-suite)/) {
dependencies {
testImplementation libs.hsqldb
testImplementation libs.h2
}
}

jar{
manifest.mainAttributes(
"Built-By": System.properties['user.name'],
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
"Implementation-Title": "Grails Framework",
"Implementation-Title": "Grace Framework",
"Implementation-Version": grailsVersion,
"Implementation-Vendor": 'grails.org')
"Implementation-Vendor": 'graceframework.org')
}

checkstyle {
Expand Down Expand Up @@ -297,14 +298,11 @@ subprojects { project ->
groovyOptions.fork(memoryInitialSize: '128M', memoryMaximumSize: '1G')
groovyOptions.encoding = "UTF-8"
options.encoding = "UTF-8"
options.deprecation = true
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

configure([compileJava, compileTestJava]) {
options.deprecation = true
options.debug = true
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
options.debug = false
}

configure([groovydoc]) {
Expand Down Expand Up @@ -338,7 +336,7 @@ subprojects { project ->
testImplementation libs.junit.platform.runner
testRuntimeOnly libs.junit.jupiter.engine

if (project.name != "grails-docs") {
if (project.name != "grace-docs") {
// Logging
api libs.slf4j.api
api libs.slf4j.jcl
Expand Down Expand Up @@ -404,7 +402,11 @@ subprojects { project ->
configurations {
meta
published.extendsFrom archives, meta
all*.exclude group:'commons-logging', module: 'commons-logging'
testRuntimeOnly {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.grails', module: 'grails-bootstrap'
exclude group: 'org.grails', module: 'grails-core'
}
}

if (!isTestSuite) {
Expand Down Expand Up @@ -463,3 +465,24 @@ project.afterEvaluate {
}
}
}

apply plugin: "io.sdkman.vendors"
sdkman {
candidate = "grace"
version = project.version
url = "https://github.com/graceframework/grace-framework/releases/download/v${project.version}/grace-${project.version}.zip"
hashtag = "graceframework"
}

task sdkManRelease {
group 'SDKMAN! Release'
description 'Performs a Major or Minor Release depend on project version'
if (project.projectVersion.endsWith("SNAPSHOT")) {
// Do nothing
} else if (project.projectVersion.contains("M") || project.projectVersion.contains("RC")) {
dependsOn 'sdkMinorRelease'
}
else {
dependsOn 'sdkMajorRelease'
}
}
4 changes: 2 additions & 2 deletions grace-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
api project(":grails-bootstrap")
api project(":grails-util")
api project(":grace-bootstrap")
api project(":grace-util")

api(libs.grails.datastore.core) {
transitive = false
Expand Down
22 changes: 11 additions & 11 deletions grace-bom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ publishing {
pom.withXml {
def xml = asNode()

xml.children().last() + pomInfo
xml.children().last() + {
def mkp = delegate

mkp.properties {

for (dep in grails.plugins) {
String version = dep.value
tokens["grails-plugin-${dep.key}.version"] = version
tokens["grace-plugin-${dep.key}.version"] = version
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
throw new RuntimeException("Cannot have a snapshot dependency on a plugin [$dep.key] for a release!")
}
mkp."grails-plugin-${dep.key}.version"(version)
mkp."grace-plugin-${dep.key}.version"(version)
}

for (dep in grails.profiles) {
String version = dep.value
tokens["grails-profile-${dep.key}.version"] = version
tokens["grace-profile-${dep.key}.version"] = version
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
throw new RuntimeException("Cannot have a snapshot dependency on a profile [$dep.key] for a release!")
}
mkp."grails-profile-${dep.key}.version"(version)
mkp."grace-profile-${dep.key}.version"(version)
}

for (ver in libraryVersions) {
Expand All @@ -60,13 +60,13 @@ publishing {
mkp.dependencyManagement {
mkp.dependencies {
for (sub in project.parent.subprojects) {
if (sub.name == 'grails-bom') continue
if (sub.name == 'grace-bom') continue

mkp.dependency {
mkp.groupId sub.group
mkp.artifactId sub.name
mkp.version sub.version
if (sub.name == 'grails-dependencies') {
if (sub.name == 'grace-dependencies') {
mkp.type 'pom'
mkp.scope 'import'
}
Expand All @@ -91,9 +91,9 @@ publishing {

for (plugin in grails.plugins) {
String artifactId = plugin.key
String version = "\${grails-plugin-${plugin.key}.version}"
String version = "\${grace-plugin-${plugin.key}.version}"
mkp.dependency {
mkp.groupId 'org.grails.plugins'
mkp.groupId 'org.graceframework.plugins'
mkp.artifactId artifactId
String versionValue = plugin.value
mkp.version version
Expand All @@ -102,10 +102,10 @@ publishing {

for (profile in grails.profiles) {
mkp.dependency {
mkp.groupId 'org.grails.profiles'
mkp.groupId 'org.graceframework.profiles'
mkp.artifactId profile.key
String version = profile.value
mkp.version("\${grails-profile-${profile.key}.version}")
mkp.version("\${grace-profile-${profile.key}.version}")
}
}
}
Expand Down
Loading

0 comments on commit 417fd46

Please sign in to comment.