-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-release.gradle
176 lines (146 loc) · 6.02 KB
/
build-release.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import groovy.io.FileType
import java.text.SimpleDateFormat
class C64Overlay extends DefaultTask {
@Input
def releaseBuildDir;
@Input
def overlayTempDir;
@TaskAction()
def create(IncrementalTaskInputs inputs) throws FileNotFoundException {
logger.quiet("Executes")
if (null != releaseBuildDir) {
def ovrname = 'c64'
def files = []
("$releaseBuildDir/C64lite/Scripts" as File).eachFile FileType.FILES, {
files << it
}
def result = files.sort { a, b -> b.lastModified() <=> a.lastModified() }.first().lastModified()
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd")
def overlayVersion = dateFormat.format(new Date(result))
def ovr = "${ovrname}.overlay.${overlayVersion}"
("$releaseBuildDir/C64lite/Settings.cfg" as File).withWriter('UTF-8') { writer ->
writer.write("overlay_version=$overlayVersion")
}
logger.quiet("OVR=${ovr}")
// create new work directories
def c64OverlayTempDir = "${overlayTempDir}/${ovr}"
new File(c64OverlayTempDir).mkdirs()
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "README.TXT")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "*.sh")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "*.js")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "*conf*")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "*prop*")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "*.cfg")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "*.ini")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "*rc")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "includes")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "jsidplay.jar")
cp("$releaseBuildDir/C64lite/Scripts/", "$c64OverlayTempDir/Scripts", "jswingc64.jar")
cp("$releaseBuildDir/C64lite/Gfx/", "$c64OverlayTempDir/Gfx", "*.png")
cp("$releaseBuildDir/C64lite", "$c64OverlayTempDir", "GameEmulators.ini")
cp("$releaseBuildDir/C64lite", "$c64OverlayTempDir", "MusicEmulators.ini")
zipIt(overlayTempDir, ovr, "$releaseBuildDir/Overlays")
new File(c64OverlayTempDir).deleteDir()
}
}
def cp(from, to, includePattern) {
new groovy.util.AntBuilder().copy(todir: to) {
fileset(dir: from) {
include(name: includePattern)
include(name: includePattern.toUpperCase())
}
}
}
def zipIt(overlayTempDir, overlayDirName, outputDir) {
new groovy.util.AntBuilder().with {
new File(overlayTempDir).eachDir {dir->
zip destfile: "${outputDir}/${dir.name}.zip", {
fileset dir: dir
}
}
}
}
def delDir(dir) {
new groovy.util.AntBuilder().delete(dir:dir,failonerror:false)
}
}
class HomepageAndDocs extends DefaultTask {
@Input
def releaseBuildDir;
@Input
def docsTempDir
@TaskAction()
def create(IncrementalTaskInputs inputs) {
new File(docsTempDir).mkdirs()
downloadRebel('http://www.rebol.com/downloads/v278/rebol-core-278-4-3.tar.gz', "${docsTempDir}/rebol-core-278-4-3.tar.gz")
unpack("${docsTempDir}/rebol-core-278-4-3.tar.gz", docsTempDir)
genrateRebol("${docsTempDir}/releases/rebol-core")
}
def downloadRebel(remoteUrl, localUrl) {
new File("$localUrl").withOutputStream { out ->
new URL(remoteUrl).withInputStream { from -> out << from; }
}
}
def unpack(fileLocation, destination) {
new groovy.util.AntBuilder().untar(src:fileLocation,
compression: 'gzip',
dest:destination,
overwrite:"false" )
}
def genrateRebol(workDir) {
executeOnShell('ls', workDir)
}
def executeOnShell(String command, workDir) {
return executeOnShell(command, new File(workDir))
}
def executeOnShell(String command, File workingDir) {
println command
def process = new ProcessBuilder(addShellPrefix(command))
.directory(workingDir)
.redirectErrorStream(true)
.start()
process.inputStream.eachLine {println it}
process.waitFor();
return process.exitValue()
}
def addShellPrefix(String command) {
def commandArray = new String[3]
commandArray[0] = "sh"
commandArray[1] = "-c"
commandArray[2] = command
return commandArray
}
}
def releaseResourcesG = '../JGameBase-bin/release_resources'
def releaseBuildDirG = "$rootDir/build/output"
task runJsDoc(dependsOn: jar) {
javaexec {
main = "-jar";
args = [
"${rootDir}/src_ressources/jsdoc/jsrun.jar",
"${rootDir}/src_ressources/jsdoc/app/run.js",
"-a",
"-d=${buildDir}/jsdoc",
"-t=${rootDir}/src_ressources/jsdoc/templates/jsdoc",
"${rootDir}/main/resources/bin/Includes/includes.js"
]
}
}
task copyBin(type: Copy) {
from "$releaseResourcesG/C64lite"
into "$releaseBuildDirG/C64lite"
}
task createC64LiteOverlay(type: C64Overlay) {
releaseBuildDir = releaseBuildDirG
overlayTempDir = "$rootDir/build/overlayTemp"
}
task createHomePageAndDocs(type: HomepageAndDocs) {
releaseBuildDir = releaseBuildDirG
docsTempDir = "$rootDir/build/docsTempDir"
}
task performRelease(dependsOn: copyBin) {
group = 'JGameBase release'
description = "Perform release of JGameBase"
}
performRelease.finalizedBy createC64LiteOverlay
performRelease.finalizedBy createHomePageAndDocs