-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmail.gradle
executable file
·86 lines (68 loc) · 1.84 KB
/
mail.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
repositories {
mavenCentral()
}
configurations {
antClasspath
}
dependencies {
antClasspath 'ant:ant-javamail:1.+'
antClasspath 'javax.activation:activation:1.1.1'
antClasspath 'javax.mail:mail:1.+'
}
ClassLoader antClassLoader = org.apache.tools.ant.Project.class.classLoader
configurations.antClasspath.each { File jar ->
antClassLoader.addURL( jar.toURI().toURL() )
}
task sendMail() << {
if (!project.hasProperty('mailHost')) {
ext.mailHost = 'frink.ciqua.com'
}
if (!project.hasProperty('mailSubject')) {
ext.mailSubject = nil
}
if (!project.hasProperty('mailPort')) {
ext.mailPort = 25
}
if (!project.hasProperty('mailMessageMimeType')) {
ext.mailMessageMimeType = 'text/html'
}
if (!project.hasProperty('mailUser')) {
ext.mailUser = nil
}
def mailPassword = null
if (project.ext.properties.containsKey("mailPassword")) {
mailPassword = project.ext.mailPassword
} else {
mailPassword = System.console().readPassword("\nPlease enter the mail server password for user ${mailUser}")
}
if (!project.hasProperty('mailFrom')) {
ext.mailFrom = 'Cocoanetics Build Server <[email protected]>'
}
if (!project.hasProperty('mailToAddresses')) {
ext.mailToAddresses = nil
}
if (!project.hasProperty('mailMessage')) {
ext.mailMessage = nil
}
if (!project.hasProperty('mailEnableStartTLS')) {
ext.mailEnableStartTLS = true
}
if (!project.hasProperty('mailEnableSSL')) {
ext.mailEnableSSL = false
}
def mailParameters = [
mailhost: mailHost,
subject: mailSubject,
messagemimetype: mailMessageMimeType,
user: mailUser,
password: new String(mailPassword),
mailport: mailPort,
from: mailFrom,
tolist: mailToAddresses,
message: mailMessage,
enableStartTLS: mailEnableStartTLS,
ssl: mailEnableSSL
]
ant.mail( mailParameters ) {
}
}