The Build Support extension. The methods defined here are available for use by any consuming build script.
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
NAME |
| Constructor and description |
|---|
BuildSupportExtension
(org.gradle.api.internal.project.ProjectInternal project) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
configureJavaTemplates(org.gradle.api.Project p)Configure a project to use "java templates." |
|
void |
configureJavadocPublishing(org.gradle.api.Project p)Configure a project to publish a javadoc artifact. |
|
void |
configureManifest(org.gradle.api.Project p)Configure the standard manifest entries for the given project. |
|
void |
configureManifestForArchiveTask(org.gradle.api.tasks.bundling.Jar task)Configure the standard manifest entries for the given archive task. |
|
void |
configurePublications(org.gradle.api.Project p, groovy.lang.Closure configClosure)Apply a configuration closure to the publications managed/created by this plugin. |
|
void |
configurePublishing(org.gradle.api.Project p, boolean toNexus = true)Configure a project to publish maven artifacts to the local M2 repo and, optionally, to the Nexus maven repo. |
|
void |
configureRdmFacades(org.gradle.api.Project p)Configure the given project for generating RDM facade classes from Structure XML definitions. |
|
void |
configureSourcePublishing(org.gradle.api.Project p, boolean mavenLocalOnly = true)Configure a project to create and publish a "sources" jar. |
|
void |
configureStandardPlugin(org.gradle.api.Project p, boolean publishToNexus, boolean configureTestAgent = true, java.lang.String... weaveTestPackages = [])Perform the "standard" configuration for a typical Raptor plugin project. |
|
void |
configureTestTasks(org.gradle.api.Project p)Apply a standard configuration to all test tasks. |
|
void |
configureXjc(org.gradle.api.Project p)Configure the given project for using XJC to compile XML schemas. |
|
void |
createPluginInstallTask(org.gradle.api.Project p)Create a task, named install, that will copy the created jar/war artifact(s) into
{@code .. |
|
static java.lang.String |
formatCommit(org.ajoberstar.grgit.Commit commit)Create a short description of a commit. |
|
java.util.Map |
getManifestAttributes(org.gradle.api.Project p)Create the standard manifest attributes for the given project. |
|
RepoManagement |
getRepoManagement() |
|
void |
git(java.lang.String... cmdArgs)Execute a git command using the installed command line tools. |
|
static void |
manifestDependencies(groovy.lang.Closure closure)This method adds a "Dependencies" entry to the manifest in the jar/war artifacts. |
|
void |
publishArtifact(org.gradle.api.Project p, java.lang.Object artifactToPublish, boolean toNexus = true)Configure a project to publish a specified artifact to maven repositories (as configured by setupRepositories(org.gradle.api.Project). |
|
void |
repoManagement(groovy.lang.Closure configureClosure)Apply the given closure to configure our repo management. |
|
void |
reportPluginVersion()Dump out our version and some associated build information:
|
|
org.ajoberstar.grgit.Commit |
safeResolveCommit(java.lang.String tagName)Resolve a given tag name to a commit. |
|
void |
setupJavaProject(org.gradle.api.Project p)Configure the given project as a java project, with appropriate plugins, compiler configuration and publishing after a build. |
|
void |
setupPluginTestAgent(org.gradle.api.Project p, java.lang.String[] weaveTestPackages = [])Configure the given project so that it has access to the Raptor bootstrap java agent. |
|
void |
setupRepositories(org.gradle.api.Project p)Add in our standard repositories. |
|
boolean |
shouldPublish(org.gradle.api.publish.maven.tasks.AbstractPublishToMaven task)Determine if a given publishing task should actually execute. |
|
void |
updateParentWithReleaseClean(org.gradle.api.Project p)Ensure that the releaseClean task is available all the time at the root. |
|
void |
verifyTreeIsClean()Validate that the current work tree is clean. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Configure a project to use "java templates." The templates are assumed to live in
src/main/java-templates, which can be overridden with the javaTemplatesDir project property.
The generated code will be placed in build/generated-sources, which will be configured as a java source
dir during compilation. The template(s) will be copied using normal gradle token expansion.
The current project will be automatically added to the token expansion map under the name 'project'
and additional tokens can be supplied via the project property templateProperties, which must be
a map of String keys to arbitrary values.
The consuming build script can define the following properties to configure the build:
javaTemplatesDir - the directory in which to find the template java files,
defaults to 'src/main/java-templates'templateProperties - A map of additional properties to use during 'expand' processing
This script creates a new copyJavaTemplates task and configures compileJava to depend on it.
If the java templates directory does not exist, then the task is not created.
Configure a project to publish a javadoc artifact. The project must configure the javadoc task
as needed. This method will create a packageJavadoc task that creates a jar file from the output
of the javadoc task with a 'javadoc' classifier, and then updates the 'mavenJava'
publication to include that artifact. The packageJavadoc task is only enabled if the
javadoc task is enabled.
p - The project to configureConfigure the standard manifest entries for the given project. This method will configure both the 'jar' and 'war' tasks on the given project.
p - project to configureConfigure the standard manifest entries for the given archive task.
task - Task to configureApply a configuration closure to the publications managed/created by this plugin. A typical use is to add an artifact to the publications, like this:
buildSupport.configurePublications(project) {
artifact testJar
}
The given closure will be applied to both the mavenJava and forMavenLocal publications.
p - The project to configureconfigClosure - The configuration closure to apply to the publications Configure a project to publish maven artifacts to the local M2 repo and, optionally, to the Nexus maven repo.
This supports dependency references from RaptorPlugins (or any other project) onto artifacts built here.
The artifacts are published to the "releases" repository using the current user's credentials.
Publishing to Nexus is only enabled when performing a "release" build (when -Prelease is
specified on the command line) or if -PforcePublish is specified on the command line.
Publishing is disabled if this is a snapshot build (isSnapshot is true) or
a rebuild (-PrebuildRelease is specified).
If -PuseTestRepo is specified on the command line, then the artifacts will be published to a local
repo within the build area, $buildDir/repo instead of to Nexus.
Two publications are managed:
mavenJava - For artifacts to publish to remote maven reposforMavenLocal - For artifacts to publish to "maven local" repop - The project to configuretoNexus - Pass true to configure publishing to Nexus (if this is a release build). Passing
false skips configuring Nexus publication regardless of build type. The Default value is true.Configure the given project for generating RDM facade classes from Structure XML definitions. This adds an extension, of type GenerateRdmFacadesExtension, to the project. See the documentation for that extension to get details and examples of how to configure facade generation.
Configure a project to create and publish a "sources" jar. By default sources will only publish to maven
local. If you really want sources published to a "real" maven repository, then pass false for
mavenLocalOnly (which defaults to true).
Be certain you understand the access controls of your project before you even consider publishing sources anywhere other than maven local.
This method creates a sourcesJar task to produce the jar containing the sources, and creates
a publication named 'sources' that uses the sourcesJar output as the artifact to publish
with a 'sources' classifier.
p - The project to configuremavenLocalOnly - Pass true to limit publication to maven local only, false to publish
to all configured repositories. Default is true.Perform the "standard" configuration for a typical Raptor plugin project. This is equivalent to calling the following methods:
if(configureTestAgent) setupPluginTestAgent(org.gradle.api.Project)p - The project to configurepublishToNexus - Pass true to enable publishing to the STL Nexus repoconfigureTestAgent - Pass true to configure the AOP test agent (required for integration tests
against the raptor core), or false if you don't need it. default is true.weaveTestPackages - Additional packages to weave during test execution, optional, default is emptyApply a standard configuration to all test tasks.
p - Project to configureConfigure the given project for using XJC to compile XML schemas. The invoking project will use the following optional properties to configure this operation:
xjcSchemasDir - the directory in which to find the schemas to compile, default is src/main/resources/schemaxjcPackage - the package into which to generate the classes, the default is determined from the
package defined in jxb:package within each schema being processed*.xjb files), if any, are in the same directory as the schemas.
Create a task, named install, that will copy the created jar/war artifact(s) into
../RaptorT/Raptor/bin/plugins (by default). If the environment variable
ORG_GRADLE_PROJECT_pluginInstallDir is set, it will provide a value for the pluginInstallDir
project property. This may be overridden if the project defines the variable pluginInstallDir
(e.g., using -PpluginInstallDir on the command line, or setting it in a gradle.properties file) it
will override the default destination directory.
install task is dependent upon the build task so that if tests fail, the artifact is not copied.
There are problems when a 'war' project is a dependency of another project. In this case when the dependent
project is built, the war project is built as a dependency, but it builds a jar (that would not normally be
created when doing a 'build' in that project directly). That would lead to having both a jar and a war
being installed into the plugins directory when only a war should have been copied. In order to handle this
case, a configuration parameter has been added to control this behavior. If a plugin project's build would
generate both a jar and a war and both should be installed, the ext variable installBothWarAndJar
must be defined.
p - Project to configureCreate a short description of a commit.
Create the standard manifest attributes for the given project.
The following manifest attributes are configured:
| Attribute | Value |
|---|---|
| Built-By | The value of rootProject.name |
| Implementation-Version | The value of the buildVersion ext variable, like '2.7.1-SNAPSHOT' |
| Build-Date | The date the build was performed, formatted as 'yyyy-MM-dd' |
| Build-Jdk | The version of the JDK used to perform the build, e.g., 1.8.0_112 |
| Build-Number | The SHA1 of the commit from which the build was created, e.g., f0d164b762e0af659dd5eb8367f72fdd8fb0b21c |
| RaptorX-Version | If this is a project/plugin build, this is the raptor version against which the project was built, i.e., raptorVersion |
| Build-Branch | The name of the branch on which the build was performed, e.g.,
dev or 2.7 or feature/OPS-78-build-support-plugin |
p - Project to processExecute a git command using the installed command line tools. This should not be used for "required" operations. It is here for use when the git command (like status) provides better human-readable output than the internal Grgit objects.
Any output produced by the command simply goes to the console (it is not redirected). Any exceptions are trapped and reported.
cmdArgs - Arguments to pass to 'git'This method adds a "Dependencies" entry to the manifest in the jar/war artifacts. It uses a closure to produce the value of the dependencies string. This allows for the delayed evaluation needed to resolve things like project versions on nested sub-projects.
For example, this configuration:
manifestDependencies { "plugin.calculators-${project(':plugin.calculators').version}" }
Would result in a manifest entry like this (ignoring the actual version of the artifact):
Dependencies: plugin.calculators-1.0.0
closure - Must return either a single string, or an iterable (like a list) which will be joined with commasConfigure a project to publish a specified artifact to maven repositories (as configured by setupRepositories(org.gradle.api.Project).
This supports projects that don't generate typical components (like jars or wars), e.g., an android project that needs to publish it's APK.
Publishing to Nexus is only enabled when performing a "release" build (when -Prelease is
specified on the command line) or if -PforcePublish is specified on the command line.
Publishing is disabled if this is a snapshot build (isSnapshot is true) or
a rebuild (-PrebuildRelease is specified).
If -PuseTestRepo is specified on the command line, then the artifacts will be published to a local
repo within the build area, $buildDir/repo instead of to Nexus.
Two publications are managed:
mavenJava - For artifacts to publish to remote maven reposforMavenLocal - For artifacts to publish to "maven local" repop - The project to configureartifactToPublish - The artifact to publishtoNexus - Pass true to configure publishing to Nexus (if this is a release build). Passing
false skips configuring Nexus publication regardless of build type. The Default value is true.Apply the given closure to configure our repo management.
Dump out our version and some associated build information:
Resolve a given tag name to a commit. Trap any underlying exception (like an NPE which is how jgit responds) and convert it into a RuntimeException with a meaningful error message.
tagName - The tag string to resolve to a Commit Configure the given project as a java project, with appropriate plugins, compiler configuration and
publishing after a build.
Plugins applied: 'java' and 'maven-publish'
The Java compiler is configured for source and target compatibility of 1.8, and configured to include debug line numbers (but no local variable table).
A task, named compile, is created as an alias for the jar task to ease developers transition from
maven.
A task, named releaseClean, is created to provide a hook for any extended cleanup operations that need to
take place prior to performing a 'release' build. The releaseClean task depends on clean.
The build task is configured to be finalized by publish so the produced jar file
is copied into the local maven repo (and Nexus, on release builds if configured) if the build succeeds.
If this is a 'release' build, then the build task is configured to depend on releaseClean and
and updateReleaseVersion and finalized by tagRelease.
The test task is configured to not fail the build if it is running under the Jenkins CI server, and
it will announce the start of each test if -Dtest.announce=true is specified on the build command line.
Configure the given project so that it has access to the Raptor bootstrap java agent. This agent is required to run container/integration tests that use the Raptor test support library. After calling this method, the project will have:
testAgenttestAgent on gov.raptor:bootstrap:$raptorVersionext variable bootstrapJar assigned the full path to the Raptor bootstrap jarjvmArgs property of the test task will be initialized to ['-ea', "-javaagent:$bootstrapJar"]p - The project to configureweaveTestPackages - Additional packages to weave during test executionAdd in our standard repositories. They are:
noMavenLocal is set, then mavenLocal() will not be added to the repository list
p - Project to configureDetermine if a given publishing task should actually execute. We manage 2 publications, and we want to ensure they only execute on their appropriate targets. Further, we don't want to interfere with any other publication that the project might have configured.
In addition, publishing will be prevented when:
Hopefully, the publishing plugin will someday grow up and allow the specification of an "optional" artifact.
task - Publishing task to testtrue if the task should executeEnsure that the releaseClean task is available all the time at the root.
Validate that the current work tree is clean. Allow the -Pforce option to override the clean check.
If the tree is not clean, and -Pforce is not specified, then a org.gradle.api.GradleException is thrown.