forked from UrbanCode/Send-SMTP-Email-UCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
184 lines (161 loc) · 4.76 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/**
* © Copyright IBM Corporation 2017.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/* The Groovy plugin for Gradle assumes the following layout
* src/main/java
* src/main/resources
* src/main/groovy
*
* src/test/java
* src/test/resources
* src/test/groovy
*
* src/<sourceSet>/java
* src/<sourceSet>/resources
* src/<sourceSet>/groovy
*
* You can override or create a new sourceSet with the following snippet:
*
* sourceSets {
* main {
* // We can override src/main/groovy to also add src/main/zip
* groovy {
* srcDirs = ['src/main/groovy', 'src/main/zip']
* }
* }
* mySourceSet {
* groovy {
* srcDirs = ['src/myDir/groovy']
* }
* }
* }
*/
def pluginName="smtp-email-open"
apply plugin: 'groovy'
defaultTasks 'distPlugin'
def buildLocaleDir = 'build/locale'
def buildUtilDir = 'build/util'
configurations {
// Remove the groovy-all jar from runtime dependencies
runtime.exclude module: 'groovy-all'
}
repositories {
mavenCentral()
maven {
url "https://public.dhe.ibm.com/software/products/UrbanCode/maven2/"
}
}
dependencies {
// groovy-plugin-utils pulls down groovy-all as a transitive dependency for the 'compile' configuration
implementation 'com.ibm.urbancode.plugins:groovy-plugin-utils:+'
implementation 'com.ibm.urbancode.util:i18n-scraper:+'
implementation 'com.ibm.urbancode.commons:uDeployRestClient:+'
implementation 'javax.mail:mail:1.4.1'
implementation 'javax.activation:activation:1.1.1'
// This compiles the i18n-scraper script
implementation localGroovy()
// compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3.6'
// testCompile group: 'junit', name: 'junit', version: '4.11'
}
sourceSets {
main {
groovy {
srcDirs = ['src/main/groovy', 'src/main/zip', "${buildDir}/util"]
}
}
zip {
groovy {
srcDirs = ['src/main/zip']
}
}
classes {
groovy {
srcDirs = ['src/main/groovy', "${buildDir}/util"]
}
}
}
compileJava {
dependsOn 'extractGPU', 'copyi18n'
}
compileGroovy {
include "i18n-scraper.groovy"
// exclude '*.groovy'
// exclude 'com/**'
}
task copyDeps(type: Copy) {
into 'lib'
copy {
from configurations.runtime
include { target ->
return target.file.path.contains("com.ibm.urbancode") ||
target.file.path.contains("commons-lang")
}
into 'lib'
rename { fileName ->
stripVersion(fileName)
}
}
copy {
from configurations.runtime
exclude { target ->
return target.file.path.contains("com.ibm.urbancode") ||
target.file.path.contains("commons-lang")
}
into 'lib'
rename { fileName ->
renameMailJar(fileName)
}
}
}
task extractGPU(type: Copy) {
def zipFile = file('lib/groovy-plugin-utils.jar')
def outputDir = file("${buildDir}/util")
from zipTree(zipFile)
into outputDir
}
task copyi18n(type: Copy) {
def i18nFile = file('lib/i18n-scraper.groovy')
def outputDir = file("${buildDir}/util")
from i18nFile
into outputDir
}
task distPlugin(type: Zip, dependsOn: ['compileGroovy', 'gatherI18n']) {
from(sourceSets.zip.groovy.srcDirs)
into('lib') {
from copyDeps
exclude 'i18n-scraper.groovy'
exclude 'groovy-plugin-utils.jar'
exclude 'groovy-all-*.jar'
exclude 'gson-*.jar'
}
into('locale') {
from buildLocaleDir
}
into('classes') {
from sourceSets.classes.groovy.srcDirs
exclude 'META-INF', 'i18n-scraper.groovy'
}
archiveFileName = "${pluginName}-3.zip"
}
task gatherI18n(type: JavaExec) {
delete buildLocaleDir
mkdir buildLocaleDir
mainClass = 'i18n-scraper'
args 'build/locale/en.properties'
classpath = sourceSets.main.runtimeClasspath
}
task cleanAll(dependsOn: ['clean', 'cleanCopyDeps', 'cleanDistPlugin', 'cleanGatherI18n'])
String stripVersion(String fileNameWithVersion) {
String ext = fileNameWithVersion.substring(fileNameWithVersion.lastIndexOf("."),fileNameWithVersion.length())
int end = fileNameWithVersion.lastIndexOf("-"); //assumes that: name-version.ext. Will not work with name-version-SNAPSHOT.ext
return fileNameWithVersion.substring(0, end) + ext
}
String renameMailJar(String fileName) {
if (fileName.startsWith("mail-")) {
return fileName.replace("mail-", "javamail-")
}
return fileName
}