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.SetProperty;
import org.gradle.api.file.DirectoryProperty;

/**
 * Extension to the lecture plugin with additional properties.
 */
abstract public class LectureExtension {

    /**
     * Supported targets (unnumbered documents).
     *
     * These are configurable, but only within a list of valid target names, so
     * 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 {@code build.gradle}. The target list for
     * numbered documents is automatically derived from this.
     *
     * @return the configured set of targets
     * @see nz.stanger.lecture.Lecture
     */
    abstract public SetProperty<String> getDocTargets();

    /**
     * Standard prefix for lecture documents.
     *
     * Document files are named as {@code prefix_type.tex}, e.g.,
     * {@code 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 {@code 01_Lecture_Title}). This is inserted into the
     * file names of numbered outputs (e.g., {@code 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
     * completely confused Gradle into thinking that all the input files in the
     * project had been touched and it yelled about implicit task dependencies.
     * See
     * {@link 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 {@code imageDir}.
     *
     * @return the configured set of images
     * @see #getImageDir()
     */
    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 {@code imageDir}.
     *
     * @return the configured set of images
     * @see #getImageDir()
     */
    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();

    /**
     * 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 handled separately because {@code FileTree} really 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();

}