Enable annotation processing

See original GitHub issue

Hi, I’m trying to use https://github.com/immutables/immutables which is an annotation based source code generator.

In the docs (https://immutables.github.io/apt.html), it’s mentioned that the m2e-apt Eclipse plugin needs to be configured when building in Eclipse, so presumably this is why in vscode it doesn’t work?

I was previously having problems with Rocker templates, and with hindsight this might have been related.

Environment
  • Operating System: xubuntu yakkety
  • JDK version: 1.8.0_131-b11
  • Visual Studio Code version: 1.17.1
  • Java extension version: 0.12.0
  • Maven 3.5
  • Maven compiler plugin 3.6
Steps To Reproduce

https://immutables.github.io/getstarted.html

  1. Set up a Maven project that includes the org.immutables dependency
  2. Add a test class that uses the @Value.Immutable annotation
  3. vs-code-java fails to generate the source code, but a mvn compile will
Current Result

No generated source code for @Value.Immutable annotated class

Expected Result

Corresponding Immutable... class source code generated

Additional Informations

I tried adding org.jboss.tools.maven.apt.core_1.3.0.201610261805 to the extension’s server/plugins folder to see if that allowed the annotation processor to be picked up, but it wasn’t effective. I also tried putting the Immutables jar in the annotationProcessorPaths element in the maven compile plugin configuration, but it still wasn’t picked up.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

12reactions
simon04commented, Jul 20, 2018

Is Gradle supported as well? Having the following in build.gradle, I keep getting “[Java] AutoValue_Remark cannot be resolved to a type” errors in my project.

dependencies {
    compile 'com.google.auto.value:auto-value-annotations:1.6.2'
    annotationProcessor 'com.google.auto.value:auto-value:1.6.2'
}

(Version 0.28.0)

6reactions
maelvlscommented, Mar 6, 2019

@simon04 I found a simple workaround for using Gradle with the annotationProcessor features (Immutables, AutoValue, Metamodels).

The idea is to add manually the location of the generated sources. In my case, I just had to add build/generated/source/apt/main to srcDirs:

sourceSets {
    main {
        java {
            srcDirs = ['src/main/java', 'build/generated/source/apt/main']
        }
    }
}

I don’t know if it is a good idea or whatever, but it works and helps me get the job done 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure annotation processors | IntelliJ IDEA Documentation
Select the desired annotation profile. · Select Enable annotation processing and configure the following options: Obtain processors from project ...
Read more >
Enable Annotation processors by default - intellij idea
File | Other Settings | Default Settings , navigate to the compiler settings, annotation processing and enable this option before importing the ...
Read more >
Using annotation processor in IDE - Immutables
IntelliJ IDEA ————- To configure annotation processing in IntelliJ IDEA, use dialog Preferences > Project Settings > Compiler > Annotation Processors. Obtain ...
Read more >
Chapter 12. Annotation Processor
Go to "File", then "Settings",; Expand the node "Compiler", then "Annotation Processors"; Choose "Enable annotation processing" and enter the following as " ...
Read more >
Java Annotation Processing and Creating a Builder - Baeldung
The maven-compiler-plugin allows specifying annotation processors as part of its configuration. Here's an example of adding annotation processor ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found