Can't run Java with specific dependecy - java

I use Intellij 2018.1 and when i add to my project a serenity-cucumber dependency with latest versions, the run and debug button doesn't work anymore. (It's strange that maven it's able to run the tests with no problem).
I tried and built the simplest project with hello world and just with that dependency. No success, same situation. When i've gone to version 1.9.8(maybe there are newer versions that could work, i will try), the intellij started to work normal.
Also tried to change project sdk and project language level.
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>1.9.35</version>
<dependency>
Now the program works with that older version, but it doesn't generate the report well. Maybe i will find a solution to run the tests with intellij with debug mode using last version.

Related

How to get Eclipse to work properly with Gradle?

I am trying out Eclipse (because of frustrations with apparent version incompatibilities when upgrading another IDE), but it is proving equally problematic. This is a perfectly clean Eclipse installation (windows installer, second variant option), so it's an ootb issue.
(Simplified, theoretically-reproducable version): I downloaded two copies of a basic Java 17 project from Spring Initializr with no dependencies; one as Gradle, one as Maven (tester & tester2 respectively). The Gradle build shows errors where there are none, per the screenshot.
Note that in the one class in the besic, clean SpringBoot application, it sees the package name, the class name, and even the definition of String as being errors. But the same code in the Maven version is fine.
There are further issues that appear to derive from this, but keeping it simpleā€¦
At some point during my testing, some message/error showed up that suggested it was building with Gradle 6.8.3, which I believe would be a problem as that version doesn't support Java 16+. Eclipse is configured to use 7.3.
How do I tell Eclipse to recognise a valid project, so it can be worked with?

Update IntelliJ default Gradle version

When starting a new project I get the message unsupported JDK. Using Gradle 7.1. I want to update that default Gradle to 7.3-rc-1.
However, I just can't seem to find where to do this outside of a specific project. I am not sure where IntelliJ obtains it's Gradle version, and it has auto-updated in the past.
Sure I could update it afterwards, but as IntelliJ seems to break on trying to create folders and doesn't go back to do it once Gradle is updated. It would save a lot of headache for IntelliJ and myself to update or force it to use the version I want before the project creation.
https://i.stack.imgur.com/TLyxF.png
IntelliJ bundles version of Gradle much like it bundles a version of the JDK. In order to upgrade the bundled version of Gradle, you must update Intellij. However, there is no guarantee that an updated version of IntelliJ will come with an updated version of Gradle.

How do I use an older version of SpringBoot on a project?

Recently I bought a course on Udemy of Java SpringBoot, and it requires the 2.3.4 version, but this version is not available anymore to create a project. I'm using IntelliJ IDEA Ultimate 2021.2.1.
I tried changing the pom.xml file but it didn't work out, as I got the error: "Could not find artifact org.springframework.boot:spring-boot-starter-parent:pom:2.3.4 in central".
So far, I tried changing the IDE for SpringToolSuite4 and asking for Maven to update the project and running mvn -U clean install, but still didn't work.
Is there anything I can do to fix this ?
Spring Boot Versions before 2.4.X have had been version definition like 2.3.4.RELEASE ... instead of 2.3.4.
https://search.maven.org/artifact/org.springframework.boot/spring-boot-starter-parent

Lombok not working with IntelliJ 2020.3 Community Edition

I worked with Lombok without any problems until Today, when my Intellij was automatically updated to the latest version 2020.3 30th, November build. After that, any Lombok annotations is not recognised anymore.
My Java project still build from command line with Maven but annotations are completely ignored in the project and cannot run any unit tests manually.
Things I tried so far:
Reinstalled the Lombok plugin
Restarted Intellij
Restarted the laptop
Invalidated the cache
Re-cloned the project from github
Checked that the annotation processor is enabled
Nothing worked. What could have happened? Any idea on what I can try to do?
To summarize go to IntelliJ Preferences (Cmd + ,)
Preferences -> Build, Execution, Deployment -> Compiler
search for this option:
User-local build process VM options (overrides Shared options):
and add this value:
-Djps.track.ap.dependencies=false
A work around is here, until they fix the actual problem:
https://youtrack.jetbrains.com/issue/IDEA-250718#focus=Comments-27-4418347.0-0
(see screenshoot for IJ fix)
I was using Lombok fine with 2020.2 and plugin, but in 2020.3.1 it should be (and it is) included
...but I had compilation errors like Cannot resolve symbol 'log' (when using #Slf4j)
I solved the problem deleting .idea from project and opened it again...
edit: it happened to me again today with new checkout (we do not have .idea in Git) and I had similar problem. Not sure if that was a fix, but I checked the plugin (it is not on screenshot above), it started working after, but I built it from cmd (Maven) and tried few other things, so I'm not sure what is a real fix
My problem was related to my lombok version
Before upgrade my IntelliJ to 2020.03 my lombok version was 1.18.10 and the lombok plugin 0.32-EAP
After upgrade my lombok dependency to 1.18.16 it start work again without any issues. Looks like the plugin is not bundled yet in the community edition.
I don't if is necessary, but my first action was to uninstall the plugin when I read the README on Lombok Plugin repo
Please check in: Lombok plugin settings you didn't disable it unintentionally.
Seems like lombok is not bundled in Community edition of 2020.3 version. Fix is expected in 2020.3.1 version.
From Lombok plugin GitHub issue
Sorry guys, I have to confirm, it was forgotten to add it properly
into the last community build. See bug on Jetbrains Yourtrack:
https://youtrack.jetbrains.com/issue/IDEA-257311
The Ultimate 2020.3 version contains lombok plugin as expected per
default.
lombok plugin should be included in both IntelliJ distribution
(Ultimate and Community) starting with 2020.3 release. Something get
wrong, we are working to fix it.
Fix is now planned for IntelliJ Community release 2020.3.1
Update
2020.3.1 Community is released and contains lombok plugin by default now
I managed to make it work on a gradle project (Intellij 2020.3.2)
by using exactly this in build.gradle :
annotationProcessor 'org.projectlombok:lombok:1.18.18'
implementation 'org.projectlombok:lombok:1.18.18'
I think important point is to declare it as "annotationProcessor" to include it in the gradle build.
I did not even have to mess around with "User-local build process VM options" and even "Enable Annotation Processing" is not ticked in Intellij Settings.
So I guess that gradle is taking care of the Lombok generation, and not IDEA.
but at least it finally works after hours lost trying to fix IntelliJ.
This is the problem with lombok, whenever IntelliJ provides upgrade lombok starts crying. Same happened with IntelliJ 2020.2
Now there are 2 solutions
Wait till the developers of lombok provide upgrade compatible with IntelliJ 2020.3
Downgrade IntelliJ to previous working version. For me IntelliJ 2020.2 worked perfectly fine.
Installing Lombok plugin and enabling the annotation processor should do the needful. If still issue persists then i think you should report a bug and see what they reply.

Java 11 Methods are not recognised in IntelliJ even after importing them correctly

I have started a new Java 11 Project with the newest Version of the IntelliJ IDEA Community Edition (IntelliJ IDEA 2018.3.5).
Everything seemed to work just fine for a while, but then some MethodCalls from imported modules were not recognised without any obvious reason. I've already tried invalidating the cache, but it did nothing. I'm also using maven 3.6.0 as I stumbled upon a post which suggested that the maven version that comes with said IDEA is not compatible with Java 11.
More specifically I tried using the method Optional.ofNullable() (same with of() or any other method of this class) which IntelliJ even proposed with AutoComplete. After auto-completion however IntelliJ seems to have forgotten it just now knew the method and proclaims: "Cannot find symbol: class ofNullable". The funny thing is: I can even Ctrl-Click Optional to be directed to the class and see that the method is actually there.
I'm at a loss. Has somebody experienced a similar problem?
I have solved this problem as follows for the Spring boot project with the Gradle build tool.
IntelliJ-Idea version should support Java-11.
Bigger scope to narrower scope
(IDE support --> Build tool --> Project setting --> Modules setting --> application run setting)
Add Java-11 SDK in Idea-IDE
Change Gradle JVM to Java-11
Change Project SDK and Language Level to Java-11
Change Module Language Level to Java-11
Change modules SDK to Java-11
Application run configuration to Java-11

Categories