• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

nebula-plugins/gradle-extra-configurations-plugin: Gradle plugin introducing a p ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

nebula-plugins/gradle-extra-configurations-plugin

开源软件地址(OpenSource Url):

https://github.com/nebula-plugins/gradle-extra-configurations-plugin

开源编程语言(OpenSource Language):

Groovy 100.0%

开源软件介绍(OpenSource Introduction):

Nebula Extra Configurations

Support Status Gradle Plugin Portal Maven Central Build Apache 2.0

This plugin allows dependencies to be declared with a configuration or attribute not available in Gradle core.

  • optional

The following publishing plugins support the correct handling when generating the relevant metadata:

Usage

Adding the plugin binary to the build

To include, add the following to your build.gradle

plugins {
  id 'nebula.optional-base' version '3.0.3' // if you want optional-base
  id 'nebula.provided-base' version '3.0.3' // if you want provided-base
}

or

buildscript {
    repositories { mavenCentral() }

    dependencies {
        classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
    }
}

The JAR file comes with two plugins:

Plugin Identifier Depends On Type Description
provided-base - ProvidedBasePlugin Creates a new configuration named provided similar to providedCompile created by the War plugin.
optional-base - OptionalBasePlugin Provides an extra method for marking dependencies as optional.

To use the Provided plugin, include the following code snippet in your build script:

apply plugin: 'nebula.provided-base'

To use the Optional plugin, include the following code snippet in your build script:

apply plugin: 'nebula.optional-base'

Using the provided plugin

A dependency declared with the provided configuration is available on the compilation and test classpath. However, when publishing the outgoing artifact of the project (usually a JAR file) with Ivy or Maven, the dependency is not marked as required transitive dependency.

This is what the Maven documentation says:

provided - this is much like compile, but indicates you expect the JDK or a container to provide it at runtime. It is only available on the compilation and test classpath, and is not transitive.

Impact on metadata created when publishing artifact

When publishing a provided dependency to a Maven repository the declaration in the POM looks as such:

<project>
    ...
    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.2</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    ...
</project>

When publishing a provided dependency to an Ivy repository the declaration in the Ivy file looks as such:

<ivy-module>
    <configurations>
        ...
        <conf name="provided" visibility="public"/>
    </configurations>
    ...
    <dependencies>
        <dependency org="org.apache.commons" name="commons-lang3" rev="3.3.2" conf="provided"/>
    </dependencies>
</ivy-module>

Usage example

apply plugin: 'java'
apply plugin: 'nebula.provided-base'

repositories {
    mavenCentral()
}

dependencies {
    provided 'org.apache.commons:commons-lang3:3.3.2'
    provided group: 'log4j', name: 'log4j', version: '1.2.17'
}

Using the optional plugin

A dependency marked with the optional attribute is a dependency that is not necessarily meant to be required. The idea is that some of the dependencies are only used for certain features in the project, and will not be needed if that feature isn't used. For more information, please have a look at the Maven documentation.

Impact on metadata created when publishing artifact

When publishing a optional dependency to a Maven repository the declaration in the POM looks as such:

<project>
    ...
    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.2</version>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>
    </dependencies>
    ...
</project>

When publishing a optional dependency to an Ivy repository the declaration in the Ivy file looks as such:

<ivy-module>
    <configurations>
        ...
        <conf name="optional" visibility="public"/>
    </configurations>
    ...
    <dependencies>
        <dependency org="org.apache.commons" name="commons-lang3" rev="3.3.2" conf="optional"/>
    </dependencies>
</ivy-module>

Usage example

apply plugin: 'java'
apply plugin: 'nebula.optional-base'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.apache.commons:commons-lang3:3.3.2', optional
    compile group: 'log4j', name: 'log4j', version: '1.2.17', optional
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap