-
Notifications
You must be signed in to change notification settings - Fork 5
/
processing-library.gradle
159 lines (133 loc) · 5.27 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
155
156
157
158
159
// This script adds processing library build support to gradle.
def releaseRoot = "$rootDir/release"
def releaseName = "$libName-$version"
def releaseDirectory = "$releaseRoot/$releaseName"
// Replace the properties in the source files
task processSource(type: Sync) {
from sourceSets.main.java
filter { String line -> line.replaceAll("##library.prettyVersion##", "$libPrettyVersion") }
filter { String line -> line.replaceAll("##library.name##", "$libName") }
filter { String line -> line.replaceAll("##author##", "$libAuthors") }
into "$buildDir/src"
}
compileJava {
source = processSource.outputs
}
task releaseProcessingLib {
dependsOn {
clean
build
javadoc
jar
}
finalizedBy 'packageRelease', 'renameRelease'
doFirst {
println "releasing library $libName..."
// Printing current jvm to the console
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..."
println "copy library..."
project.copy {
from "$buildDir/libs/${libName}.jar"
into "$releaseDirectory/library"
}
println "copy dependencies..."
project.copy {
from configurations.runtimeClasspath
into "$releaseDirectory/library"
}
// Need to delete the Processing jars explicitly, at least when including them as fileTree dependencies
for (lib in includeDeps) {
delete "$releaseDirectory/library/$lib"
}
println "Copy libraries..."
project.copy {
from("$releaseDirectory/library") {
include "*.jar"
}
into "libs"
}
println "Copy assets..."
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", "${libName}.txt")
println "Copy repository library.properties..."
copyProperties("$releaseDirectory", "library.properties")
if (project.hasProperty("sketchbookLocation")) {
println "Copy to sketchbook..."
def installDirectory = "$sketchbookLocation/libraries/$libName"
project.copy {
from("$releaseDirectory") {
include "library.properties",
"examples/**",
"library/**",
"reference/**",
"src/**"
}
into "$installDirectory"
}
}
}
ext.copyProperties = { destDirectory, destFilename ->
project.copy {
from "$rootDir/resources/library.properties"
into "$destDirectory"
rename "library.properties", "$destFilename"
// First remove comment or empty lines
filter { String line -> return line.startsWith("#") || !line.strip() ? null : line }
filter { String line -> line.replaceAll("name=##library.name##", "name=$libPrettyName") }
filter { String line -> line.replaceAll("authors=##library.authorList##", "authors=$libAuthors") }
filter { String line -> line.replaceAll("url=##library.url##", "url=$libUrl") }
filter { String line -> line.replaceAll("categories=##library.categories##", "category=$libCategory") }
filter { String line -> line.replaceAll("sentence=##library.sentence##", "sentence=$libSentence") }
filter { String line -> line.replaceAll("paragraph=##library.paragraph##", "paragraph=$libParagraph") }
filter { String line -> line.replaceAll("version=##library.version##", "version=$libVersion") }
filter { String line -> line.replaceAll("prettyVersion=##library.prettyVersion##", "prettyVersion=$libPrettyVersion") }
filter { String line -> line.replaceAll("minRevision=##compatible.minRevision##", "minRevision=$compMinRevision") }
filter { String line -> line.replaceAll("maxRevision=##compatible.maxRevision##", "maxRevision=$compMaxRevision") }
}
}
}
task packageRelease(type: Zip) {
mustRunAfter releaseProcessingLib
archiveFileName = "${libName}.zip"
from "$releaseDirectory"
into "$libName"
destinationDirectory = file("$releaseRoot")
exclude "**/*.DS_Store"
}
task renameRelease {
mustRunAfter packageRelease
}