Classes specific to testing a Gradle project, leveraging Spock
ProjectSpec
Uses Project Builder to create a in-memory expression of a Gradle build (project variable), specifically in a projectDir
. A sanitized project name will be stored in canonicalName
. Caveat, this is ONLY setting up the Project data structure, and not running through the completely lifecycle, Like to see http://issues.gradle.org/browse/GRADLE-1619.
Its value lays in being able to execute method with a proper Project object, which can flush out most groovy functions, finding basic compiler like issues. The private method evaluate()
can be called on the project variable for force evaluation
of afterEvaluate
blocks, keeping in mind that still won't generate a task gradle or run the tasks.
PluginProjectSpec
Small abstraction over ProjectSpec for plugins, adds three tests that ensure the plugin can be applied properly (idempotently and in a multi-project).
IntegrationSpec
Orchestrate a Gradle build via GradleLauncher
, which is deprecated, or the Tooling API to perform a high-level integration test of a project. Each test gets it's own test directory, called projectDir
. It is up to the implementer to add contents to the buildFile and the settingsFile. The project's name is available as moduleName
, which is a sanitized version of the test's name.
The spec will assume the Tooling API, but this can be changed by setting useToolingApi
to false in which case the GradleLauncher
will be used. It's risky to use since it's not support, but it provide more details from the resulting build. Though if you're checking the contents of the projectDir
after build, it shouldn't matter. The GradleLauncher
is required to debug the running of your build, you can't set break points in the build.gradle
file, but you can set them in the plugins being called.
Generating Test Maven and Ivy Repos
Multi-project Helpers
MultiProjectHelper
MultiProjectHelper
can create various sub-projects using the ProjectBuilder
.
MultiProjectIntegrationHelper
MultiProjectIntegrationHelper
can create sub-projects using our IntegrationSpec
.