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
| apply plugin: "groovy"
apply plugin: "war"
version = "1.0.0"
configurations {
catalinaAnt
}
dependencies {
catalinaAnt "org.apache.tomcat:tomcat-catalina-ant:7.0.0"
// 以下省略
}
// 先程ログインの動作確認をしたサーバのURL
def url = "http://testserver:8080/manager"
// デプロイ対象のアプリケーション名
def path = "/xxxxxx"
def user = project.properties['user']
def password = project.properties['password']
task tomcatStop << {
ant.taskdef(
'name':"stop", 'classname':"org.apache.catalina.ant.StopTask", 'classpath':configurations.catalinaAnt.asPath
)
ant.stop( 'username':user, 'path':path, 'password':password, 'url':url )
}
task tomcatStart << {
ant.taskdef(
'name':"start", 'classname':"org.apache.catalina.ant.StartTask", 'classpath':configurations.catalinaAnt.asPath
)
ant.start( 'username':user, 'path':path, 'password':password, 'url':url )
}
task tomcatReload(dependsOn:[clean, war]) << {
ant.taskdef(
'name':"reload", 'classname':"org.apache.catalina.ant.ReloadTask", 'classpath':configurations.catalinaAnt.asPath
)
ant.reload( 'username':user, 'path':path, 'password':password, 'url':url )
}
task tomcatList << {
ant.taskdef(
'name':"list", 'classname':"org.apache.catalina.ant.ListTask", 'classpath':configurations.catalinaAnt.asPath
)
ant.list( 'username':user, 'password':password, 'url':url )
}
task tomcatDeploy(dependsOn:[clean, war]) << {
ant.taskdef(
'name':"deploy", 'classname':"org.apache.catalina.ant.DeployTask", 'classpath':configurations.catalinaAnt.asPath
)
ant.deploy( 'username':user, 'path':path, 'password':password, 'url':url, 'war':"$rootDir/build/libs/xxxxxx-1.0.0.war" )
}
task tomcatUndeploy << {
ant.taskdef(
'name':"undeploy", 'classname':"org.apache.catalina.ant.UndeployTask", 'classpath':configurations.catalinaAnt.asPath
)
ant.undeploy( 'username':user, 'path':path, 'password':password, 'url':url )
}
|