-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
137 lines (117 loc) · 3.59 KB
/
build.gradle
File metadata and controls
137 lines (117 loc) · 3.59 KB
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
def pluginName="SAP-CTS"
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
compile 'com.ibm.urbancode.plugins:groovy-plugin-utils:+'
compile 'com.ibm.urbancode.util:i18n-scraper:+'
compile group: 'commons-codec', name: 'commons-codec', version: '1.5'
compile group: 'org.codehaus.jettison', name: 'jettison', version: '1.1'
compile 'com.ibm.urbancode.commons:CommonsUtil:+'
// This compiles the i18n-scraper script
compile 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-codec")
}
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-codec")
}
into 'lib'
}
}
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'
}
archiveName = "${pluginName}-dev.zip"
}
task gatherI18n(type: JavaExec) {
delete buildLocaleDir
mkdir buildLocaleDir
main = '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
}