Skip to content

Commit b536938

Browse files
committed
Streamline Gradle build scripts: using the Spring Dependency Management Plugin to manage dependencies and versions
Closes gh-21
1 parent 1c31ef6 commit b536938

File tree

10 files changed

+96
-114
lines changed

10 files changed

+96
-114
lines changed

build.gradle

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
buildscript {
22
repositories {
3+
// mavenLocal()
34
mavenCentral()
45
gradlePluginPortal()
56
}
67
dependencies {
78
classpath "org.graceframework:grace-gradle-plugin:$graceVersion"
9+
// classpath "org.graceframework.plugins:asset-pipeline-gradle:$assetPipelineVersion"
810
classpath 'org.asciidoctor:asciidoctor-gradle-jvm:4.0.3'
911
classpath "com.github.erdi:webdriver-binaries-gradle-plugin:$webdriverBinariesVersion"
1012
classpath "org.graceframework.plugins:views-gradle:6.3.0-M1"
@@ -18,7 +20,6 @@ group = "org.graceframework"
1820
version = project.projectVersion
1921

2022
ext {
21-
hibernatePluginVersion = project.hibernatePluginVersion
2223
isCiBuild = project.hasProperty("isCiBuild") || System.getenv().get("CI") as Boolean
2324
isBuildSnapshot = project.version.endsWith("-SNAPSHOT")
2425
isReleaseVersion = !isBuildSnapshot
@@ -30,7 +31,6 @@ ext {
3031
ext."signing.keyId" = System.getenv("SIGNING_KEY") ?: project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : null
3132
ext."signing.password" = System.getenv("SIGNING_PASSPHRASE") ?: project.hasProperty("signing.password") ? project.getProperty('signing.password') : null
3233
ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : null
33-
ext['junit-jupiter.version'] = junitJupiterVersion
3434

3535
apply plugin: 'maven-publish'
3636
apply plugin: "io.github.gradle-nexus.publish-plugin"
@@ -67,21 +67,17 @@ subprojects { project ->
6767
}
6868
}
6969

70-
ext['h2.version'] = h2Version
71-
ext['gorm.version'] = datastoreVersion
72-
ext['gorm.hibernate5.version'] = hibernatePluginVersion
73-
ext['junit-jupiter.version'] = junitJupiterVersion
74-
ext['spock.version'] = spockVersion
75-
ext['mongodb.version'] = mongodbDriverVersion
76-
7770
if (project.name.startsWith("examples")) {
71+
group = "examples"
7872

7973
apply plugin: 'groovy'
8074

81-
if(project.name.contains('grace')) {
82-
75+
if (project.name.contains('grace')) {
8376
apply plugin:"org.graceframework.grace-web"
8477
apply plugin:"org.graceframework.grace-gsp"
78+
// Execution failed for task ':examples-grace-hibernate5-mongodb:assetCompile'.
79+
// > java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: 'void groovy.lang.IntRange.<init>(boolean, boolean, int, int)'
80+
// apply plugin: "org.graceframework.asset-pipeline"
8581
}
8682

8783
boolean usesGeb = project.name.contains('grace-hibernate5-mongodb') || project.name.contains('grace-mongodb') || project.name.contains('grace-mongodb-database-per-tenant')|| project.name.contains('grace-rxmongodb')
@@ -90,18 +86,33 @@ subprojects { project ->
9086
apply plugin:"com.github.erdi.webdriver-binaries"
9187
}
9288

93-
if (project.name == "examples-test-data-service") {
89+
if (project.name == "examples-grace-test-data-service") {
9490
apply plugin:"org.graceframework.grace-web"
9591
apply plugin:"org.graceframework.plugins.views-json"
9692
}
9793

94+
if (project.name == "examples-springboot-mongodb") {
95+
apply plugin: 'org.springframework.boot'
96+
apply plugin: 'io.spring.dependency-management'
97+
98+
dependencyManagement {
99+
imports {
100+
mavenBom "org.graceframework:grace-bom:$graceVersion"
101+
}
102+
applyMavenExclusions false
103+
generatedPomCustomization {
104+
enabled = false
105+
}
106+
}
107+
}
108+
98109
dependencies {
99-
testImplementation "org.hibernate:hibernate-validator:$hibernateValidatorVersion"
100-
testImplementation "org.apache.groovy:groovy-test-junit5:$groovyVersion"
101-
testImplementation "org.spockframework:spock-core:$spockVersion", { transitive = false }
102-
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
103-
testImplementation "org.junit.platform:junit-platform-runner:1.10.2"
104-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
110+
testImplementation "org.hibernate.validator:hibernate-validator"
111+
testImplementation "org.apache.groovy:groovy-test-junit5"
112+
testImplementation "org.spockframework:spock-core", { transitive = false }
113+
testImplementation "org.junit.jupiter:junit-jupiter-api"
114+
testImplementation "org.junit.platform:junit-platform-runner"
115+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
105116
}
106117

107118
tasks.withType(Test) {
@@ -120,11 +131,6 @@ subprojects { project ->
120131
}
121132

122133
boolean isPluginProject = project.name.startsWith("grace") && project.name.endsWith("-plugin")
123-
boolean isGracePluginProject = project.name.endsWith("-plugin")
124-
125-
ext {
126-
projectInfo = new PublishingConvention(project)
127-
}
128134

129135
apply plugin: 'groovy'
130136

@@ -133,11 +139,22 @@ subprojects { project ->
133139
version = rootProject.version
134140

135141
apply plugin: "org.graceframework.grace-plugin"
136-
} else {
142+
}
143+
else {
137144
group = "org.graceframework"
138145
version = rootProject.version
139146

140-
apply plugin: "groovy"
147+
apply plugin: "io.spring.dependency-management"
148+
149+
dependencyManagement {
150+
imports {
151+
mavenBom "org.graceframework:grace-bom:$graceVersion"
152+
}
153+
applyMavenExclusions false
154+
generatedPomCustomization {
155+
enabled = false
156+
}
157+
}
141158
}
142159

143160
if (project.name == 'docs') {
@@ -156,43 +173,50 @@ subprojects { project ->
156173
withSourcesJar()
157174
}
158175

159-
configurations {
160-
all {
161-
resolutionStrategy {
162-
force "org.apache.groovy:groovy:$groovyVersion"
163-
force "org.apache.groovy:groovy-dateutil:$groovyVersion"
164-
force "org.apache.groovy:groovy-xml:$groovyVersion"
165-
force "org.apache.groovy:groovy-templates:$groovyVersion"
166-
}
167-
}
168-
}
169-
170176
dependencies {
171-
api "org.apache.groovy:groovy:$groovyVersion"
172-
api "org.apache.groovy:groovy-templates:$groovyVersion"
177+
api "org.apache.groovy:groovy"
178+
api "org.apache.groovy:groovy-templates"
173179

174-
testImplementation "org.apache.groovy:groovy-json:$groovyVersion"
175-
testImplementation "org.apache.groovy:groovy-templates:$groovyVersion"
176-
testImplementation "org.apache.groovy:groovy-test-junit5:$groovyVersion", {
180+
testImplementation "org.apache.groovy:groovy-json"
181+
testImplementation "org.apache.groovy:groovy-templates"
182+
testImplementation "org.apache.groovy:groovy-test-junit5", {
177183
exclude group: "org.junit.platform", module: "junit-platform-launcher"
178184
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
179185
}
180-
testImplementation "org.spockframework:spock-core:$spockVersion", {
186+
testImplementation "org.spockframework:spock-core", {
181187
exclude group: "org.junit.platform", module: "junit-platform-engine"
182188
}
183-
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
184-
testImplementation "org.junit.platform:junit-platform-runner:$junitPlatformVersion"
185-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
189+
testImplementation "org.junit.jupiter:junit-jupiter-api"
190+
testImplementation "org.junit.platform:junit-platform-runner"
191+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
186192
}
187193

188194
publishing {
189195
publications {
190196
maven(MavenPublication) {
197+
def projectArtifactId = project.name
198+
def projectName = project.name.split('-')*.capitalize().join(' ')
199+
if (project.name == 'grace-plugin') {
200+
projectArtifactId = 'mongodb'
201+
projectName = 'Grace MongoDb Plugin'
202+
}
203+
204+
artifactId projectArtifactId
205+
from components.java
206+
207+
versionMapping {
208+
usage('java-api') {
209+
fromResolutionOf('runtimeClasspath')
210+
}
211+
usage('java-runtime') {
212+
fromResolutionResult()
213+
}
214+
}
191215

192216
pom {
193-
name = projectInfo.projectName
194-
description = projectInfo.projectDescription
195-
url = projectInfo.projectURL
217+
name = projectName
218+
description = "Grace Data : $projectName"
219+
url = 'https://github.com/graceframework/grace-data-mongodb'
196220

197221
licenses {
198222
license {
@@ -203,7 +227,7 @@ subprojects { project ->
203227
}
204228

205229
scm {
206-
url = 'scm:git@github.com:graceframework/grace-data-mongodb.git'
230+
url = 'https://github.com/graceframework/grace-data-mongodb'
207231
connection = 'scm:[email protected]:graceframework/grace-data-mongodb.git'
208232
developerConnection = 'scm:[email protected]:graceframework/grace-data-mongodb.git'
209233
}
@@ -217,11 +241,8 @@ subprojects { project ->
217241
}
218242
}
219243

220-
artifactId projectInfo.projectArtifactId
221-
from components.java
222-
223244
afterEvaluate {
224-
if (isGracePluginProject) {
245+
if (isPluginProject) {
225246
artifact source:"${sourceSets.main.groovy.classesDirectory.get()}/META-INF/grails-plugin.xml",
226247
classifier:"plugin",
227248
extension:'xml'
@@ -248,24 +269,3 @@ subprojects { project ->
248269
shouldRunAfter(tasks.withType(Sign))
249270
}
250271
}
251-
252-
class PublishingConvention {
253-
Project project
254-
255-
String projectArtifactId
256-
String projectName = 'Grace Data MongoDB'
257-
String projectDescription = 'Provides a GORM Object Mapping implementations for the MongodB Document Database'
258-
String projectURL = 'https://github.com/graceframework/grace-data-mongodb'
259-
String projectIssueTrackerUrl = 'https://github.com/graceframework/grace-data-mongodb/issues'
260-
String projectVcsUrl = 'https://github.com/graceframework/grace-data-mongodb'
261-
262-
PublishingConvention(Project project) {
263-
this.project = project
264-
265-
def name = project.name
266-
if (name.startsWith('grace') && name.endsWith('-plugin')) {
267-
name = 'mongodb'
268-
}
269-
projectArtifactId = name
270-
}
271-
}

examples/grace-hibernate5-mongodb/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
group = "examples"
2-
31
dependencies {
42
implementation "org.springframework.boot:spring-boot-starter-logging"
53
implementation "org.springframework.boot:spring-boot-autoconfigure"

examples/grace-mongodb-database-per-tenant/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
group = "examples"
2-
31
dependencies {
42
implementation "org.springframework.boot:spring-boot-starter-logging"
53
implementation "org.springframework.boot:spring-boot-autoconfigure"

examples/grace-mongodb/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
group = "examples"
2-
31
dependencies {
42
implementation "org.springframework.boot:spring-boot-starter-logging"
53
implementation "org.springframework.boot:spring-boot-autoconfigure"
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
apply plugin: 'org.springframework.boot'
2-
apply plugin: 'io.spring.dependency-management'
3-
4-
group = 'example'
5-
61
dependencies {
72
implementation "org.springframework.boot:spring-boot-starter-web"
83
implementation project(":grace-plugin")
94

105
testImplementation"org.springframework.boot:spring-boot-starter-test"
11-
testImplementation"org.spockframework:spock-core:$spockVersion"
6+
testImplementation"org.spockframework:spock-core"
127
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dependencies {
2-
api "org.graceframework:grace-datastore-gorm:$datastoreVersion"
2+
api "org.graceframework:grace-datastore-gorm"
33
api "org.mongodb:bson:$mongodbDriverVersion"
44
}

grace-datastore-gorm-mongodb/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
22

33
dependencies {
44
api "org.mongodb:mongodb-driver-sync:$mongodbDriverVersion"
5-
api "org.graceframework:grace-datastore-gorm-validation:$datastoreVersion"
6-
api "org.graceframework:grace-datastore-gorm:$datastoreVersion"
5+
api "org.graceframework:grace-datastore-gorm-validation"
6+
api "org.graceframework:grace-datastore-gorm"
77
api project(":grace-datastore-gorm-bson")
88

9-
implementation "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"
9+
implementation "com.github.ben-manes.caffeine:caffeine"
1010

11-
compileOnly "org.graceframework:grace-datastore-gorm-support:$datastoreVersion"
12-
compileOnly "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
11+
compileOnly "org.graceframework:grace-datastore-gorm-support"
12+
compileOnly "jakarta.servlet:jakarta.servlet-api"
1313

1414
testImplementation "org.testcontainers:mongodb:1.19.8"
1515
testImplementation "org.graceframework:grace-datastore-gorm-tck:$datastoreVersion"
16-
testImplementation "org.graceframework:grace-test-support:$graceVersion"
17-
testImplementation "jakarta.validation:jakarta.validation-api:$jakartaValidationVersion"
18-
testImplementation "org.hibernate.validator:hibernate-validator:$hibernateValidatorVersion"
19-
testImplementation "org.graceframework:grace-datastore-gorm-support:$datastoreVersion", {
16+
testImplementation "org.graceframework:grace-test-support:"
17+
testImplementation "jakarta.validation:jakarta.validation-api"
18+
testImplementation "org.hibernate.validator:hibernate-validator"
19+
testImplementation "org.graceframework:grace-datastore-gorm-support", {
2020
exclude group: "org.graceframework", module:"grace-datastore-gorm-hibernate-core"
2121
}
2222
testRuntimeOnly "org.glassfish:jakarta.el:$jakartaElVersion"
23-
testRuntimeOnly "org.springframework:spring-aop:$springVersion"
23+
testRuntimeOnly "org.springframework:spring-aop"
2424
}
2525

2626

grace-plugin/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ dependencies {
22
compileOnly "org.graceframework:grace-core"
33
compileOnly "org.graceframework:grace-bootstrap"
44
compileOnly "org.graceframework:grace-boot"
5-
compileOnly "org.spockframework:spock-core:$spockVersion", {
5+
compileOnly "org.spockframework:spock-core", {
66
exclude group: "junit", module: "junit-dep"
77
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
88
exclude group: 'org.hamcrest', module: 'hamcrest-core'
99
}
1010

11-
api("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")
12-
annotationProcessor("org.springframework.boot:spring-boot-autoconfigure-processor:$springBootVersion")
13-
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion")
14-
api "org.graceframework:grace-datastore-gorm-support:$datastoreVersion"
15-
api "org.graceframework:grace-datastore-web:$datastoreVersion"
1611
api project(":grace-datastore-gorm-mongodb-ext")
1712
api project(":grace-datastore-gorm-mongodb")
13+
api "org.graceframework:grace-datastore-gorm-support"
14+
api "org.graceframework:grace-datastore-web"
15+
16+
api("org.springframework.boot:spring-boot-autoconfigure")
17+
annotationProcessor("org.springframework.boot:spring-boot-autoconfigure-processor")
18+
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
1819
}

gradle.properties

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
projectVersion=2023.3.0-SNAPSHOT
22
assetPipelineVersion=6.3.0-M1
3-
caffeineVersion=3.1.8
43
datastoreVersion=2023.3.0-M1
54
graceVersion=2023.3.0-M2
65
groovyVersion=4.0.26
76
jakartaElVersion=4.0.2
8-
jakartaValidationVersion=3.0.2
9-
h2Version=2.2.224
10-
hibernateCoreVersion=5.6.15.Final
11-
hibernatePluginVersion=2023.2.0
12-
hibernateValidatorVersion=8.0.2.Final
137
jansiVersion=2.4.1
148
javaParserCoreVersion=3.26.4
15-
junitJupiterVersion=5.10.5
16-
junitPlatformVersion=1.10.5
179
mongodbDriverVersion=5.0.1
1810
seleniumVersion=4.2.2
19-
spockVersion=2.3-groovy-4.0
20-
springBootVersion=3.3.10
21-
springVersion=6.1.18
2211
webdriverBinariesVersion=3.2
12+
2313
org.gradle.caching=true
2414
org.gradle.daemon=true
2515
org.gradle.parallel=false

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
rootProject.name = 'Grace.Data.MongoDB'
2+
13
// core
24
include "grace-datastore-gorm-bson"
35
include "grace-datastore-gorm-mongodb"

0 commit comments

Comments
 (0)