Skip to content

Commit 579cc67

Browse files
authored
Merge pull request #11035 from grails/issue-10988
Add dependency version property to bom. Fixes #10988
2 parents d5c3acf + 49295cb commit 579cc67

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

@@ -376,7 +437,7 @@ subprojects { project ->
376437
module.iml.whenMerged { module ->
377438
// adding slf4j-simple with scope TEST to .iml
378439
module.dependencies << new org.gradle.plugins.ide.idea.model.ModuleLibrary(
379-
[new org.gradle.plugins.ide.idea.model.Path("jar://\$GRADLE_USER_HOME/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-${slf4jVersion}.jar!/")], [], [], [], "TEST"
440+
[new org.gradle.plugins.ide.idea.model.Path("jar://\$GRADLE_USER_HOME/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-${slf4jVersion}.jar!/")], [], [], [], "TEST"
380441
)
381442
}
382443
}

grails-bom/build.gradle

Lines changed: 43 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,38 @@ publishing {
1818
xml.children().last() + {
1919
def mkp = delegate
2020

21+
mkp.properties {
22+
for (dep in plugins) {
23+
String version = dep.value
24+
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
25+
throw new RuntimeException("Cannot have a snapshot dependency on a plugin [$dep.key] for a release!")
26+
}
27+
mkp."${dep.key}.version"(version)
28+
}
29+
30+
for (dep in dependencyVersions) {
31+
String version = dep.value.version
32+
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
33+
throw new RuntimeException("Cannot have a snapshot dependency on [$dep.key] for a release!")
34+
}
35+
mkp."${dep.key}.version"(version)
36+
}
37+
}
38+
2139
mkp.dependencyManagement {
2240
mkp.dependencies {
23-
for(sub in project.parent.subprojects) {
24-
if(sub.name == 'grails-bom') continue
41+
for (sub in project.parent.subprojects) {
42+
if (sub.name == 'grails-bom') continue
2543

2644
mkp.dependency {
2745
mkp.groupId sub.group
2846
mkp.artifactId sub.name
29-
mkp.version( sub.version )
30-
if(sub.name == 'grails-dependencies') {
47+
mkp.version sub.version
48+
if (sub.name == 'grails-dependencies') {
3149
mkp.type 'pom'
3250
}
3351

34-
if(sub.name == 'grails-bootstrap') {
52+
if (sub.name == 'grails-bootstrap') {
3553
mkp.exclusions {
3654
mkp.exclusion {
3755
mkp.groupId 'jline'
@@ -51,123 +69,52 @@ publishing {
5169
}
5270
}
5371
}
54-
55-
}
56-
}
57-
58-
['core', 'simple','web','rest-client','gorm', 'gorm-validation', 'gorm-support', 'gorm-async', 'test-support', 'hibernate-core','gorm-test'].each { name ->
59-
mkp.dependency {
60-
mkp.groupId 'org.grails'
61-
mkp.artifactId "grails-datastore-$name"
62-
mkp.version( datastoreVersion )
63-
}
64-
65-
}
66-
67-
['', 'xml', 'swing', 'console', 'json', 'ant', 'sql', 'templates', 'xml','nio'].each { name ->
68-
mkp.dependency {
69-
mkp.groupId 'org.codehaus.groovy'
70-
mkp.artifactId name ? "groovy-$name" : "groovy"
71-
mkp.version( groovyVersion )
7272
}
7373
}
7474

75-
['aop', 'aspects', 'beans', 'context-support', 'context', 'core', 'expression', 'instrument', 'jdbc','jms', 'messaging', 'orm', 'oxm', 'test', 'tx', 'web', 'webmvc', 'websocket'].each { name ->
76-
mkp.dependency {
77-
mkp.groupId 'org.springframework'
78-
mkp.artifactId "spring-$name"
79-
mkp.version( springVersion )
75+
for (dep in dependencyVersions) {
76+
def info = dep.value
77+
def depList = GroovyCollections
78+
.combinations(info.names, info.modules)
79+
.collect { it.join('-') }
80+
.collect { it.endsWith('-') ? it[0..-2] : it }
81+
82+
for (dependency in depList) {
83+
mkp.dependency {
84+
mkp.groupId info.group
85+
mkp.artifactId dependency
86+
mkp.version "\${${dep.key}.version}"
87+
}
8088
}
8189
}
8290

83-
mkp.dependency {
84-
mkp.groupId 'io.methvin'
85-
mkp.artifactId "directory-watcher"
86-
mkp.version(directoryWatcherVersion) //0.3.0
87-
}
88-
89-
mkp.dependency {
90-
mkp.groupId 'org.springframework'
91-
mkp.artifactId "springloaded"
92-
mkp.version( springLoadedVersion )
93-
}
94-
95-
for(plugin in plugins) {
91+
for (plugin in plugins) {
9692
mkp.dependency {
9793
mkp.groupId 'org.grails.plugins'
9894
mkp.artifactId plugin.key
99-
def version = plugin.value
100-
if(!isBuildSnapshot && version.toString().endsWith("-SNAPSHOT")) {
95+
String version = plugin.value
96+
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
10197
throw new RuntimeException("Cannot have a snapshot dependency on a plugin [$plugin.key] for a release!")
10298
}
103-
mkp.version(version)
99+
mkp.version "\${${plugin.key}.version}"
104100
}
105101
}
106102

107-
['async', 'events'].each { name ->
108-
mkp.dependency {
109-
mkp.groupId 'org.grails.plugins'
110-
mkp.artifactId name
111-
mkp.version( asyncVersion )
112-
}
113-
}
114-
115-
['gpars', 'rxjava', 'rxjava2'].each { name ->
116-
mkp.dependency {
117-
mkp.groupId 'org.grails'
118-
mkp.artifactId "grails-async-$name"
119-
mkp.version( asyncVersion )
120-
}
121-
mkp.dependency {
122-
mkp.groupId 'org.grails'
123-
mkp.artifactId "grails-events-$name"
124-
mkp.version( asyncVersion )
125-
}
126-
}
127-
128-
mkp.dependency {
129-
mkp.groupId 'org.spockframework'
130-
mkp.artifactId "spock-core"
131-
mkp.version( spockVersion )
132-
}
133-
134-
mkp.dependency {
135-
mkp.groupId 'org.spockframework'
136-
mkp.artifactId "spock-spring"
137-
mkp.version( spockVersion )
138-
}
139-
140-
mkp.dependency {
141-
mkp.groupId 'org.grails.plugins'
142-
mkp.artifactId "gsp"
143-
mkp.version( gspVersion )
144-
}
145-
146-
147-
for(profile in profiles) {
103+
for (profile in profiles) {
148104
mkp.dependency {
149105
mkp.groupId 'org.grails.profiles'
150106
mkp.artifactId profile.key
151-
def version = profile.value
152-
if(!isBuildSnapshot && version.toString().endsWith("-SNAPSHOT")) {
107+
String version = profile.value
108+
if (!isBuildSnapshot && version.endsWith("-SNAPSHOT")) {
153109
throw new RuntimeException("Cannot have a snapshot dependency on a profile [$profile.key] for a release!")
154110
}
155111
mkp.version(version)
156112
}
157113
}
158-
159-
['gorm-', 'web-', ''].each { name ->
160-
mkp.dependency {
161-
mkp.groupId 'org.grails'
162-
mkp.artifactId "grails-${name}testing-support"
163-
mkp.version( testingSupportVersion )
164-
}
165-
}
166114
}
167115
}
168116
}
169117
}
170-
171118
}
172119
}
173120
}

0 commit comments

Comments
 (0)