-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
307 lines (259 loc) · 8.82 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
buildscript {
repositories {
mavenCentral()
}
}
plugins {
// Here we define all plugins that are used by subprojects and specify the version for external ones
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'signing'
id 'java'
id 'java-library' // needed to make sure that transitive deps have 'compile' scope
id 'groovy'
id 'de.undercouch.download' version '4.0.2'
id 'com.github.johnrengelman.shadow' version '7.1.1' apply false
id 'org.xtext.builder' version '4.0.0' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
}
import java.text.SimpleDateFormat
def globalVersion = new Version(version)
class Version {
String originalVersion
String thisVersion
String status
Date buildTime
Version(String versionValue) {
buildTime = new Date()
originalVersion = versionValue
thisVersion = versionValue
if (originalVersion.endsWith('-SNAPSHOT')) {
status = 'integration'
} else {
status = 'release'
thisVersion = versionValue
}
}
String getTimestamp() {
// Convert local file timestamp to UTC
def format = new SimpleDateFormat('yyyyMMddHHmmss')
format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC')))
return format.format(buildTime)
}
String toString() {
thisVersion
}
}
apply from: 'dependencies.gradle'
tasks.register("writeVersionToReadme") {
doLast {
ant.replaceregexp(match: 'rmfVersion = \"[^\\s]+\"', replace: "rmfVersion = \"${globalVersion}\"", flags:'g', byline:true) {
fileset(dir: projectDir, includes: 'README.md')
}
}
}
ext {
scmProjectName = rootProject.name
scmRepo = 'github.com'
scmProjectPath = "commercetools/rest-modeling-framework.git" // github relative path with .git extension
scmProjectUrl = "https://$scmRepo/$scmProjectPath" // just as web-page
scmHttpsUrl = "https://$scmRepo/$scmProjectPath" // common VCS read access
scmSshUrl = "git@$scmRepo:$scmProjectPath" // developers VCS read-write repo
SNAPSHOT_SUFFIX = "-SNAPSHOT"
versionWIP = "development$SNAPSHOT_SUFFIX"
}
// maven-specific publishing settings
def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
scm {
connection "scm:git:$scmHttpsUrl"
developerConnection "scm:git:$scmSshUrl"
url "$scmProjectUrl"
}
}
group='com.commercetools.rmf'
nexusPublishing {
repositories {
sonatype {
username = System.getenv('CTP_OSS_USER')
password = System.getenv('CTP_OSS_SECRET')
}
}
}
allprojects {
description = "REST Modeling Framework. https://github.com/commercetools/rest-modeling-framework"
}
subprojects { project ->
repositories {
mavenCentral()
}
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'java-library' // needed to make sure that transitive deps have 'compile' scope
apply plugin: 'groovy'
apply plugin: 'de.undercouch.download'
group='com.commercetools.rmf'
version = globalVersion
if (project.file('src/main/antlr').exists()) {
apply plugin: 'antlr'
dependencies {
antlr _antlr.antlr
}
sourceSets {
main {
java {
srcDir 'src/main/java-gen/antlr'
}
}
}
}
if (project.file('model').exists()) {
apply plugin: 'org.xtext.builder'
xtext {
version = xtextVersion
languages {
ecore {
setup = 'org.eclipse.xtext.ecore.EcoreSupport'
}
codegen {
setup = 'org.eclipse.emf.codegen.ecore.xtext.GenModelSupport'
}
xcore {
setup = 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'
generator.outlet.producesJava = true
}
}
sourceSets {
main {
srcDir 'model'
output {
dir(xtext.languages.xcore.generator.outlet, 'src/main/java-gen/xtext')
}
}
}
}
dependencies {
api 'org.eclipse.platform:org.eclipse.equinox.common:3.8.0'
api emf.common
api emf.ecore
api emf.ecore_xcore_lib
api "org.eclipse.xtext:org.eclipse.xtext.xbase.lib:$xtextVersion"
xtextLanguages 'org.eclipse.jdt:org.eclipse.jdt.core:3.20.0'
xtextLanguages 'org.eclipse.platform:org.eclipse.text:3.13.100'
xtextLanguages 'org.eclipse.platform:org.eclipse.core.resources:3.20.0'
xtextLanguages "org.eclipse.xtext:org.eclipse.xtext.ecore:$xtextVersion"
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.mwe2.runtime:2.16.0'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:1.8.0'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.common:2.35.0'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.ecore:2.35.0'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.35.0'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.27.0'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:1.7.0'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.codegen:2.35.0'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.codegen.ecore:2.35.0'
xtextLanguages 'org.antlr:antlr-runtime:3.2.0'
}
}
javadoc {
failOnError false
options.tags = ["generated", "ordered", "model"]
options.addStringOption('Xdoclint:none', '-quiet')
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveClassifier = 'sources'
dependsOn 'compileJava'
}
task javadocJar(type: Jar) {
group 'build'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar, sourcesJar
}
def excludeProject= [
'raml-test',
]
if (project.file("build.gradle").exists() && !excludeProject.contains(project.name)) {
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/commercetools/rest-modeling-framework")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
Maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId group
artifactId project.name
version version
pom {
name = project.name
description = project.description
developers {
developer {
id = "jenschude"
name = "Jens Schulze"
email = "[email protected]"
}
}
url = scmHttpsUrl
}
pom.withXml {
def root = asNode()
root.children().last() + pomConfig
}
}
}
}
signing {
useGpgCmd()
sign publishing.publications.Maven
}
}
test {
useJUnitPlatform()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
def exportedProjects= [
":antlr-utils",
":emf-utils",
":functional-utils",
":node-model",
":raml-model",
]
task alljavadoc(type: Javadoc) {
failOnError false
source exportedProjects.collect { project(it).sourceSets.main.allJava }
classpath = files(exportedProjects.collect { project(it).sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
options.noTimestamp = true
}
configurations.all {
if (name.contains("Tooling")) {
dependencies {
add(name, "org.eclipse.xtend:org.eclipse.xtend.core:$xtextVersion")
add(name, platform("org.eclipse.xtext:xtext-dev-bom:$xtextVersion"))
}
}
}