Coder Social home page Coder Social logo

tmtron / gradle-incap-helper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tbroyer/gradle-incap-helper

0.0 2.0 0.0 71 KB

Helper library and annotation processor for building incremental annotation processors

License: Apache License 2.0

Kotlin 35.41% Java 64.59%

gradle-incap-helper's 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>
  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.

gradle-incap-helper's People

Contributors

tbroyer avatar

Watchers

James Cloos avatar TMTron avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.