/
build.gradle
123 lines (100 loc) · 3.4 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
/*
* Copyright (c) 2010-2010 LinkedIn, Inc
* Portions Copyright (c) 2011-2013 Yan Pujante
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
apply plugin: 'org.linkedin.cmdline'
apply plugin: 'org.linkedin.release'
allRepositories.utilsZookeeperDistribution.configure()
configurations {
zookeeperPackages
}
dependencies {
zookeeperPackages spec.external.utilsZookeeperServerPackage
}
def dependentClis = [
':agent:org.linkedin.glu.agent-server': 'agent-server',
':agent:org.linkedin.glu.agent-cli': 'agent-cli',
':console:org.linkedin.glu.console-server': 'console-server',
':console:org.linkedin.glu.console-cli': 'console-cli',
':packaging:org.linkedin.glu.packaging-setup': 'setup'
]
cmdline {
folders = []
dependsOn = dependentClis.keySet().collect { "${it}:package-assemble" }
resources << packageIncludes
replacementTokens = [
'jetty.distribution': "jetty-distribution-${spec.versions.jetty}",
'zookeeper.version': spec.versions.utilsZookeeper
]
}
release {
publish = allRepositories.distributions
}
def dependentProjects = dependentClis.keySet().collect { evaluationDependsOn(it) }
// customizing package-assemble task to add agent cli, agent server and war
project.'package-assemble'.doFirst {
File basePackage = project.convention.plugins.cmdline.assemblePackageFile
dependentProjects.each { dp ->
File destDir = new File(basePackage, dependentClis[dp.path])
copy {
from dp.convention.plugins.cmdline.assemblePackageFile
into destDir
}
// this information is redundant because it is at the root already
ant.delete {
fileset(dir: destDir, includes: packageIncludesFiles.join(','))
}
}
configurations.zookeeperPackages.resolve().each { zkp ->
ant.untar(src: zkp, dest: basePackage, compression: 'gzip')
}
}
task bom << {
File basePackage = project.convention.plugins.cmdline.assemblePackageFile
File lib = new File(basePackage, "lib")
delete lib
lib.mkdirs()
def allJars = fileTree(dir: basePackage)
allJars.include "**/*.jar"
def jarFiles = [:]
def bomFiles = [:]
allJars.each { File jar ->
File bomFile = new File(jar.parentFile, "bom.txt")
def bomFileContent = bomFiles[bomFile]
if(!bomFileContent)
{
bomFileContent = [__base__: bomFile.parentFile.toPath().relativize(lib.toPath())]
bomFiles[bomFile] = bomFileContent
}
def sha1 = org.gradle.util.hash.HashUtil.sha1(jar).asHexString()
def previousSha1 = jarFiles[jar.name]
if(!previousSha1)
{
copy {
from jar
into lib
}
jarFiles[jar.name] = sha1
}
else
if(sha1 != previousSha1)
throw new Exception("mismatch sha1 [${sha1} != ${previousSha1}] for ${jar}")
bomFileContent[jar.name] = sha1
}
bomFiles.each { File bomFile, def bomFileContent ->
bomFile.text = bomFileContent.collect { k, v -> "${k}=${v}"}.join("\n")
logger.info "created bom file ${bomFile}"
}
}