Class TestServerTask
- All Implemented Interfaces:
Comparable<org.gradle.api.Task>,org.gradle.api.internal.DynamicObjectAware,org.gradle.api.internal.TaskInternal,org.gradle.api.Named,org.gradle.api.plugins.ExtensionAware,org.gradle.api.Task,org.gradle.util.Configurable<org.gradle.api.Task>
It does so by spawning a nested Gradle build that runs the real :server / :hplRun
task, so the verification exercises exactly the launch path users rely on.
Cacheable: a successful run produces a marker file. If the declared inputs are unchanged, Gradle can restore the marker from cache and skip launching Jenkins. The modeled inputs are:
- the plugin files synced for the server and the Jenkins runtime classpath;
- files referenced from the plugin's HPL (
testHplRunonly); - the forwarded init scripts — content via
getInitScriptFiles()and order/identity viagetInitScriptPaths(); - the project's build logic that can change the nested build: build & settings scripts,
gradle.properties, version catalogs, andbuildSrcsources (seegetBuildConfigFiles()); - the forwarded Gradle flags and system/project properties.
Cacheability boundary. Because the nested build re-evaluates the whole project,
its inputs cannot be captured exhaustively from here. Changes to build logic outside the
modeled set are not guaranteed to invalidate the cache, notably: included builds located
outside the project tree, environment variables, ~/.gradle/gradle.properties, the Gradle or
wrapper version, and dynamic dependency versions resolved from the network. When in doubt, run with
--rerun-tasks to force a fresh launch.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Named
org.gradle.api.Named.Namer -
Field Summary
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.provider.Property<Boolean>abstract org.gradle.api.file.ConfigurableFileCollectionabstract org.gradle.api.provider.Property<Boolean>abstract org.gradle.api.provider.Property<Boolean>abstract org.gradle.api.provider.Property<String>abstract org.gradle.api.provider.ListProperty<String>abstract org.gradle.api.file.ConfigurableFileCollectionabstract org.gradle.api.provider.ListProperty<String>abstract org.gradle.api.provider.Property<String>abstract org.gradle.api.file.ConfigurableFileCollectionabstract org.gradle.api.provider.Property<Boolean>abstract org.gradle.api.provider.Property<Boolean>abstract org.gradle.api.file.ConfigurableFileCollectionabstract org.gradle.api.provider.Property<PortAllocationService>abstract org.gradle.api.provider.Property<Boolean>abstract org.gradle.api.file.ConfigurableFileCollectionabstract org.gradle.api.provider.Property<Boolean>abstract org.gradle.api.provider.Property<Boolean>abstract org.gradle.api.provider.Property<String>abstract org.gradle.api.provider.Property<String>abstract org.gradle.api.file.RegularFilePropertyvoidLaunches a nested Gradle build, streams its output, and fails the task if Jenkins does not report a successful start within the configured timeout.Methods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesServiceMethods inherited from class org.gradle.api.internal.AbstractTask
acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.Task
doNotTrackState, notCompatibleWithConfigurationCache
-
Constructor Details
-
TestServerTask
public TestServerTask()
-
-
Method Details
-
getRootDir
- Returns:
- root directory of the plugin project, used as the working directory for the spawned Gradle process
-
getGradleExecutable
- Returns:
- path to the
gradlewexecutable to invoke for the nested build
-
getJavaHome
- Returns:
- path to the JDK passed to the spawned Gradle via
-Dorg.gradle.java.home
-
getInitScriptPaths
- Returns:
- ordered absolute paths of the init scripts forwarded via
--init-script, in the exact order they are passed. Gradle applies init scripts in command-line order, so the order (and the set of paths) is part of the cache key — reordering two scripts, or swapping one for a same-content script at a different path, changes the nested build and must invalidate the cache. Content is fingerprinted separately bygetInitScriptFiles().
-
getInitScriptFiles
@InputFiles @PathSensitive(NONE) public abstract org.gradle.api.file.ConfigurableFileCollection getInitScriptFiles()- Returns:
- the init script files, fingerprinted for content so that editing a script invalidates
the cache even when its path is unchanged. Path and ordering are captured by
getInitScriptPaths(), so this collection only needs to track content (PathSensitivity.NONE).
-
getBuildConfigFiles
@InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getBuildConfigFiles()- Returns:
- build-logic files for the nested build's project tree: build & settings scripts
(
*.gradle,*.gradle.kts),gradle.properties, version catalogs (*.versions.toml), andbuildSrcsources. Changes to these affect the nested build's behavior (e.g.JavaExectask args or resolved plugin versions) but are not captured by plugin-file or classpath inputs. This is best-effort, not exhaustive — see the cacheability boundary on the class javadoc.
-
getIncludedBuilds
- Returns:
- composite-build inclusions forwarded via
--include-build
-
getOffline
- Returns:
trueto pass--offlineto the spawned Gradle
-
getBuildCacheEnabled
- Returns:
trueto pass--build-cacheto the spawned Gradle
-
getRefreshDependencies
- Returns:
trueto pass--refresh-dependenciesto the spawned Gradle
-
getContinueOnFailure
- Returns:
trueto pass--continueto the spawned Gradle
-
getParallelExecution
- Returns:
trueto pass--parallelto the spawned Gradle
-
getProfile
- Returns:
trueto pass--profileto the spawned Gradle
-
getRerunTasks
- Returns:
trueto pass--rerun-tasksto the spawned Gradle
-
getDryRun
- Returns:
trueto pass--dry-runto the spawned Gradle
-
getSystemProperties
- Returns:
- system properties forwarded as
-Dkey=valueto the spawned Gradle, excluding internal ones
-
getProjectProperties
- Returns:
- project properties forwarded as
-Pkey=valueto the spawned Gradle, excluding internal ones
-
getServerTaskPath
- Returns:
- Gradle task path to run inside the spawned build (e.g.
:server)
-
getPluginFiles
@InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getPluginFiles()- Returns:
- files that
prepareServer/prepareRunwould copy into the Jenkins work directory (the project's own JPI/HPL and resolved plugin dependencies). Fingerprinting these is what makes the task safely cacheable when nothing relevant has changed.
-
getJenkinsClasspath
@Classpath public abstract org.gradle.api.file.ConfigurableFileCollection getJenkinsClasspath()- Returns:
- classpath used to launch the embedded Jenkins server (jenkins-war).
-
getReferencedFiles
@InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getReferencedFiles()- Returns:
- files referenced by the plugin's HPL but not bundled into
getPluginFiles(): the plugin's own classes, resource directories, and bundled libraries. Required fortestHplRun, where the HPL points at these paths directly; ignored (empty) fortestServer, since the JPI archive already captures the same content.
-
getSuccessMarker
@OutputFile public abstract org.gradle.api.file.RegularFileProperty getSuccessMarker()- Returns:
- marker file written only on a successful Jenkins start so the task is cacheable.
-
getPortAllocationService
@Internal public abstract org.gradle.api.provider.Property<PortAllocationService> getPortAllocationService()- Returns:
- build service that allocates a free TCP port for the Jenkins test server
-
runTestServer
public void runTestServer()Launches a nested Gradle build, streams its output, and fails the task if Jenkins does not report a successful start within the configured timeout.
-