##// END OF EJS Templates
Variants validation + fail-fast
Variants validation + fail-fast

File last commit:

r26:2ed527593ad4 default
r28:1a0b4caf9976 default
Show More
sources-plugin.md
83 lines | 2.9 KiB | text/x-minidsrc | MarkdownLexer

Sources Plugin

NAME

SourcesPlugin и extension sources.

SYNOPSIS

// Обычно подключается транзитивно через org.implab.gradle-variants-sources

sources {
    register('main') {
        declareOutputs('compiled', 'typings')

        sets {
            ts { srcDir 'src/main/ts' }
            js { srcDir 'src/main/js' }
        }
    }
}

DESCRIPTION

SourcesPlugin регистрирует extension sources типа NamedDomainObjectContainer<GenericSourceSet>.

GenericSourceSet — это автономный source bundle с четким контрактом outputs.

sourceSetDir

Базовый каталог набора. Конвенция по умолчанию: src/<name>.

outputsDir

Базовый каталог результатов набора. Конвенция по умолчанию: build/<name>.

sets

Контейнер SourceDirectorySet внутри GenericSourceSet. Используется для логического разделения подпапок (например ts, js, typings).

outputs contract

Outputs именованные и должны быть объявлены заранее:

  • declareOutputs(...) — декларация доступных output keys;
  • output(name) — доступ к ConfigurableFileCollection для output key;
  • registerOutput(...) — регистрация output из файлов или task provider.

Такой контракт упрощает wiring задач через inputs/outputs без ручного dependsOn.

API

SourcesPlugin

  • apply(Project) — добавляет extension sources в проект.
  • getSourcesExtension(Project) — возвращает контейнер GenericSourceSet.

GenericSourceSet

  • getSourceSetDir() — root directory источников набора.
  • getOutputsDir() — root directory результатов набора.
  • getSets() — контейнер поднаборов SourceDirectorySet.
  • declareOutputs(...) — объявляет разрешенные output names.
  • output(name) — возвращает FileCollection для конкретного output.
  • registerOutput(name, files...) — добавляет файлы в output.
  • registerOutput(name, task, mapper) — связывает output с task provider.
  • getAllOutputs() — агрегированный FileCollection всех outputs.
  • getAllSourceDirectories() — агрегированный FileCollection всех source dirs.

KEY CLASSES

  • SourcesPlugin — регистрация extension sources.
  • GenericSourceSet — модель источников и outputs.

NOTES

  • Обращение к output(name) без предварительного declareOutputs(name) приводит к ошибке валидации.
  • Плагин sources сейчас без marker id.