/
build.gradle
131 lines (104 loc) · 2.29 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
/*
* Packs metadata generator in a .tgz file in ~/dist folder
* To build .tgz
* gradlew packmg
* To build jar
* gradlew jarmg
*/
apply plugin: "java"
sourceCompatibility = 1.6
targetCompatibility = 1.6
def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
sourceSets {
main {
java {
srcDir 'src/src'
}
}
main.output.classesDir = "$rootDir/dist/classes"
}
dependencies {
compile files("./src/libs/bcel-5.2.jar")
compile files("./src/libs/dx.jar")
}
task makeDistDir {
def distDir = new File("$rootDir/dist")
distDir.mkdirs()
}
task cleanDist (type: Delete) {
delete "$rootDir/dist"
}
task cleanDistForJar (type: Delete) {
delete "$rootDir/dist"
}
task cleanBuildDir (type: Delete){
delete "$rootDir/build"
}
task cleanBuildDirForJar (type: Delete){
delete "$rootDir/build"
}
task cleanBin (type: Delete) {
delete "$rootDir/src/bin"
}
task copyNecessaryFiles {
doLast {
copy {
from "$rootDir/helpers"
into "$rootDir/dist/bin"
}
copy {
from "$rootDir/package.json"
into "$rootDir/dist"
}
}
}
task packMetadataGenerator (type: Exec) {
workingDir "$rootDir/dist"
if(isWinOs) {
commandLine "cmd", "/c", "npm", "pack"
}
else {
commandLine "npm", "pack"
}
}
jar {
manifest {
attributes("Manifest-Version": "1.0",
"Main-Class": "com.telerik.metadata.Generator")
}
from {
configurations.runtime.collect {
it.isDirectory() ? it : zipTree(it)
}
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
task copyJarToDist (type: Copy) {
from "$rootDir/build/libs/android-metadata-generator.jar"
into "$rootDir/dist"
}
makeDistDir.dependsOn(cleanDist)
cleanBin.dependsOn(makeDistDir)
compileJava.dependsOn(cleanBin)
cleanBuildDir.dependsOn(compileJava)
copyNecessaryFiles.dependsOn(cleanBuildDir)
packMetadataGenerator.dependsOn(copyNecessaryFiles)
task packmg {
dependsOn packMetadataGenerator
}
cleanDistForJar.dependsOn(jar)
copyJarToDist.dependsOn(cleanDistForJar)
cleanBuildDirForJar.dependsOn(copyJarToDist)
task jarmg {
dependsOn cleanBuildDirForJar
}