Git Product home page Git Product logo

tex-gradle-plugin's Introduction

GitHub Actions Gradle plugin portal JitPack

📄 tex-gradle-pluginα

Gradle plugin for building TeX/LaTeX projects.

Gradle Dependency

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>"
}

Usage

Configuring builds

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.

Options

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.

Building multiple projects in order

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
}

Development

When building and testing this library, make sure to clone the submodules. Those are TeX projects, used for integration tests.

Thanks

I am grateful to @DanySK for his work on the forked library, which was licensed under the Apache License 2.0.

Status α

⚠️ Warning: This project is in an experimental alpha stage:

  • The API may be changed at any time without further notice.
  • Development still happens on master.
  • Pull Requests are highly appreciated!

tex-gradle-plugin's People

Contributors

janheinrichmerker avatar danysk avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

tex-gradle-plugin's Issues

Build using Latexmk

Is your feature request related to a problem? Please describe.

Running the basic TeX commands manually is prone to errors. Latexmk was developed as dedicated build tool for TeX, and is included in every TeX distribution.

Describe the solution you'd like

Instead of running commands manually, we could instead copy sources to a temporary build directory, add a latexmkrc RC file including commands and configuration, and then run the latexmk command there.
Alternatively, we can pass the plugin's RC file via specifying the -r option on the command line.

Describe alternatives you've considered

Continue running TeX and bibliography compilation commands manually, as we did before.

Additional context

We have to be aware of Latexmk's search paths for latexmkrc, if we want to merge user's configuration corrrectly. The -r option seems to be a better fit, as it simply overrides any configuration in the default search paths. User's options would not be ignored, unless we specifically overwrite it in the file passed with -r.

Mark \input sources as task inputs

Currently, only the directly referenced .tex file is marked as source input.
We should be able to resolve \input or \include references and mark the included sources as task inputs too,
so that the task is no longer UP-TO-DATE, when those change.

Continuous build

Is your feature request related to a problem? Please describe.

When writing LaTeX, watching for changes and recompiling would be a huge benefit.
Typographic and compilation errors would be noticed earlier, improving the source quality.

Describe the solution you'd like

Implement Gradle's continuous build feature, by watching for changes of TeX sources.

Describe alternatives you've considered

Latexmk has a built in continuous mode. See its -pvc flag.

Additional context

For continuous builds, finding file dependencies in LaTeX documents (like in #1) is important.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.