Merge pull request #338 from liblit/kawa-gradle-improvements
Improvements for Kawa- and JNI-related Gradle build tasks
This commit is contained in:
commit
be7b0deb5f
|
@ -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'
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,15 @@ model {
|
||||||
|
|
||||||
// all combined as a colon-delimited path list
|
// all combined as a colon-delimited path list
|
||||||
args pathElements.join(':')
|
args pathElements.join(':')
|
||||||
|
|
||||||
|
// log output to file, although we don't validate it
|
||||||
|
final def outFile = file("$temporaryDir/stdout-and-stderr.log")
|
||||||
|
outputs.file outFile
|
||||||
|
doFirst {
|
||||||
|
final def fileStream = new FileOutputStream(outFile)
|
||||||
|
standardOutput fileStream
|
||||||
|
errorOutput fileStream
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check.dependsOn checkSmoke_main
|
check.dependsOn checkSmoke_main
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/kawa-chess/
|
|
@ -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'
|
|
||||||
}
|
|
||||||
|
|
||||||
compileChessFiles.dependsOn extractKawa
|
args '-d', temporaryDir
|
||||||
compileChessFiles.dependsOn getKawaChess
|
outputs.dir temporaryDir
|
||||||
|
|
||||||
task compileChessMain(type: JavaExec, dependsOn: compileChessFiles) {
|
logging.captureStandardError LogLevel.INFO
|
||||||
def kawaJar = new File("kawa.jar")
|
args '--main', '-C'
|
||||||
inputs.file kawaJar
|
}
|
||||||
classpath kawaJar
|
|
||||||
|
|
||||||
workingDir = file("kawa-chess")
|
CompileKawaJar() {
|
||||||
|
compile.dependsOn(dependsOn)
|
||||||
def kawaMain = file('kawa-chess/main.scm')
|
from compile
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,22 +270,3 @@ task cleanColllectTestDataA(type: Delete) {
|
||||||
}
|
}
|
||||||
|
|
||||||
clean.dependsOn cleanCollectTestDataA
|
clean.dependsOn cleanCollectTestDataA
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// help Eclipse build these extra jars when needed
|
|
||||||
//
|
|
||||||
|
|
||||||
afterEclipseBuildshipImport {
|
|
||||||
dependsOn(
|
|
||||||
collectJLex,
|
|
||||||
collectTestData,
|
|
||||||
collectTestDataA,
|
|
||||||
downloadJavaCup,
|
|
||||||
extractBcel,
|
|
||||||
generateHelloHashJar,
|
|
||||||
buildChessJar,
|
|
||||||
buildKawaTestJar,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue