Skip to content

Commit

Permalink
Fixed web copy task
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Sep 26, 2019
1 parent d88bedb commit cc45a67
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
26 changes: 21 additions & 5 deletions build.gradle
Expand Up @@ -4,9 +4,10 @@ plugins {
}



ext.architecture = "linux-x86_64" // TODO make adjustable
ext.toolDir = "$buildDir/tools"
ext.dataDir = file('data', PathValidation.DIRECTORY)
ext.xmlDir = file('data/xml', PathValidation.DIRECTORY)



Expand Down Expand Up @@ -59,18 +60,21 @@ dependencies {
}


task getTools(type: Copy) {
task installTools(type: Copy) {
description "Installs SlimerJS and Firefox"
configurations.tools.asFileTree.each {
from(tarTree(it))
}
into toolDir
outputs.dir(toolDir)
}

task generateSVGs(type: JavaExec) {
dependsOn getTools
description "Generates SVGs of diplomatic transcripts and overlays"
dependsOn installTools
dependsOn classes

inputs.dir("$dataDir/xml/transcript")
inputs.dir("$xmlDir/transcript")
outputs.dir("$buildDir/www/transcript")

environment 'LANG', 'en_US.UTF-8'
Expand All @@ -86,7 +90,19 @@ task generateSVGs(type: JavaExec) {
classpath sourceSets.main.runtimeClasspath
main 'net.faustedition.gen.DiplomaticConversion'
}
build.dependsOn generateSVGs

task copyWeb(type: CopyWithSymlink) {
description "Copy the web page sources"
from fileTree("src/main/web")
into "$buildDir/www"
}

task copySource(type: CopyWithSymlink) {
from xmlDir
into "$buildDir/www/xml"
}

build.dependsOn generateSVGs, copyWeb, copySource


task showProps { doLast {
Expand Down
25 changes: 25 additions & 0 deletions buildSrc/src/main/groovy/CopyWithSymlink.groovy
@@ -0,0 +1,25 @@
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths

import org.gradle.api.tasks.Copy

class CopyWithSymlink extends Copy {
public CopyWithSymlink() {
super();
eachFile { details ->
Path sourcePath = FileSystems.getDefault().getPath(details.file.path)
if(Files.isSymbolicLink(sourcePath)) {
details.exclude()
Path destinationPath = Paths.get("${destinationDir}/${details.relativePath}")
if(Files.notExists(destinationPath.parent)) {
project.mkdir destinationPath.parent
}
project.exec {
commandLine 'ln', '-sf', Files.readSymbolicLink(sourcePath), destinationPath
}
}
}
}
}

0 comments on commit cc45a67

Please sign in to comment.