Cannot resolve symbol errors in my gradle project cloning - gradle

After cloning git repo in intelliji I have errors with classes. tried invalidate cache and it didn't help at all. Not sure what could be the reason. besides this all the annotations are red and dont function as intended.
BTW, it is a gradle project
for your information added another screenshot

Related

Why refresh of Maven repository is not enough for IntelliJ?

I had a NoClassDefFoundError problem with some test, launched from IntelliJ. In order to repair the situation, I had to make several changes in many poms of the project - adding new packages and excluding some old ones for to escape the overlapping of them. Also, I reapired the situation with different versions. But the situation did not improve. Again, some package, declared in pom, was not found where it should be.
I refreshed the maven repository by
mvn -e clean install -U
, as is advised in https://stackoverflow.com/a/9697970/715269 - so old and upvoted answer, that it surely looks as Santa.
The problem remained unchanged.
I output the maven map. It was correct and it contained all needed.
I looked at the list of the External Libraries of the project. It was the old uncorrected list of overlapping jars with same names and different versions, and without good packages I added just now, and well seen in maven tree output!
Already hapless,
I reimported packages in IntelliJ
by:
Ctrl+Shift+A, Reimport All Maven Projects.
Ho! The list of libraries got repaired. And the problem, mentioned in subj, disappeared.
The question is: How it could happen, that the same project has that very pom for everything, but gets packages differently being launched in maven and in IntelliJ?
I know about that feature "delegate IDE build to Maven". And I keep it turned off. But I am NOT talking about the different SW for building. Whether they are different or not, they should be up to the actual pom's. And whereas maven, if turned off from the automatic building won't know about changes in poms, IntelliJ KNOWS about them. It could have jars up to pom, or up to maven - it has sense, but it simply has some old rubbish. Was there some deep thought under that construction?
Every time you manually change the pom.xml file, including the dependencies you need to load these changes into IDE. IDE does it on Reload from Maven action. See also Import Maven dependencies.
Intellij doesn't use maven to bulid and run a project except you are delegating build and run action to maven:
Since, IDEA doen't really use maven to run and build, it uses the pom.xml to import the project structure and "tries" to build the project the same way was maven does.
Actually, there are quite a few differences between these to build processes.
Generating sources or filtering resources (don't know if this is still an issue) aren't done during building the project with Intellij IDEA.
In case you are using code generation you have to build the project via maven first and then - when all the resouces are filtered and additional sources are generated - you are able to run, debug aso. the project with Inellij IDEA.
That's an important thing to be aware of and that's the reason why maven and IntelliJ IDEA project structures might get out of sync.
You can enable the "Reload project after changes in build scripts" feature and select the Any changes checkbox to keep your project structure updated:
Why should you disable this feature anyway
If you are working on a build file (gradle or maven is not important) reloading the structure on any change can be very anoying. It's cpu intense, dependcies are fetched aso.
Therefore, I prefer to reload project structure only in case of an external change. This happens when pulling an updated version of the build file for example.

Maven not updating dependency

I'm working with a project that imports an internal SNAPSHOT dependency that has been updated, but the version is still the same. I cannot get my Maven to get this latest update.
We have an internal Nexus repository. One of modules contains much of our data model so that it can be leveraged across multiple applications. This module is at version 1.5.0-SNAPSHOT. Recently it was updated, however the version was not incremented. One of the updates was a method was moved from one class to another. My project calls that method and therefore, this update should break the project's build.
I know for a fact that the module has been updated in Nexus, because when I build this project through Jenkins, it fails because that method was moved. I also pulled the source code from our VCS to verify directly from the source code.
I have searched SO and here is what I've tried from many of the solutions provided to similar questions.
mvn -U clean install.
Removed the local repository entry from my .m2/repository folder.
mvn dependency:purge-local-repository
Using a new local repository with -Dmaven.repo.local=localrepo
In pretty much all of these, I can see the dependency getting downloaded from our Nexus server and yet my project still builds successfully. I have the feeling there's a setting in my Maven environment that needs changed or something.

maven parent artifactId not updating in IntelliJ project view and File - open recent

I have renamed the parent module in my maven project by changing its artifactId. I also updated all parent-artifactIds in the child modules accordingly. My problem is that even though i rebuilt the maven project (clean install, which worked) and reimported all Maven projects and restarted IntelliJ, the old artifactId is still displayed in the project view.
Have I missed something in order for IntelliJ to update the name? How can I fix the problem?
edit:
After following the instructions in the link of CrazyCoder, the new name is displayed correctly in the project view. I will write an answer to describe what I have done.
But I have noticed another problem now: In File -> Open recent the old artifactId is still displayed. I have not found where I can access what is displayed in this menu to rename it. The issue is resolvable by cloning the repository with git again. Is there also a way to fix this in IntelliJ?
This is a very long known issue and can be resolved following these steps:
Change the artifactId in your poms wherever it is necessary
Run Clean-Install on your project to be sure everything is still working
Right Click on the project -> refactor -> rename or Shift-F6 and change the module name to match the new artifactId
The .iml file should be updated as well now. It might be that your IDE is confused now. Go to File and click Invalidate Cache/Restart
IntelliJ should now be displaying the correct name in the project view. According to my sources it could be necessary to update the names of the directories manually, which would be necessary between step 2 and 3. I did not have to do this, but still wanted to mention it if someone runs into that problem.
Another issue is that in Open Recent the old artifactId is still displayed. This is solvable by cloning the repository with git again. Unfortunately I have not found a way to do this in IntelliJ.

maven m2e proxy connection issues with PAC, in Eclipse; How to Debug?

I got the Eclipse EE and realized it did not have maven/m2e, so I got m2e installed.
Then I am setting up projects and using pom.xml I start getting all the fun errors like:
Could not calculate build plan: Plugin....,
__ or one of it's dependencies could not be resolved: Failed to read artifact descriptor for ....,
Failure to transfer .....
Since I'm in a corporate environment, I find the IE setting and go find the PAC ( proxy auto-configuration ) script.
Then I enter those values into a in my settings.xml area.
I even tried some of the ideas shared by developers, such as deleting .lastupdated files and deleting directories.
Even though it totally defeats the whole idea of maven, I'm considering transfering all my .jar & .pom files from another machine's repository.
No joy yet. Something is still wrong, I just don't know what yet.
I seriously need some debugging or logging or a ping test, if there is anything available to discover what the problem is.
I found some great posts on Maven and Proxy. keywords: maven, m2e, 'failed to transfer', pom.xml, settings, proxy, etc.
also
Cannot download maven dependencies through proxy
http://jira.codehaus.org/browse/MNG-5237
after reading this, and not knowing if my company was using NTLM, I put in the wagon lightweight jar and referred to it with in pom.xml
How will I know, If I do end up needing this ?? and
where should I put the .jar file ? in the user repository area, or deep in the maven runtime \jars\ directory ?
Along the way, some questions also came up.
( for reference, I am on WinXP )
With an m2e only, do I need a $M2_HOME defined ? I'm thinking not, since I don't know where that would be.
related: With m2e, will I ever have a global settings.xml ?
Should the ${user.home}.m2/repository be referenced (and uncommented) in the local settings.xml ?
As a substitute for the command line maven, can Eclise 'Run Configurations' really be a full replacement ?
I know the dialog box you use, has the empty list of goals, when it should be populated, but you can always type in
What about using 'mvn -X'
Or any of the other cool maven commands, like the one that shows you all the transitive dependencies.
Still searching, but Thanks In Advance for anyone who can assist in resolving these Proxy issues.

Jenkins Sonar plugin throws duplicate source file error during analysis

I have set up Sonar with MySQL Database. My project is a multi module eclipse project, which means it has multiple plugins.
I have set up a Jenkins build with Maven to build this project and also installed Jenkins Sonar plugin to analyse the code with sonar.
All the configurations seem to be correct. However, when sonar tries to analyse this project after the build, it complains of duplicate source code and the build fails.
Each eclipse plugin has Activator.java class and Sonar complains that this is duplicate. I have excluded this class from analysis, but Sonar complains of classes in a particular plugin that is added as a dependency to lot other plugins.
Incomplete analysis of the code leads to other issues in Sonar for this project. like, even though the project is visible in the Sonar dashboard, it asks for authentication again on clicking the project, even though I am logged in as admin.
Any inputs on pointing me to the right direction would be very helpful.
Please let me know if any additional inputs are necessary to better understand my problem.
IMO, the best example you can follow is our Sonar Eclipse project: https://github.com/SonarSource/sonar-eclipse. This is also a multi-module Eclipse project.
In this example, you want to have a look at the parent module (https://github.com/SonarSource/sonar-eclipse/tree/master/org.sonar.ide.eclipse.parent) which goal is only to define the parent POM. Almost everything happens there.
I guess that you should find your way thanks to this.
I was able to fix this issue by removing the test tag in the parent pom.xml. This was somehow causing sonar to throw the duplicate source error. It was a tedious task to figure out the root cause and I had to reconstruct pom.xml from scratch, adding section by section.
Thanks to all for the help.

Resources