Generate Local Library Files
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— aLibraryRetrieverthat copiessrc/,vars/, andresources/from the path set in thetest.library.locationsystem property. Additional libraries are injected via contiguoustest.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 inGlobalLibrariesat embedded Jenkins startup (generated unlesssharedLibrary.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 attest.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@Initializermethods via reflection. Generated directly here instead of via theannotation-indexerprocessor.META-INF/hudson.remoting.ClassFilter— registersLocalLibraryRetrieverso XStream can deserialiseLibraryConfigurationduring 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")));Properties
Content written to SharedLibraryAutoRegistrar.java; tracked as a task input for the same reason as retrieverSource.
Content written to META-INF/hudson.remoting.ClassFilter; tracked as a task input for the same reason.
When true, generates SharedLibraryAutoRegistrar.java so Jenkins auto-registers the library via @Initializer; otherwise deletes it.
Content written to LocalLibraryRetriever.java; tracked as a task input so a plugin upgrade that changes the template forces regeneration.