-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
115 lines (92 loc) · 2.89 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
plugins {
id "de.undercouch.download" version "3.1.1"
id "nebula.ospackage" version "4.0.0"
}
repositories {
mavenCentral()
}
import de.undercouch.gradle.tasks.download.Download
group 'com.sdavids'
version '0.1'
ext {
solrVersion = project.hasProperty('solrVersion') ? project.getProperty('solrVersion') : '5.5.3'
solrInstallDir = "/opt/solr"
solrVarDir = '/var/solr'
solrHome = "${solrVarDir}/data"
solrLogsDir = "${solrVarDir}/logs"
solrExtractLocation = "${buildDir}/solr-${solrVersion}"
}
task downloadSolr(type: Download) {
src "http://archive.apache.org/dist/lucene/solr/${solrVersion}/solr-${solrVersion}.tgz"
dest new File(buildDir, "solr-${solrVersion}.tgz")
onlyIfNewer true
}
task downloadAndExtractSolr(dependsOn: downloadSolr, type: Copy) {
from tarTree(downloadSolr.dest)
into buildDir
}
ospackage {
packageName = 'solr'
summary = 'Solr Search Engine'
packageDescription = 'Solr is the popular, blazing-fast, open source enterprise search platform built on Apache Lucene.'
vendor = 'Apache Software Foundation (ASF)'
url = 'http://lucene.apache.org/solr/'
license = 'Apache License, Version 2.0'
version = solrVersion
release = 1
os = LINUX
user = 'solr'
permissionGroup = 'solr'
preUninstall file('scripts/cleanSolrWebapp.sh')
requires('lsof')
directory(solrLogsDir, 0640)
from (solrExtractLocation) {
exclude(['dist/**', 'example/**', 'docs/**'])
into solrInstallDir
}
from("${solrExtractLocation}/bin/init.d/solr") {
into '/etc/init.d'
fileMode 0755
user 'root'
permissionGroup 'root'
}
from("${solrExtractLocation}/bin/solr.in.sh") {
filter { line ->
switch (line) {
case ~/^#?SOLR_HOME=.*/:
return "SOLR_HOME=${solrHome}"
case ~/^#?LOG4J_PROPS=.*/:
return "LOG4J_PROPS=${solrVarDir}/log4j.properties"
case ~/^#?SOLR_LOGS_DIR=.*/:
return "SOLR_LOGS_DIR=${solrLogsDir}"
default:
return line
}
}
into '/etc/default'
fileType CONFIG | NOREPLACE
fileMode 0755
user 'root'
permissionGroup 'root'
}
from("${solrExtractLocation}/server/resources/log4j.properties") {
filter { line -> line.replaceAll("^solr.log=.*", "solr.log=${solrLogsDir}") }
into solrVarDir
fileType CONFIG | NOREPLACE
}
from("${solrExtractLocation}/server/solr/solr.xml") {
into solrHome
fileType CONFIG | NOREPLACE
}
}
buildRpm {
preInstall file('scripts/rpm/createSolrUser.sh')
}
buildDeb {
preInstall file('scripts/deb/createSolrUser.sh')
}
buildRpm.dependsOn downloadAndExtractSolr
buildDeb.dependsOn downloadAndExtractSolr
task wrapper(type: Wrapper) {
gradleVersion = '3.0'
}