GenerateLocalLibraryFiles

@CacheableTask
abstract class GenerateLocalLibraryFiles : DefaultTask

Generates source files that allow JenkinsRule integration tests to load the project's shared library.

The plugin registers this task automatically; consumers do not invoke it directly. The generated files are wired into the integrationTest source set:

  • LocalLibraryRetriever.java — a LibraryRetriever that copies src/, vars/, and resources/ from the path set in the test.library.location system property. Additional libraries are injected via contiguous test.library.N.{name,location,implicit} properties. A future iteration may replace the property scheme with a single manifest file on the test classpath once external library resolution is implemented.

  • SharedLibraryAutoRegistrar.java — an @Initializer-annotated class that auto-registers all libraries in GlobalLibraries at embedded Jenkins startup (generated unless sharedLibrary.autoRegisterLibrary = false). Libraries are scanned via contiguous zero-based indices: test.library.0.* is always the project's own library; additional libraries resolved from Gradle dependencies follow at test.library.1.*, test.library.2.*, …

  • META-INF/services/annotations/hudson.init.Initializer — the annotation-indexer class list that Jenkins reads at startup; each listed class is scanned for @Initializer methods via reflection. Generated directly here instead of via the annotation-indexer processor.

  • META-INF/hudson.remoting.ClassFilter — registers LocalLibraryRetriever so XStream can deserialise LibraryConfiguration during test setup.

When generateAutoRegistrar = true (the default), no explicit GlobalLibraries.get().setLibraries(...) call is needed in test code — the auto-registrar handles it at Jenkins startup time. Pass an explicit name if you need a different library name than project.name:

// Explicit registration (only needed when autoRegisterLibrary = false):
GlobalLibraries.get().setLibraries(List.of(LocalLibraryRetriever.implicitLibrary()));
GlobalLibraries.get().setLibraries(List.of(LocalLibraryRetriever.implicitLibrary("my-lib")));

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open var actions: List<Action<in Task?>?>?
Link copied to clipboard
open val ant: AntBuilder?
Link copied to clipboard
@get:Internal
open val asDynamicObject: DynamicObject
Link copied to clipboard
@get:Input
abstract val autoRegistrarSource: Property<String>

Content written to SharedLibraryAutoRegistrar.java; tracked as a task input for the same reason as retrieverSource.

Link copied to clipboard
@get:Input
abstract val classFilterEntry: Property<String>

Content written to META-INF/hudson.remoting.ClassFilter; tracked as a task input for the same reason.

Link copied to clipboard
open val dependsOn: Set<Any?>?
Link copied to clipboard
open var description: @Nullable String?
Link copied to clipboard
open val destroyables: TaskDestroyables?
Link copied to clipboard
open var didWork: Boolean
Link copied to clipboard
open var enabled: Boolean
Link copied to clipboard
open val extensions: ExtensionContainer?
Link copied to clipboard
open val finalizedBy: TaskDependency?
Link copied to clipboard
@get:Input
abstract val generateAutoRegistrar: Property<Boolean>

When true, generates SharedLibraryAutoRegistrar.java so Jenkins auto-registers the library via @Initializer; otherwise deletes it.

Link copied to clipboard
open var group: @Nullable String?
Link copied to clipboard
open val identityPath: Path?
Link copied to clipboard
Link copied to clipboard
open val inputs: TaskInputsInternal?
Link copied to clipboard
@get:Internal
open var isEnabled: Boolean
Link copied to clipboard
Link copied to clipboard
@get:OutputDirectory
abstract val javaOutputDir: DirectoryProperty
Link copied to clipboard
@get:Internal
open val lifecycleDependencies: TaskDependencyInternal?
Link copied to clipboard
open val localState: TaskLocalState?
Link copied to clipboard
open val logger: Logger?
Link copied to clipboard
open val logging: LoggingManager?
Link copied to clipboard
open val mustRunAfter: TaskDependency?
Link copied to clipboard
open val name: String?
Link copied to clipboard
open val onlyIf: Spec<in TaskInternal?>?
Link copied to clipboard
open val outputs: TaskOutputsInternal?
Link copied to clipboard
open val path: String?
Link copied to clipboard
open val project: Project?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val requiredServices: TaskRequiredServices?
Link copied to clipboard
@get:OutputDirectory
abstract val resourcesOutputDir: DirectoryProperty
Link copied to clipboard
@get:Input
abstract val retrieverSource: Property<String>

