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

tbroyer/gradle-incap-helper: Helper library and annotation processor for buildin ...

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

开源软件名称(OpenSource Name):

tbroyer/gradle-incap-helper

开源软件地址(OpenSource Url):

https://github.com/tbroyer/gradle-incap-helper

开源编程语言(OpenSource Language):

Java 56.3%

开源软件介绍(OpenSource Introduction):

gradle-incap-helper

Helper library and annotation processor for building incremental annotation processors

Gradle 4.7 comes with some level incremental annotation processing support. Gradle 4.8 goes farther by making it possibly dynamic.

This library and annotation processor helps you generate the META-INF descriptor, and return the appropriate value from your processor's getSupportedOptions() if it's dynamic.

Usage

  1. Add the incap library to your compile-time dependencies, and the incap-processor to your annotation processor path:

    with Gradle
    dependencies {
        compileOnly("net.ltgt.gradle.incap:incap:${incap.version}")
        annotationProcessor("net.ltgt.gradle.incap:incap-processor:${incap.version}")
    }
    with Maven
    <dependencies>
        <dependency>
            <groupId>net.ltgt.gradle.incap</groupId>
            <artifactId>incap</artifactId>
            <version>${incap.version}</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>net.ltgt.gradle.incap</groupId>
                            <artifactId>incap-processor</artifactId>
                            <version>${incap.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

    Note: it's OK to use compileOnly in Gradle, or the provided scope in Maven, despite the annotation having class retention, because annotation processors aren't libraries that others compile against.

  2. Annotate your annotation processor with @IncrementalAnnotationProcessor

    @IncrementalAnnotationProcessor(ISOLATING)
    public class MyProcessor extends AbstractProcessor {
  3. If the choice of incrementality support is dynamic (i.e. you used the DYNAMIC value above), use the IncrementalAnnotationProcessorType enumeration's getProcessorOption() from your getSupportedOptions() to get the appropriate constant.

    @Override
    public Set<String> getSupportedOptions() {
        if (someCondition) {
            return Collections.singleton(ISOLATING.getProcessorOption());
        } else {
            return Collections.emptySet();
        }
    }

Acknowledgements

This processor works great with @AutoService, which also inspired some of the code here.

Shout-out Gradle, Inc. (and Groupon) who built this feature.




鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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