-
Notifications
You must be signed in to change notification settings - Fork 14
/
processing-library.gradle
154 lines (131 loc) · 4.22 KB
/
processing-library.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
// This script adds processing library build support to gradle.
def releaseRoot = "$rootDir/release"
def releaseName = "$outputName$outputNamePostfix-$version"
def releaseDirectory = "$releaseRoot/$releaseName"
def processingVersion = generateProcessingVersion("$version").toString()
static def generateProcessingVersion(String version) {
def tokens = version.split('\\.')
def sum = 0
def count = 1
for (String token : tokens.reverse()) {
try {
def value = token as Double
sum += value * count
count *= 100
} catch (ignored) {
}
}
return sum.toInteger()
}
task releaseProcessingLib {
dependsOn {
clean
build
javadoc
if (project.hasProperty("disable-fatjar")) {
jar
} else {
fatJar
}
}
finalizedBy 'packageRelease', 'renameRelease'
doFirst {
println "releasing library $outputName..."
// printing current jvm
def currentJvm = org.gradle.internal.jvm.Jvm.current()
println currentJvm
println("cleaning release...")
project.delete(files(
"$releaseDirectory",
"$releaseRoot/${releaseName}.zip",
"$releaseRoot/${releaseName}.txt"
))
}
doLast {
println "creating package..."
if (project.hasProperty("disable-fatjar")) {
println "copy library..."
project.copy {
from "$buildDir/libs/${outputName}.jar"
into "$releaseDirectory/library"
}
println "copy dependencies..."
project.copy {
from configurations.runtimeClasspath
into "$releaseDirectory/library"
}
// Need to delete the Processing jar explicilty, at least when including them as fileTree dependencies
delete "$releaseDirectory/library/core.jar"
delete "$releaseDirectory/library/jogl-all-main.jar"
delete "$releaseDirectory/library/gluegen-rt-main.jar"
} else {
println "copy fatjar library..."
project.copy {
from "$buildDir/libs/$outputName-complete.jar"
into "$releaseDirectory/library"
rename "$outputName-complete.jar", "${outputName}.jar"
}
}
println "copy assets (only if necessary)..."
project.copy {
from("$rootDir") {
include "shaders/**",
"native/**"
}
into "$releaseDirectory/library"
exclude "*.DS_Store"
}
/*
println "copy data..."
project.copy {
from "data"
into "$releaseDirectory/library"
}
*/
println "copy javadoc..."
project.copy {
from "$buildDir/docs/javadoc"
into "$releaseDirectory/reference"
}
println "copy additional files..."
project.copy {
from("$rootDir") {
include "README.md",
"readme/**",
"examples/**",
"src/**"
}
into "$releaseDirectory"
exclude "*.DS_Store", "**/networks/**"
}
println "copy library properties..."
project.copy {
from("$rootDir") {
include "library.properties"
}
into "$releaseDirectory"
exclude "*.DS_Store"
filter {
it.replace('${version}', "$processingVersion")
.replace('${prettyVersion}', "$project.version")
}
}
println "copy repository library.txt..."
project.copy {
from "$releaseDirectory/library.properties"
into "$releaseRoot"
rename "library.properties", "${outputName}.txt"
}
}
}
task packageRelease(type: Zip) {
mustRunAfter releaseProcessingLib
archiveFileName = "${outputName}${outputNamePostfix}.zip"
from "$releaseDirectory"
into "$outputName"
destinationDirectory = file("$releaseRoot")
exclude "**/*.DS_Store"
}
task renameRelease {
mustRunAfter packageRelease
}