How to re-include excluded paths in Intellij when using Maven - intellij-idea

I am working on a multi level maven based project. One of the modules had dependencies issues and I had excluded it: now I wish to reenable/re-include that module.
The IJ documentation says to go to
File | Settings | Compiler | Excludes
However that option reports "No excludes". Apparently the above documentation does apply to Maven built projects
Note the above is also the suggested way for another question with similar title How do I re-include a class into the build path in Intellij IDEA? . So please do not mark this question as a "duplicate".
I also tried :
File | Project Structure | Modules.
But there was no mention of excluded paths there either.

Related

Unable to download all maven dependencies

I have multi module maven project in intelliJ 2019.3 (Ultimate)
I am not able to get all dependencies after several tries. I tried below solutions as well
Solution 1
Solution 2
I noticed under the Maven tool same module shows twice as below
Not sure that caused the issue here.
Strangely I don't see any red lines in the any of the POMs
Provided that you can build project from command line Maven and dependencies are downloaded.
In IntelliJ IDEA please try: File | New | Project from Existing Sources action and point to pom.xml file to import project from. Then choose to delete existing project configuration.

Configuring IntelliJ Platform plugin's workspace

I've been setting up the workspace for IntelliJ's plugin development. There is one issue that I'm not able to solve.
I have two plugins: A and B. The B plugin depends on A. The A plugin is provided as an install-ready zip package (I don't have the code and I don't want to add it to my project).
In the manual, I met this page. I added jars from the A plugin (extracted from the zip file) to the SDK that is use when running B plugin. Unfortunately, when the sandbox is being bootstrapped, I get the following error:
Problems found loading plugins:
Plugin "B" was not loaded: required plugin "A" not installed.
Disable B
Open plugin manager
Does it mean that plugins from the SDK are not installed automatically?
I tried to install the A plugin in the sandbox but then I got a casting exception - two different class loaders were used.
Of course, I have appropriate dependency configuration in the B.plugin.xml file:
<depends>A</depends>
My question is how should I provide the A plugin to be able to develop the B plugin? Is it possible to develop the B plugin without A's sources?
In the jars that I added to the SDK's classpath, there is a package that contains the plugin.xml file for the A plugin. This plugin is also not listed on the list of plugins.
I'm sure that both plugins are configured properly because there are no problems when I install both of them in a standalone IntelliJ instance. Additionally, I don't have any compilation errors.
After couple more hours of debugging. The A plugin is marked as not installed because in the PluginManagerCore:loadDescriptorsFromClassPath method there are no appropriate jars URLs provided. It seems that BootstrapClassLoaderUtil doesn't include all of the entries configured in the SDK.
I tried to set -Didea.additional.classpath property, but I got the class cast exception again.
Finally, I have found the solution.
The B plugin consists of other B submodules:
B.submodule-1
B.submodule-2
B.submodule-3
One of these submodules had dependencies to the A's submodule. Something like this:
B:
| B.plugin-submodule
| B.submodule-1
| A.submodule1
| A.submodule2
| B.submodule-2
| B.submodule-3
Based on the gradle setup, IntelliJ resolved all of the dependencies for all submodules. Initially, I removed Gradle dependencies and set the JDK only for the plugin submodule. It was required to do so for the others (submodule-1/2/3).

How to fix IntelliJ does not see dependency JARs in /lib directory?

I got a project for Mondrian and trying to open it with IntelliJ.
Unfortunately, it doesn't see existing jars:
How to fix?
You may have to add them manually one at a time, and I see at least 2 options:
File -> Project Structure -> Libraries -> Green plus at the top
From the project tree -> Right click -> Add as a library
After this, you may want to select the type of library each of them is: compile, test, etc. The second approach seems faster, and is illustrated below:
P.S.: If at all possible, I would migrate to a maven, gradle, etc which offer dependency management (including sources and javadocs where available) as well as automated builds & other tools (tests, reports, deploys, etc).

What is a working directory in Intellij IDEA

I created a Maven project and imported it in Intellij IDEA.
In a run configuration, there is a field "working directory", which points to the root of Maven project.
If I change this folder, it doesn't seem to affect anything. So what is it?
This is the directory that is set as the Java user.dir system property. If you have any code that creates relative files or directories, it will be relative to this directory. So for a well designed application (i.e. resolves resources from the classpath and is configurable for output directories) this will not be a factor. There is also some importance to this value in maven projects, especially multi-module maven projects. This directory specifies the directory IDEA will read the POM from.
If you are unflamilar with what the Java user.dir is, there is some discussion available here and in the class level Javadoc for the File class.
In addition to answer given by #Javaru if you want to update or view your working directory in IntelliJ IDEA go to:
Run | Edit Configurations | Configuration Tab | Working Directory
From the IntellJ help Run/Debug Configuration: Maven
Working directory Specify the path to the Maven project file pom.xml.

M2Eclipse can't find dependencies when they are projects in the same workspace

I know there are various known issues with the M2eclipse plugin and I guess this is just one of them. Hopefully someone is aware of a solution or workaround.
We have like 30 projects in our workspace but for clarity lets assume there are only 2: A en B.
B includes A as a dependency in the pom.xml of B.
The problem we have is that in eclipse the classes of A can't be found so you get compilation errors. However, if you 'mvn install' A to deploy it in the local repository and the close project A then everything is fine; no compilation errors. So, if A exists in the project M2Eclipse does not seem to be able to correctly set the classpath in eclipse.
To make things stranger, we also have project C that also depends (in exactly the same way as B) on project A but here we have no compilation errors. We can't identify anything meaningful difference between project B or C; as said, they include A in the same manner.
thanks for your help,
Stijn
P.S. I'm using version 0.10.2.20100623 of the plugin
I've experienced this behavior before, and it has occurred for me in the past when I imported or checked out the maven projects separately.
Prerequisite: make sure you have m2extras installed before you check out a multi-module Maven project: update site
First thing to try: right-click each project and choose Maven -> update project configuration. The plugin might be smart enough to detect that it could be building project references between the projects.
Second thing to try (if your 30 projects are all submodules off one root): this would be easiest, because you could use the SCM integration of m2eclipse to do a "Checkout as Maven Project..." on the root pom. M2eclipse would make a project for the superpom and for each submodule, with project references built appropriately.
Third thing to try: I'd try manually creating project references in the project settings of each project to mirror their interdependencies. It'd be a lot of work, and unless you check in your eclipse .project/.settings (eww), it would have to be done individually for each working copy.
RESOLVED
finally, after agonizing hours I found the cause.
I was focussing on the .classpath and the .settings files but the problem was located in the .project file. This file in project A was missing following entry in the tag natures:
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
Adding this resolved the issues.