How to prevent Idea Intellij to change MODULE_DIR in IML files? - intellij-idea

Using Intellij Ultimate 2020.2, in a multi-module Maven project, my IML files use the MODULE_PATH variable, like this:
<component ...>
<option name="directories">
<list>
<option value="$MODULE_DIR$/src/main/java" />
But when I refresh (switch branch, build, etc.) Intellij replaces MODULE_DIR by the reel path, for example:
<component ...>
<option name="directories">
<list>
<option value="C:/somepath/myproject/mywebapp/src/main/java" />
Is there a way to prevent Intellij to change the content?

Related

IntelliJ file excluded from search, how to un-exclude?

I have somehow managed to exclude my webpack configuration from IntelliJ search results. It also now has a little cross on it as shown below. How do I re-add the content of this file to search results?
I have tried excluding the file from the Project Settings/ Modules/ Excluded files, and then removing it to clear the cache, but it still gets excluded. Thanks!
Please check your .idea/workspace.xml - do you have this .js file listed in <component name="TypeScriptGeneratedFilesManager"> section there, like:
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
<option name="exactExcludedFiles">
<list>
<option value="$PROJECT_DIR$/path/to/webpack.config.js" />
...
</list>
</option>
</component>

Intellij 10.8 Command line is too long. Shorten command line in Maven

I have the latest version of intellij 2018.1.1 and I am running a very basic maven project. I get an error message as "Command line is too long" when I try to run main. I updated the run config to JAR Manifest and now intellij doesnt pick up the latest changes in my java files. I am assuming it picks up a pre-made jar and doesnt re-compile? I am trying to figure out how to get intellij to work.
To fix this, Edit the configuration the Run/Debug job in Intellij and select an appropriate "Shorten Command line" value that makes sense for your environment. Then try running the test again. If you are not sure about the correct value, simply try each of them till you get it to work. Here's a screenshot and the value that worked for me on Windows.
In the newer versions of Intellij they've hidden the menu for shortening the command line by clicking "More Options" then select the Short Command Line.
change project/.idea/workspace.xml from
<component name="PropertiesComponent">
...
</component>
to
<component name="PropertiesComponent">
<property name="dynamic.classpath" value="true" />
...
</component>
Inside your .idea folder, change workspace.xml file
Add
<property name="dynamic.classpath" value="true" />
to
<component name="PropertiesComponent">
.
.
.
</component>
Example
<component name="PropertiesComponent">
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
<property name="dynamic.classpath" value="true" />
</component>
Try to delete .idea folder and import the project again. Run 'mvn clean compile' and then run the main method.
I needed to add before launch settings to make it work with JAR Manifest option to shorten command line. This did the trick for me.
Thanks for the quick responses!
I had the same issue and resolved it in :
closing IntelliJ
removing the .idea directory
Reopening the project

SonarLint plugin IntelliJ with no authentication

Is it possible to connect to a remote SonarQube 5.6.1 server using the SonarLint 3.0.0 plugin for IntelliJ 2017.1 without using authentication by default? Currently the plugin seems to want either username/password OR token
There is a hack which you can use:
Normally sonarLint stores the information in your IntelliJConfiguration-directory in config/options/sonarlint.xml - you can simply paste following configuration into that file:
<application>
<component name="SonarLintGlobalSettings">
<option name="sonarQubeServers">
<list>
<SonarQubeServer>
<option name="hostUrl" value="<your-server-url>" />
<option name="name" value="test" />
<option name="login" value="" />
<password />
<organizationKey />
</SonarQubeServer>
</list>
</option>
</component>
</application>
which is the basic configuration for a server without authentication.
// EDIT: It seems like this was an intended change by sonarSource to sonarLint - https://groups.google.com/forum/#!topic/sonarlint/xnpQmXN8NEo - is the mailing list discussion about this

IntelliJ IDEA load module error

I am in IntelliJ IDEA 2017.1.2. I recently renamed a module from mod_plus to exp-packs and now I keep getting the error:
Error Loading Project: Cannot load module mod_plus
The old module does not exist. Under File-> Project Structure->Modules->Dependencies it does not show up, it was there, but I removed it when I first saw the error. It does not show up in the .iml file:
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="Pyhton-Snippets" />
<orderEntry type="module" module-name="exp_packs" />
</component>
</module>
In the event log, when I click 'Details' and it asks do I want to remove, I click YES and it is gone for that session, but on restart it comes back. Any thoughts on how to get rid of it?
IntelliJ IDEA loads modules according to .idea/modules.xml file which contains the relative paths to the .iml files.
If you rename a module in IntelliJ IDEA using refactoring, modules.xml file is updated automatically. In other cases you may need to update the path manually.

"Distribution with sources" feature kills Grails 3 projects in IntelliJ

Create new Gradle 3 project, select all default values. You can test project that is runs. Then, stop the project and open build.gradle file. You will be prompted with a tip
(You can configure Gradle wrapper to use distribution with sources. It will provide IDE with Gradle API/DSL documentation)
Select Ok, apply suggestion
Now you will be unable to compile or run project anymore with the following error:
Error:Cannot compile Groovy files: no Groovy library is defined for module 'untitled1'
Is it possible to restore the project state back to normal?
UPDATE
Some block is absent in broken IPR file:
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="mavenHome" value="D:/Apps/apache-maven-3.2.3" />
</MavenGeneralSettings>
</option>
<option name="importingSettings">
<MavenImportingSettings>
<option name="downloadDocsAutomatically" value="true" />
<option name="downloadSourcesAutomatically" value="true" />
</MavenImportingSettings>
</option>
</component>