Rework Kawa download and build tasks to be more Gradle'y
All Kawa-related downloads now use our existing VerifiedDownload task class. This gives us Gradle-integrated progress reporting, incremental build support, build caching, correct dependencies, etc. Using Kawa to compile Scheme into bytecode now also has proper dependency management, incremental build support, and build caching. Same goes for bundling these compiled bytecode files into jar archives for later use in regression tests. Also, when downloading kawa-chess, grab a specific commit hash rather than whatever is the most recent master commit. If this project changes in the future, we don't want our tests to break unexpectedly. Perhaps we'd want to pick up any new kawa-chess commits; perhaps not. Either way, that should be a conscious decision rather than something that can happen behind our backs.
This commit is contained in:
parent
8324a9cb56
commit
febf20145e
|
@ -3,5 +3,5 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'de.undercouch:gradle-download-task:3.4.1'
|
compile 'de.undercouch:gradle-download-task:3.4.3'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
buildscript {
|
|
||||||
repositories { mavenCentral() }
|
|
||||||
dependencies { classpath 'org.ajoberstar:gradle-git:0.2.3' }
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
}
|
}
|
||||||
|
@ -11,94 +6,90 @@ eclipse.project.natures 'org.eclipse.pde.PluginNature'
|
||||||
|
|
||||||
sourceSets.test.java.srcDirs = ['src']
|
sourceSets.test.java.srcDirs = ['src']
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// download and extract kawa 3.0 "kawa.jar"
|
// download and extract kawa 3.0 "kawa.jar"
|
||||||
//
|
//
|
||||||
|
|
||||||
task downloadKawa(type: Exec) {
|
task downloadKawa(type: VerifiedDownload) {
|
||||||
commandLine "wget", "ftp://ftp.gnu.org/pub/gnu/kawa/kawa-3.0.zip"
|
ext.version = '3.0'
|
||||||
workingDir "$temporaryDir"
|
final def archive = "kawa-${version}.zip"
|
||||||
def destination = file("$temporaryDir/kawa-3.0.zip")
|
src "https://ftp.gnu.org/pub/gnu/kawa/$archive"
|
||||||
enabled = !destination.exists() //to clone only once
|
dest "$temporaryDir/$archive"
|
||||||
|
checksum '2713e6dfb939274ba3b1d36daea68436'
|
||||||
}
|
}
|
||||||
|
|
||||||
task extractKawa(type: Copy, dependsOn: downloadKawa) {
|
task extractKawa(type: Sync, dependsOn: downloadKawa) {
|
||||||
from(zipTree("${downloadKawa.temporaryDir}/kawa-3.0.zip")) {
|
from(zipTree(downloadKawa.dest)) {
|
||||||
include "kawa-3.0/lib/kawa.jar"
|
include "kawa-${downloadKawa.version}/lib/kawa.jar"
|
||||||
eachFile {
|
eachFile {
|
||||||
relativePath new RelativePath(!directory, relativePath.lastName)
|
relativePath new RelativePath(!directory, relativePath.lastName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
into projectDir
|
into temporaryDir
|
||||||
includeEmptyDirs false
|
includeEmptyDirs false
|
||||||
outputs.file 'kawa.jar'
|
outputs.file "$temporaryDir/kawa.jar"
|
||||||
def destination = file('kawa.jar')
|
|
||||||
enabled = !destination.exists() //to clone only once
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task cleanExtractKawa(type: Delete) {
|
|
||||||
delete files(extractKawa)[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
clean.dependsOn cleanExtractKawa
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// build kawa chess
|
// specialized task for Kawa compilation into jar archive
|
||||||
//
|
//
|
||||||
import org.ajoberstar.gradle.git.tasks.*
|
|
||||||
|
|
||||||
task getKawaChess(type: GitClone) {
|
@CacheableTask
|
||||||
def destination = file("kawa-chess")
|
class CompileKawaJar extends Jar {
|
||||||
uri = "https://github.com/ttu-fpclub/kawa-chess"
|
|
||||||
destinationPath = destination
|
|
||||||
bare = false
|
|
||||||
enabled = !destination.exists() //to clone only once
|
|
||||||
}
|
|
||||||
|
|
||||||
task compileChessFiles(type: JavaExec) {
|
@Nested final def compile = project.task("compileKawaInto${name.capitalize()}", type: JavaExec) {
|
||||||
def kawaImg = file('kawa-chess/img.scm')
|
dependsOn(project.extractKawa)
|
||||||
def kawaPos = file('kawa-chess/pos.scm')
|
final def kawaJar = project.files(project.extractKawa)[0]
|
||||||
def kawaChess = file('kawa-chess/chess.scm')
|
|
||||||
def kawaGui = file('kawa-chess/gui.scm')
|
|
||||||
inputs.file kawaImg
|
|
||||||
inputs.file kawaPos
|
|
||||||
inputs.file kawaChess
|
|
||||||
inputs.file kawaGui
|
|
||||||
|
|
||||||
workingDir = file('kawa-chess')
|
|
||||||
|
|
||||||
def kawaJar = new File("kawa.jar")
|
|
||||||
inputs.file kawaJar
|
|
||||||
classpath kawaJar
|
classpath kawaJar
|
||||||
|
|
||||||
main 'kawa.repl'
|
main 'kawa.repl'
|
||||||
args '-C', 'img.scm', 'pos.scm', 'chess.scm', 'gui.scm'
|
|
||||||
|
args '-d', temporaryDir
|
||||||
|
outputs.dir temporaryDir
|
||||||
|
|
||||||
|
logging.captureStandardError LogLevel.INFO
|
||||||
|
args '--main', '-C'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileChessFiles.dependsOn extractKawa
|
CompileKawaJar() {
|
||||||
compileChessFiles.dependsOn getKawaChess
|
compile.dependsOn(dependsOn)
|
||||||
|
from compile
|
||||||
task compileChessMain(type: JavaExec, dependsOn: compileChessFiles) {
|
|
||||||
def kawaJar = new File("kawa.jar")
|
|
||||||
inputs.file kawaJar
|
|
||||||
classpath kawaJar
|
|
||||||
|
|
||||||
workingDir = file("kawa-chess")
|
|
||||||
|
|
||||||
def kawaMain = file('kawa-chess/main.scm')
|
|
||||||
inputs.file kawaMain
|
|
||||||
|
|
||||||
main 'kawa.repl'
|
|
||||||
args '--main', '-C', 'main.scm'
|
|
||||||
}
|
|
||||||
|
|
||||||
task buildChessJar(type: Jar, dependsOn: compileChessMain) {
|
|
||||||
from file('kawa-chess')
|
|
||||||
baseName 'kawachess'
|
|
||||||
version null
|
version null
|
||||||
destinationDir projectDir
|
}
|
||||||
|
|
||||||
|
void setArgs(Object... args) {
|
||||||
|
compile.args args
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// download, unpack, and build kawa chess
|
||||||
|
//
|
||||||
|
|
||||||
|
task downloadKawaChess(type: VerifiedDownload) {
|
||||||
|
ext.commitHash = 'f1d2dcc707a1ef19dc159e2eaee5aecc8a41d7a8'
|
||||||
|
src "https://github.com/ttu-fpclub/kawa-chess/archive/${commitHash}.zip"
|
||||||
|
dest "$temporaryDir/kawa-chess.zip"
|
||||||
|
checksum 'cf29613d2be5f476a475ee28b4df9d9e'
|
||||||
|
}
|
||||||
|
|
||||||
|
task unpackKawaChess(type: Sync, dependsOn: downloadKawaChess) {
|
||||||
|
from zipTree(downloadKawaChess.dest)
|
||||||
|
into temporaryDir
|
||||||
|
ext.top = "$destinationDir/kawa-chess-${downloadKawaChess.commitHash}"
|
||||||
|
}
|
||||||
|
|
||||||
|
task buildChessJar(type: CompileKawaJar, dependsOn: unpackKawaChess) {
|
||||||
|
final def schemePath = { "$unpackKawaChess.top/${it}.scm" }
|
||||||
|
final def schemeFiles = files(['chess', 'gui', 'img', 'main', 'pos'].collect(schemePath))
|
||||||
|
args schemePath('main')
|
||||||
|
inputs.files schemeFiles
|
||||||
|
baseName 'kawachess'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,25 +98,11 @@ task buildChessJar(type: Jar, dependsOn: compileChessMain) {
|
||||||
// build the kawa test jar
|
// build the kawa test jar
|
||||||
//
|
//
|
||||||
|
|
||||||
task compileKawaTestMain(type: JavaExec, dependsOn: extractKawa) {
|
task buildKawaTestJar(type: CompileKawaJar) {
|
||||||
def kawaJar = new File("kawa.jar")
|
final def schemeFile = file('kawasrc/test.scm')
|
||||||
inputs.file kawaJar
|
args schemeFile
|
||||||
classpath kawaJar
|
inputs.files schemeFile
|
||||||
|
|
||||||
workingDir file('kawasrc')
|
|
||||||
|
|
||||||
def kawaMain = file('kawasrc/test.scm')
|
|
||||||
inputs.file kawaMain
|
|
||||||
|
|
||||||
main 'kawa.repl'
|
|
||||||
args '--main', '-C', 'test.scm'
|
|
||||||
}
|
|
||||||
|
|
||||||
task buildKawaTestJar(type: Jar, dependsOn: compileKawaTestMain) {
|
|
||||||
from file('kawasrc')
|
|
||||||
baseName 'kawatest'
|
baseName 'kawatest'
|
||||||
version null
|
|
||||||
destinationDir projectDir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue