-
Notifications
You must be signed in to change notification settings - Fork 40
/
build.gradle
169 lines (137 loc) · 5.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
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
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* 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.
*/
archivesBaseName = 'webdav-servlet'
project.group = 'net.sf.webdav-servlet'
project.version = '2.1-dev'
usePlugin('war')
usePlugin('jetty')
sourceCompatibility = 1.5
targetCompatibility = 1.5
dependencies {
addMavenRepo()
providedCompile "javax.servlet:servlet-api:2.4"
compile "org.slf4j:slf4j-api:1.4.3"
compile "org.slf4j:slf4j-log4j12:1.4.3"
compile "log4j:log4j:1.2.12"
testCompile "junit:junit:4.4"
testCompile "org.jmock:jmock:2.4.0"
testCompile "org.springframework:spring-webmvc:2.5.2"
testCompile "org.springframework:spring-mock:2.0.7"
addConfiguration("jettyRuntime")
jettyRuntime "org.mortbay.jetty:jsp-2.1:6.1.14", "org.mortbay.jetty:jetty-annotations:6.1.14"
}
defaultTasks "help"
createTask ('help') {
println " "
println "available goals:"
println " clean \t\tcleans the build folder"
println " test \t\t\truns the test suite"
println " eclipse \t\tcreates eclipse project files"
println " jettyRun \t\tstarts with jetty webserver"
println " "
println "useful flags :"
println " -Dskip.test \t\tskip execution of tests"
println " "
println "examples"
println " ./gradlew clean dists -Dskip.test \tbuilds the distribution and skip the tests"
}
createTask('wrapper', type: Wrapper).configure {
urlRoot = 'http://dist.codehaus.org/gradle/'
gradleVersion = '0.5'
jarPath = 'build-libs'
}
test {
include '**/*Test.class'
exclude '**/net/sf/webdav/testutil/**/*Test.class'
}
String jettyArtifactVersion = 'jetty-6.1.14'
File jettyDistribution = new File(buildDir, jettyArtifactVersion)
libs {
archive_jar.enabled=true
jar(classifier: 'sources') {
fileSet(dir: 'src/main/java')
}
jar(classifier: 'javadoc') {
fileSet(dir: new File(buildDir, "docs/javadoc"))
}
}
archive_javadoc_jar.dependsOn('javadoc')
dists {
zip() {
String zipRoot = "$archivesBaseName-${project.version}"
zipFileSet(dir: new File(buildDir, jettyArtifactVersion), prefix: zipRoot)
}
}
archive_zip.doFirst() {
ant.unzip(src: new File("build-libs", jettyArtifactVersion+".zip"), dest: buildDir)
ant.delete(dir: new File(jettyDistribution, 'patches'))
ant.delete(dir: new File(jettyDistribution, 'modules'))
ant.delete(dir: new File(jettyDistribution, 'jxr'))
ant.delete(dir: new File(jettyDistribution, 'javadoc'))
ant.delete(dir: new File(jettyDistribution, 'extras'))
ant.delete(dir: new File(jettyDistribution, 'distribution'))
ant.delete(dir: new File(jettyDistribution, 'contrib'))
ant.delete(dir: new File(jettyDistribution, 'examples'))
ant.delete(dir: new File(jettyDistribution, 'contexts'))
ant.delete(dir: new File(jettyDistribution, 'webapps'))
ant.delete(file: new File(jettyDistribution, 'pom.xml'))
ant.delete(file: new File(jettyDistribution, 'README.txt'))
ant.delete(file: new File(jettyDistribution, 'VERSION.txt'))
ant.mkdir(dir: new File(jettyDistribution, 'contexts'))
ant.mkdir(dir: new File(jettyDistribution, 'webapps'))
ant.unzip(src: archive_war.archivePath, dest: new File(jettyDistribution, 'webapps/ROOT'))
ant.copy(file: 'src/main/scripts/start.sh', todir: jettyDistribution)
}
jettyRun {
contextPath = '/'
scanIntervalSeconds = 2
useTestClasspath = true
connectors = configure(new org.mortbay.jetty.nio.SelectChannelConnector()) {
port = 8088
maxIdleTime = 60000
}
}.doFirst { jettyRun ->
jettyRun.additionalRuntimeJars = dependencies.jettyRuntime.resolve() as List
}
createTask('android-webapp', dependsOn:'compile') {
File generatedClasses = new File(buildDir, 'generated-classes')
def webappClassPath = dependencies.resolve("compile");
def excludeArtifacts = ['servlet-api'];
webappClassPath.each {jarFile ->
excludeArtifacts.each {excludeArtifact ->
if (jarFile.toString().indexOf(excludeArtifact) == -1) {
ant.unzip(src: jarFile, dest: generatedClasses)
}
}
}
File androidWebapp = new File(buildDir, 'android-webapp/exploded')
androidWebapp.mkdirs();
File androidWebAppLib = new File(androidWebapp, "WEB-INF/lib");
androidWebAppLib.mkdirs();
String dxPath = System.getProperty("dxTool");
String argument1 = '--dex'
String argument2 = '--core-library'
String argument3 = '--output='+new File(androidWebAppLib, "classes.zip").getAbsolutePath();
String argument4 = '--positions=lines'
String argument5 = new File(buildDir, "classes").getAbsolutePath();
String argument6 = new File(buildDir, "generated-classes").getAbsolutePath();
def command = """${dxPath} ${argument1} ${argument2} ${argument3} ${argument4} ${argument5} ${argument6}"""// Create the String
println command
def proc = command.execute()
proc.waitFor()
ant.copy(file: 'src/main/webapp/WEB-INF/web.xml', todir: new File(androidWebapp, "WEB-INF"))
ant.war(destfile: new File(buildDir, "android-webapp/webdav-servlet.war"), basedir: androidWebapp, webxml: 'src/main/webapp/WEB-INF/web.xml')
}