-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
153 lines (129 loc) · 3.96 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
/**
* (c) 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.
*/
import org.apache.tools.ant.filters.ReplaceTokens
String pluginName = "IBM-MQ-zOS-UCD"
String pluginVersion
if (project.hasProperty('pluginVersion')) {
pluginVersion = project.getProperty('pluginVersion')
} else {
def pluginNode = new XmlParser().parse(new File('src/main/zip/plugin.xml'))
pluginVersion = "${pluginNode.header.identifier.@version[0]}.dev"
}
apply plugin: 'groovy'
defaultTasks("dist")
def buildLocaleDir = 'build/locale'
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:+'
// This compiles the i18n-scraper script
implementation localGroovy()
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
}
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', 'copyDeps'
}
compileGroovy {
include "i18n-scraper.groovy"
}
tasks.register('copyDeps', Copy) {
into 'lib'
copy {
from configurations.runtimeClasspath
include { target ->
return target.file.path.contains("com.ibm.urbancode")
}
into 'lib'
rename { fileName ->
stripVersion(fileName)
}
}
copy {
from configurations.runtimeClasspath
exclude { target ->
return target.file.path.contains("com.ibm.urbancode")
}
into 'lib'
}
}
tasks.register('extractGPU', Copy) {
def zipFile = file('lib/groovy-plugin-utils.jar')
def outputDir = file("${buildDir}/util")
from zipTree(zipFile)
into outputDir
}
tasks.register('copyi18n', Copy) {
def i18nFile = file('lib/i18n-scraper.groovy')
def outputDir = file("${buildDir}/util")
from i18nFile
into outputDir
}
tasks.register('dist', Zip) {
dependsOn('compileGroovy', 'gatherI18n')
from(sourceSets.zip.groovy.srcDirs) {
filter(ReplaceTokens, tokens: [RELEASE_VERSION: pluginVersion])
}
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}-${pluginVersion}.zip"
}
tasks.register('gatherI18n', JavaExec) {
delete buildLocaleDir
mkdir buildLocaleDir
main = 'i18n-scraper'
args 'build/locale/en.properties'
classpath = sourceSets.main.runtimeClasspath
}
tasks.register('cleanAll') {
dependsOn('clean', 'cleanCopyDeps', 'cleanDistPlugin', 'cleanGatherI18n')
}
static String stripVersion(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
}