Newer
Older
gradle-lectures / buildSrc / src / main / java / nz / stanger / lecture / LectureExtension.java
package nz.stanger.lecture;

import org.gradle.api.provider.Property;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.SetProperty;
import org.gradle.api.file.DirectoryProperty;

abstract public class LectureExtension {

    /**
     * Supported targets (unnumbered documents).
     *
     * These are configurable, but only within a list of valid target names
     * i.e., you can disable supported targets but not create new ones.
     *
     * Remove any targets that don't exist for this lecture. New targets must be
     * registered in the lecture's build.gradle.kts. The target list for
     * numbered documents is automatically derived from this (see Lecture.java).
     *
     * @return the configured set of targets
     */
    abstract public SetProperty<String> getDocTargets();

    /**
     * Standard prefix for lecture documents.
     *
     * Document files are named as "prefix_type.tex", e.g.,
     * "lecture_slides.tex".
     *
     * @return the configured lecture document prefix
     */
    abstract public Property<String> getDocPrefix();

    /**
     * Lecture number.
     *
     * Default is to derive from the project name (assumes the project folder is
     * named something like "01_Lecture_Title"). This is inserted into the file
     * names of numbered outputs (e.g., "lecture_01_slides.pdf".
     *
     * @return the configured lecture number (0 prefixed if necessary)
     */
    abstract public Property<String> getLectureNum();

    /**
     * Subdirectory in which images are kept.
     *
     * @return the configured images directory
     */
    abstract public DirectoryProperty getImageDir();

    /**
     * Subdirectory to which numbered PDFs will be written.
     *
     * Originally these were written into the project directory, but it seemed
     * to completely confuse Gradle into thinking that all the input files in
     * the project had been touched and it yelled about implicit task
     * dependencies. See
     * https://docs.gradle.org/7.3.1/userguide/validation_problems.html#implicit_dependency.
     *
     * @return the configured PDFs directory
     */
    abstract public DirectoryProperty getPdfDir();

    /**
     * Images used by the slides, handout, and notes documents.
     *
     * These will become dependencies of the document. Images will be
     * automatically mapped to imageDir (above).
     *
     * @return the configured set of images
     */
    abstract public SetProperty<String> getSlidesImages();

    /**
     * Files used by the slides, handout, and notes documents.
     *
     * These will become dependencies of the document.
     *
     * @return the configured set of files
     */
    abstract public SetProperty<String> getSlidesFiles();

    /**
     * Images used by the examples document.
     *
     * These will become dependencies of the document. Images will be
     * automatically mapped to imageDir (above).
     *
     * @return the configured set of images
     */
    abstract public SetProperty<String> getExamplesImages();

    /**
     * Images and files used by the examples document.
     *
     * These will become dependencies of the document.
     *
     * @return the configured set of files
     */
    abstract public SetProperty<String> getExamplesFiles();

    /**
     * Images that are generated from another format.
     *
     * The key is the target image, the value is the source image. This is
     * independent of the slidesImages and examplesImages (above). All images
     * will be mapped to imageDir (above).
     *
     * @return MapProperty<String>
     */
    abstract public MapProperty<String, String> getGeneratedImages();

    /**
     * Files to be removed by the clean task.
     *
     * @return the configured set of files to remove
     */
    abstract public SetProperty<String> getCleanFiles();

    /**
     * Directories to be removed by the clean task.
     *
     * Directories are separate because FileTree only stores files :(.
     *
     * @return the configured set of directories to remove
     */
    abstract public SetProperty<String> getCleanDirs();

    /**
     * Command line options for LaTeX.
     *
     * This is a set, so duplicates will be automatically eliminated.
     *
     * @return the configured LaTeX command line options
     */
    abstract public SetProperty<String> getLatexFlags();

}