-
-
Save k-groshev/9dedb5c9e4f92f4efad9cbf4a37f4e03 to your computer and use it in GitHub Desktop.
Gradle script for LaTeX pdf generation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Usage: | |
* all LaTeX source files go in $rawDirectory | |
* base document to 'cook' should match content of $latexFile | |
* build script delivers resulting PDF file to $cookedDirectory | |
*/ | |
defaultTasks 'full' | |
ext { documentBase = 'myBaseLaTeXFileName' } | |
project.ext { | |
latexFile = documentBase + '.tex' | |
pdfFile = documentBase + '.pdf' | |
rawDirectory = 'raw' | |
cookedDirectory = 'cooked' | |
} | |
task cook(type: Exec) { | |
doFirst { | |
println "Cooking $project.latexFile in /$project.rawDirectory." | |
} | |
outputs.upToDateWhen{false} | |
workingDir project.rawDirectory | |
standardOutput = new ByteArrayOutputStream() // stops output to STDOUT | |
2.times { | |
commandLine 'pdflatex', project.documentBase | |
} | |
outputs.file file("$project.rawDirectory/$project.pdfFile") | |
doLast { | |
println "Cooked $project.latexFile to $project.pdfFile." | |
} | |
} | |
task deliver(type: Copy) { | |
outputs.upToDateWhen{false} | |
from cook | |
into project.cookedDirectory | |
doLast { | |
println "Delivered $project.pdfFile to /$project.cookedDirectory." | |
} | |
} | |
task flush(type: Delete) { | |
dependsOn deliver | |
outputs.upToDateWhen{false} | |
delete { | |
fileTree(dir: project.rawDirectory, excludes: ['**/*.tex', '**/*.cls']) | |
} | |
doLast { | |
println "Flushed /$project.rawDirectory of temporary $documentBase files." | |
} | |
} | |
task full { | |
dependsOn flush | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment