public class PluginBuildPlugin
extends java.lang.Object
implements org.gradle.api.Plugin<org.gradle.api.Project>
The org.ajoberstar.grgit plugin is used to interact with
the project's git repository, if it exists.
The com.github.johnrengelman.shadow plugin is used to
generate a "fat" executable jar, if #isShadowJarEnabled
returns true.
The maven-publish, signing,
com.gradle.plugin-publish com.jfrog.artifactory,
io.github.gradle-nexus.publish-plugin plugins are used to
sign and publish artifacts to Artifactory, Nexus and the Gradle Plugin
Portal.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ARTIFACTORY_PLUGIN_ID
The JFrog Artifactory Gradle plugin identifier.
|
static java.lang.String |
GRADLE_NEXUS_PUBLISH_PLUGIN_ID
The Sonatype Nexus publishing plugin identifier.
|
static java.lang.String |
GRADLE_PLUGIN_PUBLISH_PLUGIN_ID
The Gradle plugin publishing plugin identifier.
|
static java.lang.String |
GRGIT_PLUGIN_ID
The Grgit plugin identifier.
|
static java.lang.String |
GROOVY_PLUGIN_ID
The Groovy plugin identifier.
|
static java.lang.String |
JAVA_GRADLE_PLUGIN_ID
The Java Gradle plugin identifier.
|
static java.lang.String |
JAVA_LIBRARY_PLUGIN_ID
The Java library plugin identifier.
|
static java.lang.String |
MAVEN_PUBLISH_PLUGIN_ID
The Maven publishing plugin identifier.
|
static java.util.List<java.lang.String> |
PLUGIN_IDS
The plugins to apply to the plugin build project.
|
static java.util.List<java.lang.String> |
REQUIRED_PROPERTIES
The project-specific properties that must be set.
|
static java.lang.String |
SHADOW_PLUGIN_ID
The shadow plugin identifier.
|
static java.lang.String |
SIGNING_PLUGIN_ID
The signing plugin identifier.
|
static java.lang.String |
SONARQUBE_PLUGIN_ID
The Sonarqube plugin identifier.
|
| Constructor and Description |
|---|
PluginBuildPlugin() |
| Modifier and Type | Method and Description |
|---|---|
void |
apply(org.gradle.api.Project project)
Applies the plugin and configures the build.
|
static java.lang.String |
asString(org.gradle.api.Project project,
java.lang.String propertyName)
Looks up a project property and returns the value as a string.
|
static void |
checkProjectProperties(org.gradle.api.Project project,
java.util.List<java.lang.String> requiredProperties)
Checks that values have been provided for the required project properties.
|
static void |
configureArchives(org.gradle.api.Project project)
Configures archives for publishing.
|
static void |
configureArtifactory(org.gradle.api.Project project)
Configures Artifactory publishing.
|
static void |
configureDefaultTasks(org.gradle.api.Project project)
Configures the
local and all tasks and assigns
all as the project default. |
static void |
configureDependencies(org.gradle.api.Project project)
Adds dependencies.
|
static void |
configureDerivedPropertiesWithoutPlugins(org.gradle.api.Project project)
Defines additional properties that are derived from the required properties.
|
static void |
configureDerivedPropertiesWithPlugins(org.gradle.api.Project project)
Configure the properties that we couldn't get values for without plugins.
|
protected static void |
configureGradlePlugin(org.gradle.api.Project project,
java.util.Map<java.lang.String,java.lang.String> spec,
org.gradle.plugin.devel.PluginDeclaration declaration)
Configures the specified Gradle plugin.
|
static void |
configureGradlePlugins(org.gradle.api.Project project)
Configures the Gradle plugin to build and publish.
|
static void |
configureJarAppendix(org.gradle.api.tasks.bundling.Jar jar)
Configures the jar appendix.
|
static void |
configureJarBaseName(org.gradle.api.tasks.bundling.Jar jar)
Configures the jar basename.
|
static void |
configureJarClassifier(org.gradle.api.tasks.bundling.Jar jar,
java.lang.String prefix,
java.lang.String suffix)
Configures the jar classifier.
|
static void |
configureJarManifest(org.gradle.api.tasks.bundling.Jar jar,
java.util.Map<java.lang.String,java.lang.String> manifestAttributes)
Configures the jara manifest with the parameter attributes.
|
static void |
configureJarTask(org.gradle.api.Project project)
Configures jar task including manifest attributes.
|
static void |
configureJavadocJarTask(org.gradle.api.Project project)
Configures the Javadoc jar task.
|
static void |
configureJavaPlugin(org.gradle.api.Project project)
Configures the Java plugin including source and target compatibility.
|
static void |
configureJavaPublishing(org.gradle.api.Project project)
Configures Java artifact publishing.
|
static void |
configureJavaPublishing(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPublication publication)
Configures Java artifact publishing.
|
static void |
configureMavenPom(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPom pom)
Configures the parameter POM.
|
static void |
configureMavenPomDevelopers(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPomDeveloperSpec spec)
Configures the developers section of a POM.
|
static void |
configureMavenPomIssueManagement(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPomIssueManagement spec)
Configures the issue management section of a POM.
|
static void |
configureMavenPomLicenseSpec(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPomLicenseSpec spec)
Configures the licensing section of a POM.
|
static void |
configureMavenPomOrganization(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPomOrganization spec)
Configures the organization section of a POM.
|
static void |
configurePlugin(org.gradle.api.Project project,
java.lang.String id,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
Applies the plugin identified by the parameter plugin identifier.
|
static void |
configurePluginBundle(org.gradle.api.Project project)
Configures the plugin bundle being published.
|
static void |
configurePluginInclusion(org.gradle.api.Project project,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
Configures plugin inclusion.
|
static void |
configurePlugins(org.gradle.api.Project project,
java.util.List<java.lang.String> pluginIds,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
Applies the plugins in the
PLUGIN_IDS list. |
static void |
configureRepositories(org.gradle.api.Project project)
Adds repository definitions.
|
static void |
configureShadowJarTask(org.gradle.api.Project project)
Configures the shadow jar task.
|
static void |
configureSigning(org.gradle.api.Project project)
Configures signing.
|
static void |
configureSonatype(org.gradle.api.Project project)
Configures Sonatype publishing.
|
static void |
configureSourceJarTask(org.gradle.api.Project project)
Configures the source jar task.
|
static java.util.Map<java.lang.String,java.lang.String> |
createManifestAttributes(org.gradle.api.Project project)
Creates jar manifest attributes for the parameter project.
|
static java.lang.Object |
findPropertyOr(org.gradle.api.Project project,
java.lang.String propertyName,
java.lang.Object defaultValue)
Looks up a project property or provides the parameter default if no value found.
|
static java.lang.String |
formatSonatypeContextUrl(org.gradle.api.Project project,
java.lang.String propertyName,
java.lang.String description)
Formats a context URL for Sonatype Nexus.
|
static boolean |
hasLicenses(org.gradle.api.Project project)
Checks whether the process has one or more license entries assigned to
the
project.licenses property. |
static boolean |
hasReleaseVersion(org.gradle.api.Project project)
Determines whether the project version is a release or release candidate.
|
static boolean |
hasSnapshotVersion(org.gradle.api.Project project)
Determines whether the project version is a snapshot.
|
static boolean |
isArtifactoryPublishingEnabled(org.gradle.api.Project project)
Determines whether produced artifacts should be published to Artifactory.
|
static boolean |
isGitHosted(org.gradle.api.Project project)
Checks whether git integration should be enabled.
|
static boolean |
isGradleApiDependedOn(org.gradle.api.Project project)
Checks whether the project needs a Gradle API dependency.
|
static boolean |
isLocalGroovyDependedOn(org.gradle.api.Project project)
Checks whether the project needs a Groovy dependency.
|
static boolean |
isOpenSource(org.gradle.api.Project project)
Checks whether the project is marked as open source.
|
static boolean |
isPluginPublishingEnabled(org.gradle.api.Project project)
Determines whether the produced artifacts should be published to the
Gradle plugin portal.
|
static boolean |
isProjectPropertySet(org.gradle.api.Project project,
java.lang.String propertyName)
Checks that the parameter project property has a non-empty string that
does not evaluate to
false,or a non-empty collection value. |
static boolean |
isPropertyValueSet(java.lang.Object value)
Checks whether the parameter value is non-null, non-empty if collection,
and non-empty and non-whitespace if string.
|
static boolean |
isShadowJarEnabled(org.gradle.api.Project project)
Checks whether a shadow jar should be built.
|
static boolean |
isSigningEnabled(org.gradle.api.Project project)
Checks whether artifacts should be signed.
|
static boolean |
isSonarqubeEnabled()
Checks whether Sonarqube should be used.
|
static boolean |
isSonatypePublishingEnabled(org.gradle.api.Project project)
Determines whether the produced artifacts should be published to Maven Central.
|
static boolean |
isSystemPropertySet(java.lang.String propertyName)
Checks that the parameter system property has a non-empty string that
does not evaluate to
false. |
static boolean |
isThirdPartyPublishingEnabled(org.gradle.api.Project project)
Determines whether publishing to Maven Central and the Gradle Plugin
Portal is enabled for the parameter project.
|
static void |
logPluginInclusion(org.gradle.api.Project project,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
Logs plugin inclusion for the project.
|
static void |
logProperties(org.gradle.api.Project project)
Logs the required and derived project properties.
|
static void |
logProperty(org.gradle.api.Project project,
java.lang.String displayName,
java.lang.String propertyName,
java.lang.StringBuilder builder)
Formats and logs a property.
|
static void |
logProperty(java.lang.String displayName,
java.lang.String displayValue,
java.lang.StringBuilder builder)
Formats and logs a property.
|
static boolean |
shouldApplyPlugin(org.gradle.api.Project project,
java.lang.String pluginId,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
Uses the
pluginInclusion map to determine whether the plugin
identified by the parameter identifier should be applied to the project. |
public static final java.lang.String ARTIFACTORY_PLUGIN_ID
public static final java.lang.String GRADLE_NEXUS_PUBLISH_PLUGIN_ID
public static final java.lang.String GRADLE_PLUGIN_PUBLISH_PLUGIN_ID
public static final java.lang.String GRGIT_PLUGIN_ID
public static final java.lang.String GROOVY_PLUGIN_ID
public static final java.lang.String JAVA_GRADLE_PLUGIN_ID
public static final java.lang.String JAVA_LIBRARY_PLUGIN_ID
public static final java.lang.String MAVEN_PUBLISH_PLUGIN_ID
public static final java.lang.String SHADOW_PLUGIN_ID
public static final java.lang.String SIGNING_PLUGIN_ID
public static final java.lang.String SONARQUBE_PLUGIN_ID
public static final java.util.List<java.lang.String> PLUGIN_IDS
public static java.util.List<java.lang.String> REQUIRED_PROPERTIES
public void apply(org.gradle.api.Project project)
apply in interface org.gradle.api.Plugin<org.gradle.api.Project>project - The project to configurepublic static void configurePluginInclusion(org.gradle.api.Project project,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
project - The project to configure.pluginInclusion - The predicates determining what plugins to apply.public static void logPluginInclusion(org.gradle.api.Project project,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
project - The project to configure.pluginInclusion - The predicates determining plugin inclusion.public static void configurePlugins(org.gradle.api.Project project,
java.util.List<java.lang.String> pluginIds,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
PLUGIN_IDS list.project - The project to configure.pluginIds - The plugin identifiers.pluginInclusion - Optional closures to check plugin inclusion.PLUGIN_IDSpublic static void configurePlugin(org.gradle.api.Project project,
java.lang.String id,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
pluginInclusion
map then it will only be applied if the value is present as a property on
the project with a non-empty value.project - The project to apply the plugin toid - The identifier of the plugin to applypluginInclusion - Optional closures to check plugin inclusionpublic static boolean shouldApplyPlugin(org.gradle.api.Project project,
java.lang.String pluginId,
java.util.Map<java.lang.String,java.util.function.Predicate<org.gradle.api.Project>> pluginInclusion)
pluginInclusion map to determine whether the plugin
identified by the parameter identifier should be applied to the project.project - The project being configuredpluginId - The plugin identifierpluginInclusion - Optional closures to check plugin inclusionpublic static void checkProjectProperties(org.gradle.api.Project project,
java.util.List<java.lang.String> requiredProperties)
project - The project to configurerequiredProperties - The properties that are required for the project.REQUIRED_PROPERTIESpublic static boolean isArtifactoryPublishingEnabled(org.gradle.api.Project project)
As of version 4.16.1, the Artifactory plugin can only be applied to the
root project using the plugins { .. } Gradle syntax. When the
plugin needs to be applied to subprojects, it has to be included as a build
script class path dependency and then applied using the
apply plugin: syntax. This plugin only supports applying the
Artifactory when configuring a root project. Multi-project builds can
instead be explicitly configured with a subprojects { .. }
clause in the root project.
project - The project to check.public static boolean isGitHosted(org.gradle.api.Project project)
isGitHosted project property, with a
non-empty value.project - The project to checkpublic static boolean isGradleApiDependedOn(org.gradle.api.Project project)
dependOnGradleApi project
property, with a non-empty value. Set this property only if the project
code depends on classes like GradleException or the like.project - The project to checkpublic static boolean isLocalGroovyDependedOn(org.gradle.api.Project project)
dependOnLocalGroovy project
property, with a non-empty value. Set this property only if the project
code includes Groovy files.project - The project to checkpublic static boolean isOpenSource(org.gradle.api.Project project)
project - The project to configurepublic static boolean isPluginPublishingEnabled(org.gradle.api.Project project)
Plugin publishing is only applicable for open source projects that define
the isOpenSource property with the value true.
Plugin publishing is enabled when the Gradle plugin key and secret project properties are provided, and the project build number is not SNAPSHOT.
project - The project being configuredpublic static boolean isShadowJarEnabled(org.gradle.api.Project project)
buildShadowJar project property, with a
non-empty value.project - The project to checkpublic static boolean isSigningEnabled(org.gradle.api.Project project)
signing.keyId, signing.password
and signing.secretKeyRingFile properties, with non-empty
values. The values are not checked.
The values should be set as described in the signing plugin documentation.
project - The project to checkpublic static boolean isSonarqubeEnabled()
sonar.host.url and sonar.login
properties, with a non-empty value. The values are not checked.
The sonar.login should be initialized with a Sonar
server token.
public static boolean isSonatypePublishingEnabled(org.gradle.api.Project project)
OSS publishing is only applicable for open source projects that define
the isOpenSource property with the value true.
Publishing is enabled when the signing properties are provided, and the project build number is not SNAPSHOT.
project - The project being configuredpublic static boolean isThirdPartyPublishingEnabled(org.gradle.api.Project project)
project - The project to check.public static boolean isProjectPropertySet(org.gradle.api.Project project,
java.lang.String propertyName)
false,or a non-empty collection value.project - The project to check.propertyName - The property name to check.public static boolean isSystemPropertySet(java.lang.String propertyName)
false.propertyName - The property name to checkpublic static boolean isPropertyValueSet(java.lang.Object value)
value - The value to check.public static boolean hasLicenses(org.gradle.api.Project project)
project.licenses property.project - The project to configurepublic static boolean hasReleaseVersion(org.gradle.api.Project project)
project - The project to check.public static boolean hasSnapshotVersion(org.gradle.api.Project project)
project - The project to check.public static void configureDerivedPropertiesWithoutPlugins(org.gradle.api.Project project)
project - The project to configurepublic static void configureDerivedPropertiesWithPlugins(org.gradle.api.Project project)
project - The project to configurepublic static void logProperties(org.gradle.api.Project project)
project - The project to configurepublic static void logProperty(org.gradle.api.Project project,
java.lang.String displayName,
java.lang.String propertyName,
java.lang.StringBuilder builder)
project - The project being configured.displayName - The display name of the property.propertyName - The actual name of the property.builder - The message builder to write to.public static void logProperty(java.lang.String displayName,
java.lang.String displayValue,
java.lang.StringBuilder builder)
displayName - The display name of the property.displayValue - The value to log.builder - The message builder to write to.public static void configureRepositories(org.gradle.api.Project project)
project - The project to configurepublic static void configureDependencies(org.gradle.api.Project project)
project - The project to configurepublic static void configureJavaPlugin(org.gradle.api.Project project)
project - The project to configurepublic static void configureJarTask(org.gradle.api.Project project)
project - The project to configurepublic static java.util.Map<java.lang.String,java.lang.String> createManifestAttributes(org.gradle.api.Project project)
project - The project to configure.public static void configureJarManifest(org.gradle.api.tasks.bundling.Jar jar,
java.util.Map<java.lang.String,java.lang.String> manifestAttributes)
jar - The jar to configure.manifestAttributes - The attributes to apply.public static void configureJarBaseName(org.gradle.api.tasks.bundling.Jar jar)
jar - The jar to configure.public static void configureJarAppendix(org.gradle.api.tasks.bundling.Jar jar)
jar - The jar to configure.public static void configureJarClassifier(org.gradle.api.tasks.bundling.Jar jar,
java.lang.String prefix,
java.lang.String suffix)
jar - The jar to configure.prefix - The classifier prefix.suffix - The classifier suffix.public static void configureJavadocJarTask(org.gradle.api.Project project)
project - The project to configurepublic static void configureSourceJarTask(org.gradle.api.Project project)
project - The project to configure.public static void configureShadowJarTask(org.gradle.api.Project project)
project - The project being configured.public static void configureArchives(org.gradle.api.Project project)
project - The project to configurepublic static void configureJavaPublishing(org.gradle.api.Project project)
project - The project to configure.public static void configureJavaPublishing(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPublication publication)
project - The project to configure.publication - The Maven publication being configured.public static void configureMavenPom(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPom pom)
project - The project being configured.pom - The POM to configure.public static void configureMavenPomDevelopers(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPomDeveloperSpec spec)
project - The project being configured.spec - The developers section specification.public static void configureMavenPomIssueManagement(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPomIssueManagement spec)
project - The project being configured.spec - The issue management section specification.public static void configureMavenPomLicenseSpec(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPomLicenseSpec spec)
project - The project being configured.spec - The licensing section specification.public static void configureMavenPomOrganization(org.gradle.api.Project project,
org.gradle.api.publish.maven.MavenPomOrganization spec)
project - The project being configured.spec - The organization section specification.public static void configureArtifactory(org.gradle.api.Project project)
Set mavenContextUrl, mavenRepoKey,
mavenUser and mavenToken to enable
Artifactory publishing.
project - The project to configurepublic static void configureSigning(org.gradle.api.Project project)
project - The project to configure.public static void configureSonatype(org.gradle.api.Project project)
Set sonatypeContextUrl, sonatypeRepoKey,
sonatypeSnapshotsRepositoryUrl,
sonatypeUser and
sonatypePassword to enable Sonatype publishing. Signing
must also be configured and the project must be marked open source.
project - The project to configureisSonatypePublishingEnabled(org.gradle.api.Project)public static java.lang.String formatSonatypeContextUrl(org.gradle.api.Project project,
java.lang.String propertyName,
java.lang.String description)
project - The project being configured.propertyName - The property name to take the URL from.description - The description of the context URL being formatted.public static void configureGradlePlugins(org.gradle.api.Project project)
project - The project to configureprotected static void configureGradlePlugin(org.gradle.api.Project project,
java.util.Map<java.lang.String,java.lang.String> spec,
org.gradle.plugin.devel.PluginDeclaration declaration)
project - The project being configured.spec - The Gradle plugin specification to configure.declaration - The plugin declaration being configured for the project.public static void configurePluginBundle(org.gradle.api.Project project)
Snapshot versions are not published.
Projects without an isOpenSource property that evaluates to
true are not published.
project - The project to configurepublic static void configureDefaultTasks(org.gradle.api.Project project)
local and all tasks and assigns
all as the project default.project - The project to configurepublic static java.lang.Object findPropertyOr(org.gradle.api.Project project,
java.lang.String propertyName,
java.lang.Object defaultValue)
gradle-rt which is not available.project - The project to look up a property value for.propertyName - The property name to look up.defaultValue - The default value to provide if no value is assigned.public static java.lang.String asString(org.gradle.api.Project project,
java.lang.String propertyName)
gradle-rt which is not available.project - The project to find the value for.propertyName - The name of the property to look up.groovy.lang.MissingPropertyException - If the project has no value for the property.