Why do I have to restart Intellij for it to recognize Lombok annotations? - intellij-idea

I am using intellij & Lombok & I have annotation processor set to enabled.
IntelliJ IDEA 2020.2 (Community Edition)
Build #IC-202.6397.94, built on July 27, 2020
Runtime version: 11.0.7+10-b944.20 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux XXXX
GC: ParNew, ConcurrentMarkSweep
Memory: XXXXM
Cores: XX
Non-Bundled Plugins: color.scheme.Gruvbox, Lombook Plugin, org.intellij.scala
Current Desktop: KDE
And using Lobmok: 0.30-EAP
When I create a class like so:
#Builder
#Getter
public class Stub {
private final int f1;
private final long f2;
}
Or if I add a field to an existing class Intellij Complains that: Variable 'f1' might not have been initialized.
If I restart Intellij the error goes away.
Build/Recompiling the class doesn't help
Maven reload proejct doesn't help
Build/Build the project doesn't help

IntelliJ IDEA 2020.2 has a known issue affecting Lombok plug-in. It's fixed in 2020.2.1 release. Please update.

Related

Error creating Groovy class with latest release of IntelliJ Idea

I am using the latest version of the Community Edition of IntelliJ Idea ( 2021.2 ) with the Groovy plugin ( 212.4746.92 ) on a Windows 10 box.
I created a very simple Groovy class:
class HWClass {
static void main(String[] args) {
// Using a simple println statement to print output to the console
println('Hello World');
}
}
When I try and run the Groovy class I get :
java.util.concurrent.ExecutionException: java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
I have verified my project setup many times ...I have my Platform Settings SDK set to OpenJDK 12 and my Global Libraries references my Groovy 3.0.8 installation. Note that this is a new release of IntelliJ Idea I am using ( 2021.2 ) ...I am aware of a known bug in this release of IntelliJ ( https://youtrack.jetbrains.com/issue/IDEA-275043 ) with Groovy Scripts but am unaware of any issues with Groovy classes... any thoughts ?

Gradle build doing nothing on WSL

I'm writing a Kotlin program, and using Gradle as the build system, as is customary in that language. I usually work on Windows, but it's time to start testing on Linux, so using WSL for that. Installed Gradle, cloned a copy of my code in WSL...
(base) a#DESKTOP-4B7M920:~/ayane$ gradle -version
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/usr/share/java/groovy-all.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
------------------------------------------------------------
Gradle 4.4.1
------------------------------------------------------------
Build time: 2012-12-21 00:00:00 UTC
Revision: none
Groovy: 2.4.16
Ant: Apache Ant(TM) version 1.10.5 compiled on March 28 2019
JVM: 11.0.7 (Ubuntu 11.0.7+10-post-Ubuntu-2ubuntu218.04)
So far so good, that warning happens sometimes, doesn't seem to portend immediate trouble.
This is my build file, that works on Windows:
(base) a#DESKTOP-4B7M920:~/ayane$ cat build.gradle.kts
plugins {
kotlin("jvm") version "1.3.72"
}
repositories {
jcenter()
}
dependencies {
implementation(kotlin("stdlib"))
testImplementation("org.junit.jupiter:junit-jupiter:5.6.2")
}
tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
Here goes.
(base) a#DESKTOP-4B7M920:~/ayane$ gradle build
> Task :buildEnvironment
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
No dependencies
BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
<-------------> 0% WAITING
Uh? I could understand if it threw an error because some prerequisite or other was unavailable. But no error, just nothing? What's going on?
You are using the newest version at this time of the Kotlin plugin for Gradle (1.3.72). However, you are using a really old version of Gradle (4.4.1). As you can read from the Kotlin documentation:
The Kotlin Gradle plugin 1.3.72 works with Gradle 4.9 and later.
It is unfortunate that the plugin doesn't check for this and give a more proper error message instead of just silently doing nothing. I guess you could create an issue for Jetbrains on this if you like.
Just as has been mentioned in the comment to your question, I also highly recommend using the wrapper. It ensures that the project is built with a particular declared version of Gradle that you, the build author, has decided on. Otherwise, you will have to document how to set up the environment correctly, including what version of Gradle to install.
Same thing goes for Java: be sure to clearly document which version is required or supported.
As for building in WSL, the only issue I've ever had with it was a remote build cache not working. This was because I had configured Git to checkout with POSIX line endings (LF) for source files, whereas the cache were populated on a Windows machine using CRLF line endings). It doesn't sound like you are using that feature, but other than that, everything has been working fine for me in WSL.

Issue with Spring-Boot-Devtools compatibility with Intellij IDEA, compiltion error on Spring-Boot-Devtools live-reload

I am facing hard time in the live reload using Spring-Boot-Devtools. Every time I update my controller class, the spring couldn't find the dependencies which are injected using constructor injection.
Suppose I am having this class
class MyController{
private MyService myService;
public MyController(MyService myService){
this.myService= myService;
}
//controller methods
}
Changes to any of the controller methods or the MyService's methods would result in some error like: constructor in com.example.MyController required a bean of type 'com.example.MyService' that could not be found
Whereas if I run the same code on the Eclipse, the live reload works fine.
IntelliJ IDEA 2019.1.2 (Ultimate Edition)
JRE: 1.8.0_202-release-1483-b49 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6

Quarkus gradle test fails

I am trying to run the simple 'getting-started'-type gradle project with quarkus and my unit test fails everytime with this error
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to locate project pom.xml for C:\Users\myuser\IdeaProjects\myproj\build\classes\java\main
Followed instructions here https://quarkus.io/guides/gradle-tooling
Any suggestions or thoughts on what is going on?
Gradle version details
Gradle 5.4
Build time: 2019-04-16 02:44:16 UTC
Revision: a4f3f91a30d4e36d82cc7592c4a0726df52aba0d
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.2 (Oracle Corporation 11.0.2+9)
OS: Windows 10 10.0 amd64
btw. the problem is still open (current version 0.19.1) and issue (2307) is still unresolved.
The reason is that #QuarkusTest points to the QuarkusTestExtension, which in BootstrapClassLoaderFactory.newDeploymentClassLoader attempts to resolve local project with Maven.
We have options:
wait for official solution (see issue)
write own extension overriding BootstrapClassLoaderFactory to "understand" gradle project structure
apply a workaround (for time being), i.e. generate pom.xml from gradle build
Workaround
in build.grade:
plugins {
id 'java'
id 'io.quarkus' version '0.19.1'
// ...
id 'maven-publish'
}
// ...
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
// augment your pom here if necessary
}
}
}
// ...
task createPom(type: Copy) {
description 'This is workaround to generate pom.xml, needed for #QuarkusTest tests.'
dependsOn('generatePomFileForMavenJavaPublication')
from "$buildDir/publications/mavenJava/pom-default.xml"
into '.'
rename('pom-default.xml', 'pom.xml')
}
Note:
use 'maven-publish', not obsolete 'maven' plugin.
do not forget to apply ./gradlew createPom on dependencies changes

Could not compile project in Intellij Idea 13 EAP/12.1.5 due to Lombok usages

While trying Intellij Idea 13 EAP ( which I'm aware is not stable ) I could not compile/run a working project because of the following warning:
java: lombok.javac.apt.Processor could not be initialized. Lombok will not run during this compilation: java.lang.ClassCastException: com.sun.tools.javac.processing.JavacProcessingEnvironment cannot be cast to com.sun.tools.javac.processing.JavacProcessingEnvironment
at lombok.javac.apt.Processor.init(Processor.java:84)
at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:89)
at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:143)
It's working very well with Intellij Idea 12, but I need to run on 13 because of an another issue fixed only in 13 (IDEA-104616)
This error comes up:
com.sun.tools.javac.processing.JavacProcessingEnvironment cannot be cast to com.sun.tools.javac.processing.JavacProcessingEnvironment
Update:
Created JetBrains issue: IDEA-114130
It is an Intellij IDEA issue: IDEA-114130
Fixed in build 132.474
Note: Reproducible in Intellij IDEA 12.1.5; avoid upgrade (in case of Lombok use) !
UPDATE:
FIxed version is publicly released.