forked from LabKey/server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
418 lines (379 loc) · 21.6 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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
import org.apache.commons.lang3.SystemUtils
import org.labkey.gradle.task.ShowDiscrepancies
import org.labkey.gradle.util.BuildUtils
import org.labkey.gradle.util.GroupNames
import org.labkey.gradle.plugin.NpmRun
import org.labkey.gradle.task.PurgeNpmAlphaVersions
buildscript {
repositories {
maven {
url "${artifactory_contextUrl}/plugins-release"
}
if (gradlePluginsVersion.contains("SNAPSHOT") || versioningPluginVersion.contains("SNAPSHOT"))
{
maven {
url "${artifactory_contextUrl}/plugins-snapshot-local"
}
}
}
dependencies {
classpath "org.labkey.build:versioning:${versioningPluginVersion}"
}
configurations.all {
// Check for updates every build for SNAPSHOT dependencies
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
plugins {
id "com.jfrog.artifactory" version "${artifactoryPluginVersion}" apply false
id "com.github.node-gradle.node" version "${gradleNodePluginVersion}" apply false
id "org.owasp.dependencycheck" version "${owaspDependencyCheckPluginVersion}" apply false
// id "com.github.ben-manes.versions" version "0.39.0"
id "org.labkey.build.multiGit"
}
allprojects {
if (project.hasProperty('enableOwaspDependencyCheck'))
{
// Comment in to enable the tasks for owasp dependency checking
apply plugin: 'org.owasp.dependencycheck'
dependencyCheck {
outputDirectory = "${project.rootProject.buildDir}/reports/dependencyCheck/${project.path.replaceAll(':', '_').substring(1)}"
}
}
if (BuildUtils.shouldPublish(project) || BuildUtils.shouldPublishDistribution(project))
{
apply plugin: 'com.jfrog.artifactory'
}
project.tasks.withType(JavaCompile) {
JavaCompile compile ->
compile.options.incremental = true // Gradle 3.4
compile.options.encoding = 'UTF-8'
}
}
// We need the tomcat home directory to run UI tests from within IntelliJ.
String tomcatDirProp = System.getenv('CATALINA_HOME') != null ? System.getenv('CATALINA_HOME') : System.properties['tomcat.home']
if (tomcatDirProp != null && !new File(tomcatDirProp).exists())
throw new GradleException("Tomcat home directory ${tomcatDirProp} does not exist.")
allprojects {
// this configuration is needed only in server and testAutomation, but we leave it here (for now) to avoid duplication
configurations
{
driver
utilities
}
configurations.driver.setDescription("Dependencies used for SqlUtils")
configurations.utilities.setDescription("Utility binaries for use on Windows platform")
dependencies
{
//for SqlUtils
driver "net.sourceforge.jtds:jtds:${jtdsVersion}"
driver "org.postgresql:postgresql:${postgresqlDriverVersion}"
if (SystemUtils.IS_OS_WINDOWS)
{
utilities "org.labkey.tools.windows:utils:${windowsUtilsVersion}@zip"
}
}
// We apply the base module here so we get the configurations (in particular external and modules)
// that can be used for the allDepInsight task below. I would really prefer not to do this here, but
// we'll need to find another solution for allDepInsight (perhaps enumerate projects?)
apply plugin: 'org.labkey.build.base'
tasks.withType(JavaCompile)
{
sourceCompatibility = project.ext.sourceCompatibility
targetCompatibility = project.ext.targetCompatibility
}
repositories
{
// this if statement is necessary because the TeamCity artifactory plugin overrides
// the repositories but does not use these artifactory_ urls. For others who are
// developing or building, you do need to specify the three artifactory_ properties
// used below.
if (project.hasProperty("artifactory_contextUrl"))
{
maven {
url "${artifactory_contextUrl}/ext-tools-local"
}
maven {
url "${artifactory_contextUrl}/libs-release"
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password'))
{
credentials {
username = artifactory_user
password = artifactory_password
}
authentication {
basic(BasicAuthentication) // enable preemptive authentication to get around https://www.jfrog.com/jira/browse/RTFACT-4434
}
}
}
maven {
url "${artifactory_contextUrl}/libs-snapshot"
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password'))
{
credentials {
username = artifactory_user
password = artifactory_password
}
authentication {
basic(BasicAuthentication) // enable preemptive authentication to get around https://www.jfrog.com/jira/browse/RTFACT-4434
}
}
}
// Temporarily uncomment the block below and update the four-digit number to allow building with Tomcat versions that
// haven't been released yet. The "VOTE" emails sent to the Tomcat dev email list include a staging repo URL. In
// addition to updating the url to match, you'll also need to update apacheTomcatVersion in gradle.properties.
// maven {
// url "https://repository.apache.org/content/repositories/orgapachetomcat-1322/"
// }
}
mavenCentral()
}
configurations.all
{
// Check for updates every build for SNAPSHOT dependencies
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
configurations.all
{Configuration config ->
resolutionStrategy {
// we force this version because we have compilation problems with version 1.9.2 of commons-beanutils, which is the version
// that is brought in by Gradle's conflict resolution as a result of our chosen versions for commons-validator (1.5.0) and commons-digester (1.8.1)
force "commons-beanutils:commons-beanutils:${commonsBeanutilsVersion}"
// we get different versions of slf4j-log4j12 and slf4j-api from different transitive dependencies.
force "org.slf4j:slf4j-log4j12:${slf4jLog4j12Version}"
force "org.slf4j:slf4j-api:${slf4jLog4jApiVersion}"
// force some newer versions than are brought in by mondrian (et al.)
force "xerces:xercesImpl:${xercesImplVersion}"
force "org.apache.logging.log4j:log4j-core:${log4j2Version}"
force "org.apache.logging.log4j:log4j-api:${log4j2Version}"
force "org.apache.logging.log4j:log4j-1.2-api:${log4j2Version}"
// force version for consistency with saml, query, LDK, and pipeline
force "commons-lang:commons-lang:${commonsLangVersion}"
// force version for consistency with workflow, api, SequenceAnalysis
force "org.apache.commons:commons-lang3:${commonsLang3Version}"
force "commons-dbcp:commons-dbcp:${commonsDbcpVersion}"
force "commons-io:commons-io:${commonsIoVersion}"
force "commons-logging:commons-logging:${commonsLoggingVersion}"
force "commons-pool:commons-pool:${commonsPoolVersion}"
// force version for consistency with query, saml, LDK, api
force "commons-collections:commons-collections:${commonsCollectionsVersion}"
// force version for ms2, saml, fileTransfer, harvest, scrumtime, api, accounts, docker
force "commons-codec:commons-codec:${commonsCodecVersion}"
// force version consistency in TCRdb, SequenceAnalysis, API
force "org.apache.commons:commons-math3:${commonsMath3Version}"
// force version for api, accounts, fileTransfer, harvest, scrumtime, docker
force "org.apache.httpcomponents:httpcore:${httpcoreVersion}"
// force version for api, docker, fileTransfer, harvest, scrumtime, accounts
force "org.apache.httpcomponents:httpclient:${httpclientVersion}"
// force version for SequenceAnalysis, api, cloud
force "com.google.guava:guava:${guavaVersion}"
// force version for accounts, api, query
force "javax.validation:validation-api:${validationApiVersion}"
// force version for accounts, docker, api, workflow
force "com.fasterxml.jackson.core:jackson-annotations:${jacksonAnnotationsVersion}"
// saml and query bring in different versions transitively; we force the later one
force "xalan:xalan:${xalanVersion}"
// genotyping brings in a much older version of this, so we force a newer version for compatibility
force "org.apache.commons:commons-compress:${commonsCompressVersion}"
// Transitive dependency of commons-compress -- Transitive dependency com.github.samtools:htsjdk:2.14.3 uses much older version
force "org.tukaani:xz:${tukaaniXZVersion}"
// force version for api, LDK, pipeline, query, saml, but not for the xsdDoc configuration, which requires
// an older version for the docflex library we use
if (!config.name.equals('xsdDoc'))
force "xml-apis:xml-apis:${xmlApisVersion}"
// cloud and SequenceAnalysis bring this in as a transitive dependency. We resolve to the later version here to keep things consistent
force "com.google.code.gson:gson:${gsonVersion}"
// workflow (Activiti) brings in older versions of these libraries, so we need to force these versions
force "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
force "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
// The version of picard we depend on brings in an older version of htsjdk, but SequenceAnalysis depends on a later version
force "com.github.samtools:htsjdk:${htsjdkVersion}"
// Cloud module brings in earlier versions of this library, so we force the later one
force "org.apache.tika:tika-core:${tikaVersion}"
// OpenLDAPSync and premium have transitive dependency on a broken version of MINA
force "org.apache.mina:mina-core:${apacheMinaVersion}"
// saml has transitive dependencies on old versions of batik and xmlgraphics-commons, which conflict with more recent versions in api
force "org.apache.xmlgraphics:batik-css:${batikVersion}"
force "org.apache.xmlgraphics:xmlgraphics-commons:${fopVersion}"
// force consistency in TCRdb, WNPRC
force "org.javassist:javassist:${javassistVersion}"
force "org.ow2.asm:asm:${asmVersion}"
// force junit and hamcrest versions to be consistent with what comes from labkey-client-api via json-simple.
// The hamcrest dependencies come through transitively from jackson, json-simple, junit, jmock
force "org.hamcrest:hamcrest-core:${hamcrestVersion}"
force "org.hamcrest:hamcrest-library:${hamcrestVersion}"
force "junit:junit:${junitVersion}"
// force consistency in nlp and saml that bring these in transitively
force "org.codehaus.woodstox:stax2-api:${stax2ApiVersion}"
force "com.fasterxml.woodstox:woodstox-core:${woodstoxCoreVersion}"
// force consistency in transitive dependency for fileTransfer compared to api
// This can be removed when the googleHttpClient version is updated to bring in a consistent version
force "com.google.code.findbugs:jsr305:${jsr305Version}"
dependencySubstitution {
// Because the client api artifact name is not the same as the directory structure, we use
// Gradle's dependency substitution so the dependency will appear correctly in the pom files that
// are generated. Because dependency substitution does not understand the use of classifiers, we cannot
// use this mechanism in general (plus, it's very slow for our many-module build).
if (project.findProject(BuildUtils.getRemoteApiProjectPath(gradle)) && BuildUtils.shouldBuildFromSource(project.project(BuildUtils.getRemoteApiProjectPath(gradle))))
substitute module('org.labkey:labkey-client-api') with project(BuildUtils.getRemoteApiProjectPath(gradle))
// mule and tika bring in different versions of bouncycastle package via transitive dependencies, but these versions
// result in a StackOverflow when starting tomcat so we substitute new libraries for both versions that are brought in.
substitute module('bouncycastle:bcprov-jdk14:138') with module("org.bouncycastle:bcprov-jdk15on:${bouncycastleVersion}")
substitute module('bouncycastle:bcmail-jdk14:138') with module("org.bouncycastle:bcpkix-jdk15on:${bouncycastleVersion}")
substitute module('bouncycastle:bcprov-jdk15:1.45') with module("org.bouncycastle:bcprov-jdk15on:${bouncycastleVersion}")
substitute module('bouncycastle:bcmail-jdk15:138') with module("org.bouncycastle:bcpkix-jdk15on:${bouncycastleVersion}")
// This JAR packages classes with the same names as commons-logging but forces them to use SLF4J instead
// of the normal routing decisions, and can result in very verbose output to STDOUT
substitute module('org.slf4j:jcl-over-slf4j') with module("commons-logging:commons-logging:${commonsLoggingVersion}")
// jdk5 backport of guava has significant conflicts with guava 18+
substitute module('com.google.guava:guava-jdk5') with module("com.google.guava:guava:${guavaVersion}")
// This library was renamed
substitute module('org.codehaus.woodstox:woodstox-core-asl') with module("com.fasterxml.woodstox:woodstox-core:${woodstoxCoreVersion}")
}
}
}
}
if (BuildUtils.shouldPublish(project) || BuildUtils.shouldPublishDistribution(project))
{
artifactory {
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = BuildUtils.getRepositoryKey(project)
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password'))
{
username = artifactory_user
password = artifactory_password
}
maven = true
}
defaults
{
publishPom = true
publishIvy = false
}
}
}
artifactoryPublish.skip = true
}
subprojects {
task("showRepos", group: "Help", description: "Show the list of repositories currently in use.").doLast({
repositories.each {
println "repository: ${it.name} (${it.hasProperty("url") ? it.url : it.getDirs()})"
}
})
project.task("showConfigs", group: "help", description: "Show all the configurations available in the project and their published artifacts")
.doLast({
project.configurations.forEach({
Configuration config ->
println(config.name + ": (${config.getDescription()})")
})
})
task("allDepInsight",
type: DependencyInsightReportTask,
group: "Help",
description: "Displays the insight into a specific dependency across all projects")
task("allDependencies",
type: DependencyReportTask,
group: "Help",
description: "Displays the dependencies for all projects")
}
project.task("showDiscrepancies",
group: "Help",
type: ShowDiscrepancies,
description: "Report external dependencies that have more than one version referenced in the modules in this build"
)
project.task(
'getModulesManifest',
group: GroupNames.DISTRIBUTION,
description: "Creates a csv file with a list of the modules for each distribution. By default it will be " +
"placed in a directory called manifests in the root of this labkey installation. Specify another " +
"directory by using \"-PmanifestDir\". The default file name is distributionModules.csv; specify " +
"another name using \"-PmanifestFileName\"."
).doLast({
String manifestDir = "${project.getRootProject().getProjectDir()}/manifests"
String manifestFileName = "distributionModules.csv"
if (project.hasProperty("manifestDir")) {
manifestDir = project.manifestDir
}
if (project.hasProperty("manifestFileName")) {
manifestFileName = project.manifestFileName
}
project.mkdir(manifestDir)
File manifestFile = project.file("${manifestDir}/${manifestFileName}")
StringBuilder manifestString = new StringBuilder("distribution,moduleName\n")
project.allprojects({Project sp ->
if (sp.configurations.getNames().contains("distribution")) {
String distName
if (sp.getName().startsWith("test_")) {
// This is for the test_*prc case.
distName = sp.getName()
}
else {
distName = sp.tasks.distribution.hasProperty("subDirName") ?
sp.tasks.distribution.subDirName :
sp.getName()
}
sp.configurations.distribution
.getAllDependencies()
.withType(ProjectDependency)
.each({dep ->
manifestString.append("${distName},${dep.name}\n")
})
}
})
manifestFile.text = manifestString.toString()
})
project.task(
'listNpmProjects',
group: GroupNames.NPM_RUN,
description:"List all projects that employ npm in their build"
).doLast({
List<String> npmProjects = []
project.allprojects({Project p ->
if (p.getPlugins().hasPlugin(NpmRun.class))
npmProjects.add("${p.path} (${NpmRun.useYarn(p) ? 'yarn' : 'npm'})")
})
if (npmProjects.size == 0)
println("No projects found containing ${NpmRun.NPM_PROJECT_FILE}")
else {
println("The following projects use NPM in their builds:\n\t${npmProjects.join("\n\t")}\n")
}
})
project.tasks.register('ijWorkspaceSetup', Copy) {
Copy copy ->
copy.group = "IntelliJ"
copy.description = "Copy the workspace template file. Used only once, for initial setup of the IntelliJ project."
copy.from(".idea/configTemplates/workspace.xml")
copy.into('.idea')
}
project.tasks.register("ijRunConfigurationsSetup", Copy) {
Copy copy ->
copy.group = "IntelliJ"
copy.description = "Copy run configurations from templates, substituting path separators for this OS"
copy.from(".idea/runConfigurations/templates")
copy.into(".idea/runConfigurations")
copy.filter({ String line ->
return line.replace("PATH_SEPARATOR", File.pathSeparator)
})
}
project.tasks.register("ijCodeSetup", Copy) {
Copy copy ->
copy.group = "IntelliJ"
copy.description = "Copy template files from .idea/configTemplates to .idea directory (excluding the workspace.xml file)"
copy.from(".idea/configTemplates")
copy.into(".idea/")
copy.exclude("workspace.xml")
}
project.tasks.register('ijConfigure') {
DefaultTask task ->
task.group = "IntelliJ"
task.description = "Install IntelliJ template files as files for IntelliJ to use in .idea directory"
}
project.tasks.ijConfigure.dependsOn(project.tasks.ijCodeSetup, project.tasks.ijRunConfigurationsSetup)
project.tasks.register('purgeNpmAlphaVersions', PurgeNpmAlphaVersions) {
group = GroupNames.NPM_RUN
description = "Given an alpha version prefix for npm packages via the property -P${PurgeNpmAlphaVersions.ALPHA_PREFIX_PROPERTY}=yourPrefix, " +
"removes all packages with versions that match that prefix from Artifactory (e.g., @labkey/components-1.2.3-yourPrefix.0 and @labkey/workflow-0.3.4-yourPrefix.1). " +
" Use -PdryRun to see what versions would be deleted without actually doing the deletion."
}