Skip to content

Commit 1b15f3c

Browse files
committed
Restructure Gradle builds
- Use Gradle version catalog to simplify dependency management - Sharing Build Logic using buildSrc - Update Checkstyle and CodeNarc plugin Closes gh-76
1 parent 79d1bf7 commit 1b15f3c

File tree

18 files changed

+305
-256
lines changed

18 files changed

+305
-256
lines changed

build.gradle

Lines changed: 58 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
1-
buildscript {
2-
repositories {
3-
mavenCentral()
4-
gradlePluginPortal()
5-
if (project.projectVersion.endsWith('-SNAPSHOT')) {
6-
maven {
7-
name = 'Maven Central Portal Snapshots'
8-
url = 'https://central.sonatype.com/repository/maven-snapshots/'
9-
10-
content {
11-
includeGroupAndSubgroups 'org.graceframework'
12-
}
13-
mavenContent {
14-
snapshotsOnly()
15-
}
16-
}
17-
}
18-
}
19-
dependencies {
20-
classpath "io.github.gradle-nexus:publish-plugin:2.0.0"
21-
classpath "org.graceframework:grace-gradle-plugin:$graceVersion"
22-
classpath "io.spring.gradle:dependency-management-plugin:$dependencyManagementPluginVersion"
23-
}
1+
plugins {
2+
id 'java-library'
3+
id 'groovy'
4+
id 'maven-publish'
5+
id 'signing'
6+
id 'eclipse'
7+
id 'idea'
8+
alias libs.plugins.grace.doc
9+
alias libs.plugins.gradle.nexus.publish
2410
}
2511

2612
ext."signing.keyId" = project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : System.getenv('SIGNING_KEY')
@@ -31,180 +17,8 @@ ext.isReleaseVersion = !projectVersion.endsWith("SNAPSHOT")
3117
version = project.projectVersion
3218
group = "org.graceframework"
3319

34-
apply plugin: "groovy"
35-
apply plugin: "java-library"
36-
apply plugin: "io.github.gradle-nexus.publish-plugin"
37-
apply plugin: "maven-publish"
38-
apply plugin: "signing"
39-
apply plugin: "idea"
40-
apply plugin: 'org.graceframework.grace-doc'
41-
42-
allprojects {
43-
repositories {
44-
mavenCentral()
45-
if (project.projectVersion.endsWith('-SNAPSHOT')) {
46-
maven {
47-
name = 'Maven Central Portal Snapshots'
48-
url = 'https://central.sonatype.com/repository/maven-snapshots/'
49-
50-
content {
51-
includeGroupAndSubgroups 'org.graceframework'
52-
}
53-
mavenContent {
54-
snapshotsOnly()
55-
}
56-
}
57-
}
58-
}
59-
60-
configurations {
61-
documentation
62-
}
63-
}
64-
65-
subprojects {
66-
version = project.projectVersion
67-
group = "org.graceframework"
68-
69-
apply plugin: "groovy"
70-
apply plugin: "eclipse"
71-
apply plugin: "idea"
72-
apply plugin: "java-library"
73-
apply plugin: "maven-publish"
74-
apply plugin: "signing"
75-
apply plugin: "checkstyle"
76-
apply plugin: "codenarc"
77-
apply plugin: "io.spring.dependency-management"
78-
79-
dependencyManagement {
80-
imports {
81-
mavenBom "org.graceframework:grace-bom:$graceVersion"
82-
}
83-
applyMavenExclusions false
84-
generatedPomCustomization {
85-
enabled = false
86-
}
87-
}
88-
89-
dependencies {
90-
api "org.apache.groovy:groovy"
91-
testImplementation "org.apache.groovy:groovy-test-junit5"
92-
testImplementation "org.junit.jupiter:junit-jupiter-api"
93-
testImplementation "org.junit.jupiter:junit-jupiter-engine"
94-
testImplementation "org.junit.platform:junit-platform-runner"
95-
testImplementation("org.spockframework:spock-core") { transitive = false }
96-
97-
if (project.name == "grace-datastore-gorm-tck") {
98-
api "org.apache.groovy:groovy-test-junit5"
99-
api "org.junit.jupiter:junit-jupiter-api"
100-
api "org.junit.platform:junit-platform-runner"
101-
runtimeOnly "org.junit.jupiter:junit-jupiter-engine"
102-
implementation("org.spockframework:spock-core") { transitive = false }
103-
}
104-
}
105-
106-
if (project.name == "grace-datastore-gorm-async") {
107-
dependencies {
108-
testImplementation project(":grace-datastore-gorm-tck")
109-
}
110-
}
111-
112-
compileTestGroovy {
113-
configure(groovyOptions.forkOptions) {
114-
jvmArgs = [ '-Xmx768m']
115-
}
116-
}
117-
118-
java {
119-
toolchain {
120-
languageVersion = JavaLanguageVersion.of(17)
121-
}
122-
withJavadocJar()
123-
withSourcesJar()
124-
}
125-
126-
javadoc {
127-
failOnError = false
128-
}
129-
130-
test {
131-
useJUnitPlatform()
132-
}
133-
134-
checkstyle {
135-
toolVersion = "10.3.2"
136-
configDirectory.set(rootProject.file("$rootDir/gradle/checkstyle"))
137-
}
138-
139-
codenarc {
140-
toolVersion = '3.1.0'
141-
setConfigFile(new File("$rootDir/gradle/codenarc/codenarc.groovy"))
142-
}
143-
144-
configure([javadoc]) {
145-
options.encoding "UTF-8"
146-
options.docEncoding "UTF-8"
147-
options.charSet "UTF-8"
148-
options.jFlags "-Xms64M", "-Xmx512M"
149-
}
150-
151-
publishing {
152-
publications {
153-
maven(MavenPublication) {
154-
def projectName = project.name.split('-')*.capitalize().join(' ')
155-
groupId = project.group
156-
version = project.version
157-
158-
versionMapping {
159-
usage('java-api') {
160-
fromResolutionOf('runtimeClasspath')
161-
}
162-
usage('java-runtime') {
163-
fromResolutionResult()
164-
}
165-
}
166-
167-
from components.java
168-
169-
pom {
170-
name = projectName
171-
description = "Grace Data : $projectName"
172-
url = 'https://github.com/graceframework/grace-data'
173-
licenses {
174-
license {
175-
name = 'The Apache License, Version 2.0'
176-
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
177-
}
178-
}
179-
developers {
180-
developer {
181-
id = 'rainboyan'
182-
name = 'Michael Yan'
183-
184-
}
185-
}
186-
scm {
187-
connection = 'scm:git:git://github.com/graceframework/grace-data.git'
188-
developerConnection = 'scm:git:ssh://github.com:graceframework/grace-data.git'
189-
url = 'https://github.com/graceframework/grace-data/'
190-
}
191-
}
192-
}
193-
}
194-
}
195-
196-
afterEvaluate {
197-
signing {
198-
required = isReleaseVersion && gradle.taskGraph.hasTask("publish")
199-
sign publishing.publications.maven
200-
}
201-
}
202-
}
203-
204-
dependencies {
205-
documentation "com.github.javaparser:javaparser-core:$javaParserCoreVersion"
206-
documentation "org.apache.groovy:groovy:$groovyVersion"
207-
documentation "org.apache.groovy:groovy-ant:$groovyVersion"
20+
configurations {
21+
documentation
20822
}
20923

21024
def cleanTask = project.tasks.findByName('clean')
@@ -246,16 +60,58 @@ docs {
24660
sourceDir = project.file('src/docs')
24761
}
24862

249-
project.afterEvaluate {
250-
allprojects.repositories.each { handler ->
251-
handler.each {
252-
if (it.url.toString().startsWith("http://")) {
253-
throw new RuntimeException("Build should not define insecure HTTP-based Maven repostories")
63+
publishing {
64+
publications {
65+
maven(MavenPublication) {
66+
def projectName = project.name.split('-')*.capitalize().join(' ')
67+
groupId = project.group
68+
version = project.version
69+
70+
versionMapping {
71+
usage('java-api') {
72+
fromResolutionOf('runtimeClasspath')
73+
}
74+
usage('java-runtime') {
75+
fromResolutionResult()
76+
}
77+
}
78+
79+
from components.java
80+
81+
pom {
82+
name = projectName
83+
description = "Grace Data : $projectName"
84+
url = 'https://github.com/graceframework/grace-data'
85+
licenses {
86+
license {
87+
name = 'The Apache License, Version 2.0'
88+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
89+
}
90+
}
91+
developers {
92+
developer {
93+
id = 'rainboyan'
94+
name = 'Michael Yan'
95+
96+
}
97+
}
98+
scm {
99+
connection = 'scm:git:git://github.com/graceframework/grace-data.git'
100+
developerConnection = 'scm:git:ssh://github.com:graceframework/grace-data.git'
101+
url = 'https://github.com/graceframework/grace-data/'
102+
}
254103
}
255104
}
256105
}
257106
}
258107

108+
afterEvaluate {
109+
signing {
110+
required = isReleaseVersion && gradle.taskGraph.hasTask("publish")
111+
sign publishing.publications.maven
112+
}
113+
}
114+
259115
nexusPublishing {
260116
repositories {
261117
sonatype {

buildSrc/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
id 'groovy-gradle-plugin'
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
plugins {
2+
id 'java-library'
3+
id 'groovy'
4+
id 'maven-publish'
5+
id 'signing'
6+
id 'checkstyle'
7+
id 'codenarc'
8+
}
9+
10+
version = project.projectVersion
11+
group = "org.graceframework"
12+
13+
repositories {
14+
mavenCentral()
15+
gradlePluginPortal()
16+
if (project.projectVersion.endsWith('-SNAPSHOT')) {
17+
maven {
18+
name = 'Maven Central Portal Snapshots'
19+
url = 'https://central.sonatype.com/repository/maven-snapshots/'
20+
21+
content {
22+
includeGroupAndSubgroups 'org.graceframework'
23+
}
24+
mavenContent {
25+
snapshotsOnly()
26+
}
27+
}
28+
}
29+
}
30+
31+
configurations {
32+
documentation
33+
}
34+
35+
36+
dependencies {
37+
api libs.groovy.core
38+
39+
testImplementation libs.groovy.test.junit5
40+
testImplementation libs.junit.jupiter.api
41+
testImplementation libs.junit.jupiter.engine
42+
testImplementation libs.junit.platform.runner
43+
testImplementation libs.spock.core
44+
45+
documentation libs.javaparser
46+
documentation libs.groovy.ant
47+
documentation libs.groovy.core
48+
}
49+
50+
compileTestGroovy {
51+
configure(groovyOptions.forkOptions) {
52+
jvmArgs = [ '-Xmx768m']
53+
}
54+
}
55+
56+
java {
57+
toolchain {
58+
languageVersion = JavaLanguageVersion.of(17)
59+
}
60+
withJavadocJar()
61+
withSourcesJar()
62+
}
63+
64+
javadoc {
65+
failOnError = false
66+
}
67+
68+
test {
69+
useJUnitPlatform()
70+
}
71+
72+
configure([javadoc]) {
73+
options.encoding "UTF-8"
74+
options.docEncoding "UTF-8"
75+
options.charSet "UTF-8"
76+
options.jFlags "-Xms64M", "-Xmx512M"
77+
}
78+
79+
checkstyle {
80+
toolVersion = "10.26.1"
81+
configDirectory.set(rootProject.file("config/checkstyle"))
82+
}
83+
84+
codenarc {
85+
toolVersion = '3.6.0'
86+
config = resources.text.fromFile(rootProject.file("config/codenarc/codenarc.groovy"))
87+
}
File renamed without changes.

grace-datastore-async/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
plugins {
2+
id 'grace.build.common'
3+
}
4+
15
dependencies {
2-
api "org.graceframework.async:grace-async-core:7.0.0-SNAPSHOT"
6+
api libs.grace.async.core
37
}

0 commit comments

Comments
 (0)