Multiple errors when importing Gradle project - java

I wanted to read the source code of a java project, so I cloned the project into a directory, and opened it in VSCode. The project used gradle as a dependency manager. None of the dependencies were downloaded, so I ran
gradle --refresh-dependencies
This seemed to work in getting everything setup, but there were many different errors such as
Cannot make a static reference to the non-static method reload() from the type FastRegistry
This error seemed to be the most common, but VSCode reports 2000 errors. I should mention that this project is a Minecraft Mod, so there may be some conflict with the source code and the mapped class names. I am still a beginner at this kind of stuff, so hopefully there is a simple solution. Here is a link to the project: https://github.com/PorkStudios/FarPlaneTwo/

After asking the project owner about this, I found that this project uses lombok annotations. Because of the weirdly formatted annotations, everything was thrown off.
To fix this for VSCode, which does not support these annotations by default, install the extensions for it.
In addition to this, if you have already loaded the project, you will need to clean the workspace.

Related

IntelliJ can't load Maven dependency

I'm using IntelliJ IDEA Community 2020.2.3.
My project is built around Kotlin 1.3.30 and Java 11.
I've upgraded one of my dependecy to java 11 too, and after that, the IDE shows the dependency under "External Libraries", it build the app without errors, Maven build it from terminal without error, but the IDE shows unresolved references on each occurrency of the classes, functions and imports of that library.
I already tried to empty the cache or deleting idea files and importing again the project, but none of those worked.
Any tips?
You can use CTRL+SHIFT+A and look for Load Maven Changes or CTRL+SHIRT+O to do the same thing

Why does external dependencies added in Project Structure doesn't appear in compile time (Intellij)?

So I've created a library which is not released as not tested, so I'm importing it manually using the Project structure to test it out, just like explained in here.
Here's a snapshot as well:
And it even seems that it is imported in the intellij as it is shown in the editor, as well as I can navigate to its definition.
But unfortunately the build fails see this:
And i tried changing the scoped of the dependency, but nothing worked.
How could I solve this, any help would be appreciated 😊.
Finally i got it working by removing external dependencies I had added manually from Intellij IDEA's Project structure.
And add the external dependencies by using the gradle:
compile files('path/to/the/jar/my-plugin.main.jar')
This file() uses project's folder as root, then we can navigate through that.
Issue may have been occured because of using both gradle and intellij project management at the same time.
Hopefully if somebody having same issue, he/she may fix it using gradle.

Package accessible from more than one module in Eclipse RCP

I updated an Eclipse RCP Project from Eclipse 2019-12 to 2020-03. After the update I get build errors on export, like the following:
"The package javax.xml.parsers is accessible from more than one module: , java.xml".
I am using Java 11, no module-info.java file, the Eclipse 3 Compatibility Layer and the eclipse product export wizard in my project.
The error message basically is clear to me. It detects some class twice on classpath, which is not allowed. Once the class is provided by JDK module "java.xml". The second copy comes from javax.xml osgi bundle.
My problem is that both of the packages can not be removed. The JDK module has a lot of dependent JDK modules that are actively used in code and I don't think that they can be supplemented by some libraries. The OSGI bundle is used by a lot of very basic eclipse bundles. So it can also not be removed.
So I have two questions:
Why does Eclipse RCP break projects with its new version? Was that considered a bug before? (I did not find a ticket)
How can I get my project to run again without really big changes?
Edit 1: Added reproducible example:
https://workupload.com/file/wKUZTXJXsR9
Edit 2: See also Eclipse Bug Ticket:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=562761
I created a minimum example. One can see the problem by exporting the product via wizard. I used DocumentBuilderFactory from javax.xml in Application.java to trigger the problem.
I found out a few things:
A plugin dependency to org.eclipse.help.ui is needed to trigger the problem. Although also other plugins have dependencies to javax.xml plugin.
Eclipse tells you the problem in Editor if I you add a direct dependency to javax.xml plugin. But we have only a transitive dependency to it and therefor get no hint.
That raises some new questions:
It seems that org.eclipse.help.ui plugin causes the problem, but we need it in our application. Is this a possible bug? Are there alternatives?
Why does eclipse editor not show the problem if I only have a transitive dependency to javax.xml plugin? Also a possible bug?
I found a workaround for this problem: When using a target definition (*.target file) instead of the Running Platform (automatic target definition of the Eclipse IDE) the error does simply not occur! I don't know exactly what the difference is between these two targets, since they both contain the "javax.xml" bundle. But when using the target file the "javax.xml" bundle is not added to the product file when automatically adding the dependencies and it does not complain later on that this bundle is needed "javax.xml". Somehow when using the target file the "javax.xml" is simply not needed and then no error occurs.
I think there is a bug in Eclipse RCP, that causes this problem when using the Running Platform. But I suggest using a target definition file anyways, since this brings a lot of other advantages.

How to configure git repo with multiple java projects in eclipse

I'm following this tutorial: http://spring.io/guides/tutorials/rest/ to get familiar with spring/REST. However, the git repo (git clone https://github.com/spring-guides/tut-rest.git) has many individual java projects each with their own gradle build. I'd like to edit the code in Eclipse, as that's the whole point, but this hasn't proved trivial.
So far, I've created a general project for the git repo, and then separate java projects for each of the folders from the repo, linking the source in my java projects to the source/test folders in the repo. This has worked great except that I don't have the spring jars in my dependencies for the java projects, I get a ton of errors as well as lose the nice autocomplete of function names, etc.
What is the correct way to fix this? It seems like there isn't a good way to install the jars for spring in each java project without using maven or some other build tool, which seems redundant and inefficient since I can build the source from the repo project. If this is the case, should I make a build for each separate project even though the idea for the tutorial is that they each come with gradle?
Thanks for your help, and please excuse the slight open endedness of it--I'm not sure I'm on the right track.

A project that compiles fine on the command line with maven does not compile in intellij idea 11

As a matter of fact the project compiles just fine with eclipse as well but for some reason IntelliJ is not able to deal with it.
We have other large multi-module projects which load just fine - so I don't think this is a general problem with using maven with intellij.
Anyone else faced similar problems please share ideas on fixing this problem.
I am sorry I cannot post the pom for the project here but in general what I see from the way the pom is structured is that the common dependencies are in a parent pom. If I keep copying some of the dependencies to child modules I can get the compilation to move forward but I still do not get why I need to do this at all.
For the better Maven 3 support it's recommended to use the latest IntelliJ IDEA version (12.1.2 at the moment of this writing). There is an option to Use Maven3 to import project that should be enabled.

Categories

Resources