-
Notifications
You must be signed in to change notification settings - Fork 2
/
processing-library.gradle
148 lines (125 loc) · 4.92 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
// This script adds processing library build support to gradle.
def releaseRoot = "$rootDir/release"
def releaseName = "$projectName-$version"
def releaseDirectory = "$releaseRoot/$releaseName"
task releaseProcessingLib {
dependsOn {
clean
build
javadoc
jar
}
finalizedBy 'packageRelease', 'renameRelease'
doFirst {
println "releasing library $projectName..."
// printing current jvm
def currentJvm = org.gradle.internal.jvm.Jvm.current()
println currentJvm
// if (project.hasProperty("cuda")) {
// println "CUDA support enabled!"
// }
println("cleaning release...")
project.delete(files(
"$releaseDirectory",
"$releaseRoot/${releaseName}.zip",
"$releaseRoot/${releaseName}.txt"
))
}
doLast {
println "creating package..."
println "copy library..."
project.copy {
from "$buildDir/libs/${projectName}.jar"
into "$releaseDirectory/library"
}
println "copy dependencies..."
project.copy {
from configurations.runtimeClasspath
into "$releaseDirectory/library"
}
// Need to delete the Processing jar explicitly, 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"
println "copy libraries..."
project.copy {
from("$releaseDirectory/library") {
include "*.jar"
}
into "libs"
exclude "${projectName}.jar"
}
println "copy assets (only if necessary)..."
project.copy {
from("$rootDir") {
include "shaders/**",
"native/**"
}
into "$releaseDirectory/library"
exclude "*.DS_Store"
}
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 repository library.txt..."
copyProperties("$releaseRoot", "${projectName}.txt")
println "copy repository library.properties..."
copyProperties("$releaseDirectory", "library.properties")
if (project.hasProperty("sketchbookLocation")) {
println "copy to sketchbook..."
def sketchbookAbsolutePath = sketchbookLocation.replace("\${user.home}", System.properties['user.home'])
def installDirectory = "$sketchbookAbsolutePath/libraries/$projectName"
project.copy {
from("$releaseDirectory") {
include "library.properties",
"examples/**",
"library/**",
"reference/**",
"src/**"
}
into "$installDirectory"
}
}
}
ext.copyProperties = { destDirectory, destFilename ->
project.copy {
from "$rootDir/library.properties"
into "$destDirectory"
rename "library.properties", "$destFilename"
filter { String line -> line.replaceAll("name=", "name=$propertiesName") }
filter { String line -> line.replaceAll("category=", "category=$propertiesCategory") }
filter { String line -> line.replaceAll("authors=", "authors=$propertiesAuthors") }
filter { String line -> line.replaceAll("url=", "url=$propertiesUrl") }
filter { String line -> line.replaceAll("sentence=", "sentence=$propertiesSentence") }
filter { String line -> line.replaceAll("paragraph=", "paragraph=$propertiesParagraph") }
filter { String line -> line.replaceAll("version=", "version=$propertiesVersion") }
filter { String line -> line.replaceAll("prettyVersion=", "prettyVersion=$propertiesPrettyVersion") }
filter { String line -> line.replaceAll("minRevision=", "minRevision=$propertiesMinRevision") }
filter { String line -> line.replaceAll("maxRevision=", "maxRevision=$propertiesMaxRevision") }
}
}
}
task packageRelease(type: Zip) {
mustRunAfter releaseProcessingLib
archiveFileName = "${projectName}.zip"
from "$releaseDirectory"
into "$projectName"
destinationDirectory = file("$releaseRoot")
exclude "**/*.DS_Store"
}
task renameRelease {
mustRunAfter packageRelease
}