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
|
@Nested final def compile = project.task("compileKawaInto${name.capitalize()}", type: JavaExec) {
|
||||||
bare = false
|
dependsOn(project.extractKawa)
|
||||||
enabled = !destination.exists() //to clone only once
|
final def kawaJar = project.files(project.extractKawa)[0]
|
||||||
|
classpath kawaJar
|
||||||
|
main 'kawa.repl'
|
||||||
|
|
||||||
|
args '-d', temporaryDir
|
||||||
|
outputs.dir temporaryDir
|
||||||
|
|
||||||
|
logging.captureStandardError LogLevel.INFO
|
||||||
|
args '--main', '-C'
|
||||||
|
}
|
||||||
|
|
||||||
|
CompileKawaJar() {
|
||||||
|
compile.dependsOn(dependsOn)
|
||||||
|
from compile
|
||||||
|
version null
|
||||||
|
}
|
||||||
|
|
||||||
|
void setArgs(Object... args) {
|
||||||
|
compile.args args
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task compileChessFiles(type: JavaExec) {
|
|
||||||
def kawaImg = file('kawa-chess/img.scm')
|
|
||||||
def kawaPos = file('kawa-chess/pos.scm')
|
|
||||||
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')
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// download, unpack, and build kawa chess
|
||||||
|
//
|
||||||
|
|
||||||
def kawaJar = new File("kawa.jar")
|
task downloadKawaChess(type: VerifiedDownload) {
|
||||||
inputs.file kawaJar
|
ext.commitHash = 'f1d2dcc707a1ef19dc159e2eaee5aecc8a41d7a8'
|
||||||
classpath kawaJar
|
src "https://github.com/ttu-fpclub/kawa-chess/archive/${commitHash}.zip"
|
||||||
|
dest "$temporaryDir/kawa-chess.zip"
|
||||||
main 'kawa.repl'
|
checksum 'cf29613d2be5f476a475ee28b4df9d9e'
|
||||||
args '-C', 'img.scm', 'pos.scm', 'chess.scm', 'gui.scm'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compileChessFiles.dependsOn extractKawa
|
task unpackKawaChess(type: Sync, dependsOn: downloadKawaChess) {
|
||||||
compileChessFiles.dependsOn getKawaChess
|
from zipTree(downloadKawaChess.dest)
|
||||||
|
into temporaryDir
|
||||||
task compileChessMain(type: JavaExec, dependsOn: compileChessFiles) {
|
ext.top = "$destinationDir/kawa-chess-${downloadKawaChess.commitHash}"
|
||||||
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) {
|
task buildChessJar(type: CompileKawaJar, dependsOn: unpackKawaChess) {
|
||||||
from file('kawa-chess')
|
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'
|
baseName 'kawachess'
|
||||||
version null
|
|
||||||
destinationDir projectDir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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