All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gradle.plugin.use.PluginDependenciesSpec Maven / Gradle / Ivy

/*
 * Copyright 2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.plugin.use;

/**
 * The DSL for declaring plugins to use in a script.
 * 

* In a build script, the plugins {} script block API is of this type. * That is, you can use this API in the body of the plugins script block to declare plugins to be used for the script. *

*

Relationship with the apply() method

*

* The plugins {} block serves a similar purpose to the {@link org.gradle.api.plugins.PluginAware#apply(java.util.Map)} method * that can be used to apply a plugin directly to a {@code Project} object or similar. * A key difference is that plugins applied via the plugins {} block are conceptually applied to the script, and by extension the script target. * At this time there is no observable practical difference between the two approaches with regard to the end result. *

*

Strict Syntax

*

* The plugins {} block only allows a strict subset of the full build script programming language. * Only the API of this type can be used, and values must be literal (e.g. constant strings, not variables). * Moreover, the plugins {} block must be the first code of a build script. * There is one exception to this, in that the {@code buildscript {}} block (used for declaring script dependencies) must precede it. *

*

* This implies the following constraints: *

*
    *
  • Only {@link #id(String)} method calls may be top level statements
  • *
  • {@link #id(String)} calls may only be followed by a {@link PluginDependencySpec#version(String)} and/or {@link PluginDependencySpec#apply(boolean)} method call on the returned object
  • *
  • {@link #id(String)}, {@link PluginDependencySpec#version(String)} and {@link PluginDependencySpec#apply(boolean)} methods must be called with a literal argument (i.e. not a variable)
  • *
  • The plugins {} script block must follow any buildscript {} script block, but must precede all other logic in the script
  • *
*

Available Plugins

*

Core Plugins

*

* Core Gradle plugins are able to be applied using the plugins {} block. * Core plugins must be specified without a version number, and can have a qualified or unqualified id. * That is, the {@code java} plugin can be used via: *

*
 * plugins {
 *   id 'java'
 * }
 * 
*

* Or via: *

*
 * plugins {
 *   id 'org.gradle.java'
 * }
 * 
*

* Core Gradle plugins use the {@code org.gradle} namespace. *

*

* For the list of available core plugins for a particular Gradle version, please consult the user manual. *

*

Community Plugins

*

* Non-core plugins are available from the Gradle Plugin Portal. * These plugins are contributed by users of Gradle to extend Gradle's functionality. * Visit plugins.gradle.org to browse the available plugins and versions. *

*

* To use a community plugin, the fully qualified id must be specified along with a version. *

*/ public interface PluginDependenciesSpec { /** * Add a dependency on the plugin with the given id. * *
     * plugins {
     *     id "org.company.myplugin"
     * }
     * 
* Further constraints (e.g. version number) can be specified by the methods of the return value. *
     * plugins {
     *     id "org.company.myplugin" version "1.3"
     * }
     * 
* * Plugins are automatically applied to the current script by default. This can be disabled using the {@code apply false} option: * *
     * plugins {
     *     id "org.company.myplugin" version "1.3" apply false
     * }
     * 
* * This is useful to reuse task classes from a plugin or to apply it to some other target than the current script. * * @param id the id of the plugin to depend on * @return a mutable plugin dependency specification that can be used to further refine the dependency */ PluginDependencySpec id(String id); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy