📄 tex-gradle-pluginα
Gradle plugin for building TeX/LaTeX projects.
The plugin is available from the Gradle plugin portal.
Add this in your build.gradle.kts
or build.gradle
file:
Kotlin
plugins {
id("dev.reimer.tex") version "<version>"
}
Groovy
plugins {
id "dev.reimer.tex" version "<version>"
}
Build TeX files by registering tasks:
Kotlin
tasks.register<TexCompile>("buildTexFile") {
source("sample.tex")
}
Groovy
task buildTexFile(type: TexCompile) {
source("sample.tex")
}
(You may need to import TexCompile
)
This configuration autodetects if a sample.bib
is present,
and builds the resulting sample.pdf
.
Compiled PDFs are stored in the out/
directory under the project root.
Setting the destinationDir
property overwrites
the default output directory.
You can register as many tex compile tasks as you like.
Alternatively, reference a directory, file tree
or more,
using the source()
task configuration.
And don't worry about a messy out/
directory,
as the folder structure will be preserved.
Global options can be specified directly in the tex
block.
Kotlin
tex {
quiet.set(true)
overwrite.set(true)
texCompiler.set(TexCompilerType.PDFLATEX)
bibliographyCompiler.set(BibliographyCompilerType.BIBTEX)
imageConverter.set(ImageConverterType.INKSCAPE_PDF)
}
Groovy
tex {
quiet = true
overwrite = true
texCompiler = TexCompilerType.PDFLATEX
bibliographyCompiler = BibliographyCompilerType.BIBTEX
imageConverter = ImageConverterType.INKSCAPE_PDF
}
All options can also be applied to each task individually.
Task dependencies (dependsOn
) can be used to specify dependencies among TeX tasks.
In the following example, project1.tex
and project2.tex
can get built in parallel,
while project3.tex
build can start only after both the former completed successfully.
Kotlin
tasks.register<TexCompile>("buildTexProject1") {
source("project1/")
}
tasks.register<TexCompile>("buildTexProject2") {
source("project2/")
}
tasks.register<TexCompile>("buildTexProject3") {
source("project3/")
dependsOn("buildTexProject1", "buildTexProject2")
}
Groovy
task buildTexProject1(type: TexCompile) {
source("project1/")
}
task buildTexProject2(type: TexCompile) {
source("project2/")
}
task buildTexProject3(type: TexCompile) {
source("project3/")
dependsOn buildTexProject1, buildTexProject2
}
When building and testing this library, make sure to clone the submodules. Those are TeX projects, used for integration tests.
I am grateful to @DanySK for his work on the forked library, which was licensed under the Apache License 2.0.
- The API may be changed at any time without further notice.
- Development still happens on
master
. - Pull Requests are highly appreciated!