forked from moqui/moqui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
125 lines (111 loc) · 5.46 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
/*
* This Work is in the public domain and is provided on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* including, without limitation, any warranties or conditions of TITLE,
* NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
* You are solely responsible for determining the appropriateness of using
* this Work and assume any risks associated with your use of this Work.
*
* This Work includes contributions authored by David E. Jones, not as a
* "work for hire", who hereby disclaims any copyright to the same.
*/
allprojects { version = '1.2.1' }
def tomcatHome = '../apache-tomcat-7.0.32'
def warName = 'moqui-' + version + '.war'
def execTempDir = 'execwartmp'
def moquiRuntime = 'runtime'
def moquiConfDev = 'conf/MoquiDevConf.xml'
def moquiConfProduction = 'conf/MoquiProductionConf.xml'
def allBuildTasks = []
def allCleanTasks = []
allprojects {
afterEvaluate { project ->
for (def task in project.tasks) {
if (task.name == 'build') allBuildTasks.add(task)
if (task.name == 'clean') allCleanTasks.add(task)
}
}
}
// ========== clean tasks ==========
task clean(type: Delete) { delete file(warName); delete file(execTempDir) }
task cleanTempDir(type: Delete) { delete file(execTempDir) }
task cleanDb(type: Delete) { delete files(file(moquiRuntime+'/db/derby').listFiles()) - files(moquiRuntime+'/db/derby/derby.properties') }
task cleanElasticSearch(type: Delete) { delete file(moquiRuntime+'/elasticsearch/data') }
task cleanLog(type: Delete) { delete fileTree(dir: moquiRuntime+'/log', include: '*') }
task cleanOther(type: Delete) { delete fileTree(dir: '.', includes: ['**/.nbattrs', '**/*~', '**/.#*', '**/.DS_Store', '**/*.rej', '**/*.orig']) }
task cleanAll {
dependsOn clean
dependsOn allCleanTasks
dependsOn cleanDb
dependsOn cleanElasticSearch
dependsOn cleanLog
dependsOn cleanOther
}
// ========== run tasks ==========
task run(type: JavaExec) {
dependsOn allBuildTasks
dependsOn cleanTempDir
workingDir = '.'; jvmArgs = ['-server', '-XX:MaxPermSize=128m']; maxHeapSize = '256M'
systemProperties = ['moqui.conf':moquiConfDev, 'moqui.runtime':moquiRuntime]
// NOTE: this is a hack, using -jar instead of a class name, and then the first argument is the name of the jar file
main = '-jar'; args = [warName]
}
task runStaging(type: JavaExec) {
dependsOn allBuildTasks
dependsOn cleanTempDir
workingDir = '.'; jvmArgs = ['-server', '-XX:MaxPermSize=128m', '-Xms512M']; maxHeapSize = '512M'
systemProperties = ['moqui.conf':'conf/MoquiStagingConf.xml', 'moqui.runtime':moquiRuntime]
main = '-jar'; args = [warName]
}
task runProduction(type: JavaExec) {
dependsOn allBuildTasks
dependsOn cleanTempDir
workingDir = '.'; jvmArgs = ['-server', '-XX:MaxPermSize=128m', '-Xms512M']; maxHeapSize = '512M'
systemProperties = ['moqui.conf':moquiConfProduction, 'moqui.runtime':moquiRuntime]
main = '-jar'; args = [warName]
}
task load(type: JavaExec) {
dependsOn allBuildTasks
workingDir = '.'; jvmArgs = ['-server', '-XX:MaxPermSize=128m']; maxHeapSize = '256M'
systemProperties = ['moqui.conf':moquiConfDev, 'moqui.runtime':moquiRuntime]
main = '-jar'; args = [warName, '-load']
}
task loadProduction(type: JavaExec) {
dependsOn allBuildTasks
workingDir = '.'; jvmArgs = ['-server', '-XX:MaxPermSize=128m']; maxHeapSize = '256M'
systemProperties = ['moqui.conf':moquiConfProduction, 'moqui.runtime':moquiRuntime]
main = '-jar'; args = [warName, '-load']
}
// ========== deploy tasks ==========
task deployTomcat << {
// remove runtime directory, may have been added for logs/etc
delete file(tomcatHome + '/runtime')
// remove ROOT directory and war to avoid conflicts
delete file(tomcatHome + '/webapps/ROOT')
delete file(tomcatHome + '/webapps/ROOT.war')
// copy the war file to ROOT.war
copy { from file(warName); into file(tomcatHome + '/webapps'); rename(warName, 'ROOT.war') }
}
task addRuntime << {
// unzip the "moqui-${version}.war" file to the wartemp directory
//directory { dir = file('wartemp') }
copy { from zipTree(warName); into file('wartemp') }
// copy runtime directory (with a few exceptions) into a runtime directory in the war
copy {
from fileTree(dir: '.', include: moquiRuntime+'/**', excludes: ['**/*.jar', moquiRuntime+'/classes/**', moquiRuntime+'/lib/**', moquiRuntime+'/db/**', moquiRuntime+'/log/**'])
into file('wartemp')
}
// copy the jar files from runtime/lib
copy { from fileTree(dir: moquiRuntime+'/lib', include: '*.jar'); into 'wartemp/WEB-INF/lib' }
// copy the classpath resource files from runtime/classes
copy { from fileTree(dir: moquiRuntime+'/classes', include: '**/*'); into 'wartemp/WEB-INF/classes' }
// TODO copy the jar files from components?
// this copies whole directory tree, how to just get files? copy { from fileTree(dir: 'runtime/component', include: '**/*.jar'); into 'wartemp/WEB-INF/lib' }
// add MoquiInit.properties fresh copy, just in case it was changed
copy { from file('MoquiInit.properties'); into 'wartemp/WEB-INF/classes' }
// zip it up again
ant.zip(destfile: 'moqui-plus-runtime.war') { fileset(dir: 'wartemp') { include(name: '**/*') } }
// alternative once supported: zip { archiveName 'moqui-plus-runtime.war'; from fileTree(dir: 'wartemp', include: '**/*') }
// clean up the temporary directory
delete file('wartemp')
}