forked from UrbanCode/Plugin-Template-UCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
92 lines (80 loc) · 2.26 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
/* 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']
* }
* }
* }
*/
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'groovy'
defaultTasks 'distPlugin'
def buildLocaleDir = 'build/locale'
configurations {
// Remove the groovy-all jar from runtime dependencies
runtime.exclude module: 'groovy-all'
}
repositories {
mavenCentral()
}
dependencies {
// groovy-plugin-utils pulls down groovy-all as a transitive dependency for the 'compile' configuration
compile 'com.ibm.urbancode.plugins:groovy-plugin-utils:1.0'
// 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', 'src/main/util']
}
}
}
task copyDeps(type: Copy) {
from configurations.runtime
into 'lib'
}
task distPlugin(type: Zip, dependsOn: ['compileGroovy', 'gatherI18n']) {
def releaseVersion = apiVersion + "." + pluginVersion
from(sourceSets.main.groovy.srcDirs) {
filter(ReplaceTokens, tokens: [API_VERSION: apiVersion, RELEASE_VERSION: releaseVersion])
}
into('lib') {
from copyDeps
}
into('locale') {
from buildLocaleDir
}
archiveName = "${pluginName}-${releaseVersion}.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'])