Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Run annotation processors as part of the gradle idea task #76

Open
jroitgrund opened this issue Aug 14, 2017 · 5 comments
Open

Run annotation processors as part of the gradle idea task #76

jroitgrund opened this issue Aug 14, 2017 · 5 comments

Comments

@jroitgrund
Copy link

Current behavior: when switching to a new branch that has different dependencies, I need to run gradle idea to fetch those, and then I need to run Rebuild Project in IntelliJ to run the annotation processors again.

Desired behavior: gradle idea also runs the annotation processors such that checking out a commit and running gradle idea is sufficient to start coding.

@alicederyn
Copy link
Contributor

Running javac is the responsibility of IntelliJ, not Gradle. You don't want a code typo preventing you generating the IntelliJ project.

@jroitgrund
Copy link
Author

jroitgrund commented Aug 14, 2017 via email

@alicederyn
Copy link
Contributor

No, I mean gradle idea doesn't run compileJava, so the sources aren't necessarily present nor up-to-date :/

@aouledissa
Copy link

I am seeking help here as i couldn't find any valuable resource else where. I am trying to have my custom plugin create a task that when run, it should trigger an annotation processing process.
Do you know how to configure this task so it does so? is that even possible?
PS: My tasks are written in kotlin but i don't mind groovy examples.
Thanks in advance

@aouledissa
Copy link

I am seeking help here as i couldn't find any valuable resource else where. I am trying to have my custom plugin create a task that when run, it should trigger an annotation processing process.
Do you know how to configure this task so it does so? is that even possible?
PS: My tasks are written in kotlin but i don't mind groovy examples.
Thanks in advance

Yep this is possible and here is my task configs

tasks.register(
"myTaskName",
JavaCompile::class.java
) {
    compiler ->
    with(compiler.options) {
        isFork = true
        isIncremental = true
    }
    with(compiler) {
        group = shuttle.plugin.ShuttlePlugin.TASK_GROUP
        destinationDir = outputDir
        classpath = variant.getCompileClasspath(null)
        options.annotationProcessorPath = variant.getCompileClasspath(null) //this is the missing piece!!
        source = files(projectDir.resolve("src/main/java")).asFileTree
    }
}

Hope this could be helpful to someone.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants