Skip to content

Commit 49295cb

Browse files
committed
Add dependency version property to bom. Fixes #10988
1 parent 9dcfd4d commit 49295cb

File tree

2 files changed

+108
-100
lines changed

2 files changed

+108
-100
lines changed

build.gradle

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ext {
2626
// grailsVersion = '3.3.6'
2727
isBuildSnapshot = grailsVersion.endsWith(".BUILD-SNAPSHOT")
2828
isTravisBuild = System.getenv().get("TRAVIS") == 'true'
29-
29+
3030
asyncVersion = '3.3.2'
3131
gspVersion = '3.3.1'
3232
legacyConvertersVersion = "3.3.1"
@@ -38,7 +38,7 @@ ext {
3838
aspectjVersion = "1.8.7" // use same version as org.springframework:spring-aspects uses
3939
commonsCliVersion = "1.2"
4040
commonsIOVersion = "2.2"
41-
commonsLangVersion = "2.6"
41+
commonsLangVersion = "2.6"
4242
gdocEngineVersion = "1.0.1"
4343

4444
groovyVersion = System.getenv('CI_GROOVY_VERSION') ?: "2.4.15"
@@ -61,7 +61,68 @@ ext {
6161
tomcatLog4jVersion = "8.5.2"
6262
servletApiVersion = "3.0.1"
6363

64-
64+
dependencyVersions = [
65+
datastore: [
66+
version: datastoreVersion,
67+
group : 'org.grails',
68+
names : ['grails-datastore'],
69+
modules: ['core', 'simple', 'web', 'rest-client', 'gorm', 'gorm-validation', 'gorm-support', 'gorm-async', 'test-support', 'hibernate-core', 'gorm-test']
70+
],
71+
groovy: [
72+
version: groovyVersion,
73+
group : 'org.codehaus.groovy',
74+
names : ['groovy'],
75+
modules: ['', 'xml', 'swing', 'console', 'json', 'ant', 'sql', 'templates', 'nio']
76+
],
77+
spring: [
78+
version: springVersion,
79+
group : 'org.springframework',
80+
names : ['spring'],
81+
modules: ['aop', 'aspects', 'beans', 'context-support', 'context', 'core', 'expression', 'instrument', 'jdbc', 'jms', 'messaging', 'orm', 'oxm', 'test', 'tx', 'web', 'webmvc', 'websocket']
82+
],
83+
directoryWatcher: [
84+
version: directoryWatcherVersion,
85+
group : 'io.methvin',
86+
names : ['directory-watcher'],
87+
modules: ['']
88+
],
89+
springLoaded: [
90+
version: springLoadedVersion,
91+
group : 'org.springframework',
92+
names : ['springloaded'],
93+
modules: ['']
94+
],
95+
async: [
96+
version: asyncVersion,
97+
group : 'org.grails.plugins',
98+
names : ['async', 'events'],
99+
modules: ['']
100+
],
101+
asyncImpls: [
102+
version: asyncVersion,
103+
group : 'org.grails',
104+
names : ['grails-async', 'grails-events'],
105+
modules: ['gpars', 'rxjava', 'rxjava2']
106+
],
107+
spock: [
108+
version: spockVersion,
109+
group : 'org.spockframework',
110+
names : ['spock-core', 'spock-spring'],
111+
modules: ['']
112+
],
113+
gsp: [
114+
version: gspVersion,
115+
group : 'org.grails.plugins',
116+
names : ['gsp'],
117+
modules: ['']
118+
],
119+
testingSupport: [
120+
version: testingSupportVersion,
121+
group : 'org.grails',
122+
names : ['grails-testing-support', 'grails-gorm-testing-support', 'grails-web-testing-support'],
123+
modules: ['']
124+
],
125+
]
65126

66127
isJava8Compatible = org.gradle.api.JavaVersion.current().isJava8Compatible()
67128

@@ -297,7 +358,7 @@ subprojects { project ->
297358
module.iml.whenMerged { module ->
298359
// adding slf4j-simple with scope TEST to .iml
299360
module.dependencies << new org.gradle.plugins.ide.idea.model.ModuleLibrary(
300-
[new org.gradle.plugins.ide.idea.model.Path("jar://\$GRADLE_USER_HOME/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-${slf4jVersion}.jar!/")], [], [], [], "TEST"
361+
[new org.gradle.plugins.ide.idea.model.Path("jar://\$GRADLE_USER_HOME/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-${slf4jVersion}.jar!/")], [], [], [], "TEST"
301362
)
302363
}
303364
}

grails-bom/build.gradle

Lines changed: 43 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,38 @@ publishing {
9595
}
9696
}
9797

98+
mkp.properties {
99+
for (dep in plugins) {
100+
String version = dep.value
101+
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
102+
throw new RuntimeException("Cannot have a snapshot dependency on a plugin [$dep.key] for a release!")
103+
}
104+
mkp."${dep.key}.version"(version)
105+
}
106+
107+
for (dep in dependencyVersions) {
108+
String version = dep.value.version
109+
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
110+
throw new RuntimeException("Cannot have a snapshot dependency on [$dep.key] for a release!")
111+
}
112+
mkp."${dep.key}.version"(version)
113+
}
114+
}
115+
98116
mkp.dependencyManagement {
99117
mkp.dependencies {
100-
for(sub in project.parent.subprojects) {
101-
if(sub.name == 'grails-bom') continue
118+
for (sub in project.parent.subprojects) {
119+
if (sub.name == 'grails-bom') continue
102120

103121
mkp.dependency {
104122
mkp.groupId sub.group
105123
mkp.artifactId sub.name
106-
mkp.version( sub.version )
107-
if(sub.name == 'grails-dependencies') {
124+
mkp.version sub.version
125+
if (sub.name == 'grails-dependencies') {
108126
mkp.type 'pom'
109127
}
110128

111-
if(sub.name == 'grails-bootstrap') {
129+
if (sub.name == 'grails-bootstrap') {
112130
mkp.exclusions {
113131
mkp.exclusion {
114132
mkp.groupId 'jline'
@@ -128,123 +146,52 @@ publishing {
128146
}
129147
}
130148
}
131-
132-
}
133-
}
134-
135-
['core', 'simple','web','rest-client','gorm', 'gorm-validation', 'gorm-support', 'gorm-async', 'test-support', 'hibernate-core','gorm-test'].each { name ->
136-
mkp.dependency {
137-
mkp.groupId 'org.grails'
138-
mkp.artifactId "grails-datastore-$name"
139-
mkp.version( datastoreVersion )
140-
}
141-
142-
}
143-
144-
['', 'xml', 'swing', 'console', 'json', 'ant', 'sql', 'templates', 'xml','nio'].each { name ->
145-
mkp.dependency {
146-
mkp.groupId 'org.codehaus.groovy'
147-
mkp.artifactId name ? "groovy-$name" : "groovy"
148-
mkp.version( groovyVersion )
149149
}
150150
}
151151

152-
['aop', 'aspects', 'beans', 'context-support', 'context', 'core', 'expression', 'instrument', 'jdbc','jms', 'messaging', 'orm', 'oxm', 'test', 'tx', 'web', 'webmvc', 'websocket'].each { name ->
153-
mkp.dependency {
154-
mkp.groupId 'org.springframework'
155-
mkp.artifactId "spring-$name"
156-
mkp.version( springVersion )
152+
for (dep in dependencyVersions) {
153+
def info = dep.value
154+
def depList = GroovyCollections
155+
.combinations(info.names, info.modules)
156+
.collect { it.join('-') }
157+
.collect { it.endsWith('-') ? it[0..-2] : it }
158+
159+
for (dependency in depList) {
160+
mkp.dependency {
161+
mkp.groupId info.group
162+
mkp.artifactId dependency
163+
mkp.version "\${${dep.key}.version}"
164+
}
157165
}
158166
}
159167

160-
mkp.dependency {
161-
mkp.groupId 'io.methvin'
162-
mkp.artifactId "directory-watcher"
163-
mkp.version(directoryWatcherVersion) //0.3.0
164-
}
165-
166-
mkp.dependency {
167-
mkp.groupId 'org.springframework'
168-
mkp.artifactId "springloaded"
169-
mkp.version( springLoadedVersion )
170-
}
171-
172-
for(plugin in plugins) {
168+
for (plugin in plugins) {
173169
mkp.dependency {
174170
mkp.groupId 'org.grails.plugins'
175171
mkp.artifactId plugin.key
176-
def version = plugin.value
177-
if(!isBuildSnapshot && version.toString().endsWith("-SNAPSHOT")) {
172+
String version = plugin.value
173+
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
178174
throw new RuntimeException("Cannot have a snapshot dependency on a plugin [$plugin.key] for a release!")
179175
}
180-
mkp.version(version)
176+
mkp.version "\${${plugin.key}.version}"
181177
}
182178
}
183179

184-
['async', 'events'].each { name ->
185-
mkp.dependency {
186-
mkp.groupId 'org.grails.plugins'
187-
mkp.artifactId name
188-
mkp.version( asyncVersion )
189-
}
190-
}
191-
192-
['gpars', 'rxjava', 'rxjava2'].each { name ->
193-
mkp.dependency {
194-
mkp.groupId 'org.grails'
195-
mkp.artifactId "grails-async-$name"
196-
mkp.version( asyncVersion )
197-
}
198-
mkp.dependency {
199-
mkp.groupId 'org.grails'
200-
mkp.artifactId "grails-events-$name"
201-
mkp.version( asyncVersion )
202-
}
203-
}
204-
205-
mkp.dependency {
206-
mkp.groupId 'org.spockframework'
207-
mkp.artifactId "spock-core"
208-
mkp.version( spockVersion )
209-
}
210-
211-
mkp.dependency {
212-
mkp.groupId 'org.spockframework'
213-
mkp.artifactId "spock-spring"
214-
mkp.version( spockVersion )
215-
}
216-
217-
mkp.dependency {
218-
mkp.groupId 'org.grails.plugins'
219-
mkp.artifactId "gsp"
220-
mkp.version( gspVersion )
221-
}
222-
223-
224-
for(profile in profiles) {
180+
for (profile in profiles) {
225181
mkp.dependency {
226182
mkp.groupId 'org.grails.profiles'
227183
mkp.artifactId profile.key
228-
def version = profile.value
229-
if(!isBuildSnapshot && version.toString().endsWith("-SNAPSHOT")) {
184+
String version = profile.value
185+
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
230186
throw new RuntimeException("Cannot have a snapshot dependency on a profile [$profile.key] for a release!")
231187
}
232188
mkp.version(version)
233189
}
234190
}
235-
236-
['gorm-', 'web-', ''].each { name ->
237-
mkp.dependency {
238-
mkp.groupId 'org.grails'
239-
mkp.artifactId "grails-${name}testing-support"
240-
mkp.version( testingSupportVersion )
241-
}
242-
}
243191
}
244192
}
245193
}
246194
}
247-
248195
}
249196
}
250197
}

0 commit comments

Comments
 (0)