-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
75 lines (64 loc) · 2.12 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
import groovy.swing.SwingBuilder
repositories {
mavenCentral()
}
configurations {
sshAntTask
}
dependencies {
sshAntTask "org.apache.ant:ant-jsch:1.9.3"
sshAntTask "jsch:jsch:0.1.29"
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.apache.ant:ant-jsch:1.9.3"
}
}
task update {
def user = System.getenv("USER")
def home = System.getenv("HOME")
def folder = "/usr/share/nginx/www/homepage"
description = "Update files on remote server as $user."
// Redefine scp Ant task, with the classpath property set to our newly defined
// sshAntTask configuration classpath.
ant.taskdef(name: 'scp', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
classpath: configurations.sshAntTask.asPath)
doLast {
def console = System.console()
def passphrase = ''
if (console) {
passphrase = console.readPassword("%s: ", "Please enter passphrase for the key file ($home/.ssh/id_rsa)")
} else {
new SwingBuilder().edt{
dialog(modal: true,
title: 'Enter password',
alwaysOnTop: true,
resizable: false,
locationRelativeTo: null,
pack: true,
show: true){
vbox {
label(text: 'Please enter key passphrase:')
input = passwordField()
button(defaultButton: true, text: 'OK', actionPerformed: {
passphrase = input.password;
dispose();
})
}
}
}
}
// Invoke the scp Ant task. (Use gradle -i update to see the output of the Ant task.)
ant.scp(todir: "$user@jackivy.com:$folder",
keyfile: "$home/.ssh/id_rsa",
passphrase: passphrase as String, // Use phassphrase entered by the user.
verbose: 'true') {
fileset(dir: 'web') {
include(name: '**/**')
}
}
}
}