Content written to LocalLibraryRetriever.java; tracked as a task input so a plugin upgrade that changes the template forces regeneration.

Link copied to clipboard
open val sharedResources: List<ResourceLock?>?
Link copied to clipboard
open val shouldRunAfter: TaskDependency?
Link copied to clipboard
open val standardOutputCapture: StandardOutputCapture?
Link copied to clipboard
open val state: TaskStateInternal?
Link copied to clipboard
open val taskActions: List<InputChangesAwareTaskAction?>?
Link copied to clipboard
open val taskDependencies: TaskDependencyInternal?
Link copied to clipboard
open val taskIdentity: TaskIdentity<*>?
Link copied to clipboard
open val temporaryDir: File?
Link copied to clipboard
open val temporaryDirFactory: Factory<File?>?
Link copied to clipboard
open val timeout: Property<Duration?>?

Functions

Link copied to clipboard
open fun acceptServiceReferences(serviceReferences: Set<ServiceReferenceSpec?>?)
Link copied to clipboard
open fun appendParallelSafeAction(action: Action<in Task?>?)
Link copied to clipboard
open operator fun compareTo(otherTask: Task?): Int
Link copied to clipboard
open fun configure(closure: Closure<*>?): Task?
Link copied to clipboard
open fun dependsOn(vararg paths: Any?): Task?
Link copied to clipboard
open fun doFirst(action: Closure<*>?): Task?
open fun doFirst(action: Action<in Task?>?): Task?
open fun doFirst(actionName: String?, action: Action<in Task?>?): Task?
Link copied to clipboard
open fun doLast(action: Closure<*>?): Task?
open fun doLast(action: Action<in Task?>?): Task?
open fun doLast(actionName: String?, action: Action<in Task?>?): Task?
Link copied to clipboard
open fun doNotTrackState(reasonNotToTrackState: String?)
Link copied to clipboard
open fun doNotTrackStateIf(reason: String?, spec: Spec<in TaskInternal?>?)
Link copied to clipboard
open fun finalizedBy(vararg paths: Any?): Task?
Link copied to clipboard
fun generate()
Link copied to clipboard
open fun hasProperty(propertyName: String?): Boolean
Link copied to clipboard
Link copied to clipboard
open fun mustRunAfter(vararg paths: Any?): Task?
Link copied to clipboard
open fun onlyIf(onlyIfClosure: Closure<*>?)
open fun onlyIf(spec: Spec<in Task?>?)
open fun onlyIf(onlyIfReason: String?, spec: Spec<in Task?>?)
Link copied to clipboard
open fun prependParallelSafeAction(action: Action<in Task?>?)
Link copied to clipboard
open fun property(propertyName: String?): Any?
Link copied to clipboard
open fun restoreOnlyIf(onlyIf: Spec<in TaskInternal?>?)
Link copied to clipboard
open fun restoreTaskActions(taskActions: List<InputChangesAwareTaskAction?>?)
Link copied to clipboard
open fun setDependsOn(dependsOn: Iterable<*>?)
Link copied to clipboard
open fun setFinalizedBy(finalizedByTasks: Iterable<*>?)
Link copied to clipboard
open fun setMustRunAfter(mustRunAfterTasks: Iterable<*>?)
Link copied to clipboard
open fun setOnlyIf(onlyIfClosure: Closure<*>?)
open fun setOnlyIf(spec: Spec<in Task?>?)
open fun setOnlyIf(onlyIfReason: String?, spec: Spec<in Task?>?)
Link copied to clipboard
open fun setProperty(name: String?, value: Any?)
Link copied to clipboard
open fun setShouldRunAfter(shouldRunAfterTasks: Iterable<*>?)
Link copied to clipboard
open fun shouldRunAfter(vararg paths: Any?): TaskDependency?
Link copied to clipboard
open fun usesService(service: Provider<out BuildService<*>?>?)