1

I am experimenting with Gradle/IntelliJ and various Java builders/containers. However, I am unable to configure both org.inferred.FreeBuilder and com.google.auto.value.AutoValue in the same project.

With the build.gradle file below, I am able to successfully compile a class annatoted with AutoValue, (Animal example from AutoValue documentation).

However, as soon as I uncomment "id 'org.inferred.processors" and "processor 'org.inferred:freebuilder:1.14.6'" I get

:processorPath \main\java\example\com\Animal.java:12: error: cannot find symbol return new AutoValue_Animal(name, numberOfLegs); ^ symbol: class AutoValue_Animal location: class Animal 1 error :compileJava FAILED

plugins {
    id 'java'
    id 'idea'
    id 'net.ltgt.apt-idea'  version '0.13'
    // id 'org.inferred.processors' version '1.2.15'
}

version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.auto.value:auto-value:1.5.1'
    apt 'com.google.auto.value:auto-value:1.5.1'

    //processor 'org.inferred:freebuilder:1.14.6'
}

jar {
    from {
        (configurations.runtime).collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
    manifest {
        attributes 'Main-Class': 'example.com.Main'
    }
}

idea {
    project {
        // experimental: whether annotation processing will be configured in the IDE; only actually used with the 'idea' task.
        configureAnnotationProcessing = true
    }
    module {
        apt {
            // whether generated sources dirs are added as generated sources root
            addGeneratedSourcesDirs = true
            // whether the apt and testApt dependencies are added as module dependencies
            addAptDependencies = true

            // The following are mostly internal details; you shouldn't ever need to configure them.
            // whether the compileOnly and testCompileOnly dependencies are added as module dependencies
            addCompileOnlyDependencies = false // defaults to true in Gradle < 2.12
            // the dependency scope used for apt and/or compileOnly dependencies (when enabled above)
            mainDependenciesScope = "PROVIDED" // defaults to "COMPILE" in Gradle < 3.4, or when using the Gradle integration in IntelliJ IDEA
        }
    }
}

I am trying to extract information out of these source:

tkruse
  • 10,222
  • 7
  • 53
  • 80
Leon
  • 1,141
  • 13
  • 25
  • I did something similar to you here: https://github.com/tkruse/beantest. might help you get started. I am using different gradle plugins. – tkruse Jan 05 '18 at 00:23

1 Answers1

1

You can use both gradle dependencies in your project, but not both their gradle plugins. Neither should you need to.

You just need one gradle plugin for annotation processor support (any of them), and then all bean processor dependencies should work.

tkruse
  • 10,222
  • 7
  • 53
  • 80
  • +1ed. Looks like we ran into similar problems. Thanks for the git repo, awesome. I haev one things which I still cannot figure out. My generated flies go to build/classes folder. I have tried enabling processor handling but that didnt help. Any suggestions? – Leon Jan 08 '18 at 14:05
  • playing around with beantest, seems like generated classes go to target/generated-sources for maven.compile but not for gradle.compileJava – Leon Jan 08 '18 at 14:21
  • happy to try to contribute. I find the discoverability of gradle configs very poor. Any pointers of where to find the parameters that I need to configure? – Leon Jan 09 '18 at 10:56
  • thanks. seems like this will do the trick. https://stackoverflow.com/a/37822882/541765 – Leon Jan 09 '18 at 12:30