Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defaultTasks "tex"
- ext.jobname = 'main'
- ext.texengine = 'lualatex'
- ext.mainfile = file('main.tex')
- ext.tmpdir = file("${buildDir}/tex-output")
- task tex << {
- tmpdir.mkdirs()
- texRun()
- texErrors(file("${tmpdir}/${jobname}.log"))
- ant.copy(file: "${tmpdir}/${jobname}.pdf", todir: projectDir, overwrite: true, force: true)
- pdfInfo()
- fontInfo()
- }
- def texRun() {
- def proc = "${texengine} --jobname=\"${jobname}\" --output-directory=\"${tmpdir.absolutePath}\" --interaction=nonstopmode \"${mainfile.absolutePath}\"".execute()
- proc.in.eachLine {line -> println line}
- proc.err.eachLine {line -> println 'ERROR: ' + line}
- proc.waitFor()
- }
- def texErrors(logFile) {
- def errors = logFile.readLines('utf-8').findAll { line -> line.startsWith('! ') }
- if(0 < errors.size) {
- println "\nThe following errors occured during the TeX run:"
- errors.each { error -> println (error - '! ') }
- }
- }
- def pdfInfo() {
- println ''
- def proc = "pdfinfo ${file(jobname + '.pdf').absolutePath}".execute()
- proc.in.eachLine {line -> println line}
- proc.err.eachLine {line -> println 'ERROR: ' + line}
- proc.waitFor()
- }
- def fontInfo() {
- println ''
- def proc = "pdffonts ${file(jobname + '.pdf').absolutePath}".execute()
- proc.in.eachLine {line -> println line}
- proc.err.eachLine {line -> println 'ERROR: ' + line}
- proc.waitFor()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement