Intellij does not displays repos on auto complete drop down - maven

I am new to maven and I wanted to try it out and I decided to choose Intellij IDEA IDE for this task.
I tried to follow few video tutorial to create simple spring project with maven. But I happen to notice that, while creating dependency on pom.xml file I could not get auto complete for packages that are present on .m2 directory inside my user home directory.
But I can see two item in autocomplete dropdown, one being the self project and other maven-clean-plugin for artifactId
I could not come up with any solution for this. May be this will not affect my development, but I got stuck with this issue and wanted to know what really happened.
I am more than happy to clear myself further if what I am asking is unclear :)

When auto-completing maven dependencies, IDEA uses an index it generates to know what dependencies are available. Go into Settings (Ctrl+Alt+S / ⌘,) > Build, Execution, Deployment > Build Tools > Maven > Repositories. Your local repository should be listed. Select it and click Update for IDEA to update the index on it. It will take a bit of time. The progress will show on the center-right of the bottom status bar of the main IDEA window. If you use a repository manager, like Sonatype's Nexus, you should add it in the "Artifactory or Nexus Service URLs" section in the lower pane. Maven central will also likely be shown. You should update its index as well.
Click the Help button on that settings dialog for more information.

Related

Intellij IDEA 2019.2: Set the maven home directory "globally" for all projects

Every time I clone a repo I have to manually set the maven home directory under File->Settings->Build, Execution, Deployment->Build Tools-> Maven-> Maven home directory which is very annoying. I searched jetbrains forums and there is only an option to configure the IDE for FUTURE projects which under circumstances can never be a fact. Cloning a repo into idea projects is not creating a new project and therefore the global settings do not get triggered. How can I do this? Btw it not only applies to Maven home dir but also Code Style settings and many other more - see here
IntelliJ IDEA doesn't have a feature to propagate any setting to all the existing projects. A request is welcome.

STS on Linux - Could Not Calculate Build Plan

After installing the Spring Tool Suite, I tried to create a maven project and this is what I get in an instant:
So waddap Maven/STS creators? How do I make your product work?
To any noobs like me who got overwhelmed by this error, here's what I did:
Go to your .m2/repository, where I think Maven stores its configurations files, then wipe it clean, delete all files, delete the 'repository' folder even.
I then closed the STS IDE and restarted it. You can see in 'Progress tab' that Maven is downloading new files.
Saw the same 5 errors, right clicked and clicked 'Quick Fix'. That's it.
This post was helpful too.

Sonar refuses to analize multimodule project

I have upgraded from Sonar 5.3 to 6.2 and a project X is giving me some weird errors at the sonar stage of the jenkins job (altough build finishes as STABLE).
The project is a standard multimodule maven java project.
Entering the project dashboard a single message appears on screen:
"No analysis has been performed since creation. The only available
section is the configuration."
But in the upper-right corner the red "FAILED" tag shows up. That leads to the Background tasks of the project and there is the failed task with this error log:
The project "com.foo:bar-submodule-1" is already defined in SonarQube
but not as a module of project "com.foo:bar". If you really want to
stop directly analysing project "com.foo:bar-submodule-1", please
first delete it from SonarQube and then relaunch the analysis of
project "com.foo:bar"
I do not want to delete the project and lose the historical data.
So the question is: How can i add a project Y (that is a submodule of project X but Sonar does not recognize it) as a submodule of project X?
EDIT 1
The parent project is the only one that has been analyzed through jenkins jobs.
Your problem is not that Sonar can't figure out your submodules, but the root issue is that there is another project/module with the same name conflicting with the project you are analyzing now. It happens, for example, when you extract a submodule as a standalone library and moves it as a root project and try to analyse the new project. Since it is a new project, but sometime in the past you had another project/module with the exact same name, it won't be able to finish the process. I have found three ways to fix this:
Delete the old project, if it is possible
This is a option that I use when I have analysed mistakenly new projects (with wrong parameters for example) or when I am migrating servers and still have some wrong configuration in place. You can do this in the project's Configuration/Administration menu, 'Delete project'.
Rename the old projects keys
This is my default option, since usually what I want is just keep the old analyses data for old submodules that we are moving to other projects or promoting to root modules. You can do this in the project's Configuration/Administration menu, 'Update key' option.
Updating your current project's keys
This option I use when the submodules conflict with other valid submodules (It can happen when you have different teams creating small libraries that happen to have the same keys). You can do this in two steps. First you need to update your project's keys following the option 2. The next step is to go to your project and update the modules and submodules names using the key sonar.moduleKey. The default value for this is : similar to sonar.projectKey, as especified here. Following these steps you won't lose all your records and old analyses.
I hope it helps.

How do I clear teamcity's maven dependency repository/cache

I have a teamcity server and I have maven dependencies which have changed but who's versions have not changed. From what I can tell this is causing my build to fail because teamcity is not updating these dependencies.
So I need to know how to clear out teamcity's maven dependency cache for my project. I looked through the documentation and didn't find anything significant.
Thanks!
Rather than trying to manually clear the local Maven repository on the server running Teamcity, it may be easier to force an update of the Maven dependencies in the Teamcity settings.
To do this, edit the settings for the Teamcity project (in the Teamcity frontend select the project and then select the 'Settings' tab). Next click the 'Edit Configuration Settings' link (top right) and then click the 'Build Steps' link on the right hand side. In here, edit the step responsible for compiling the code. On this form, in the 'Goals' field, add the argument -U (that's an uppercase 'U').
Save the settings and kick off a new build. That extra argument will force Maven to go and update its dependencies.
Going forward, if the dependencies are changing but their versions are not, you may be better to have their versions set as SNAPSHOT. See What exactly is a Maven Snapshot and why do we need it?
Found mine at /opt/buildagent/system/jetbrains.maven.runner/maven.repo.local.
I found mine in /opt/TeamCity/buildAgent/system/sbt_ivy/cache/, But if you can SSH to your machine, just run sudo find / -name "sbt_ivy" and you'll see the address of ivy in your machine (if you use SBT as I do)
You can actually go to Version Control Settings and there is a checkbox "Delete all files in the checkout directory before the build".

Good Reference for Hudson/Maven/Mercurial Integration

Can anyone provide a good reference (web, book etc.) that explains how to set up Hudson to do builds/releases using Maven/Nexus and Mercurial? I would like to set up our system to do Maven builds in Hudson based on updates to our Mercurial SCM projects which are automatically deployed to our local Nexus server. Some of the project are dependent on others. I can find quite a few references that refer to one part of the equation, but haven't found anything that details all the pieces together.
TIA!!
EDIT
I think what I am looking for initially is more of a general overview of how to use these tools in an integrated manner. And then I can delve into the details. What I'm looking for is how to use Hudson to do/verify builds and based on the results, push the artifacts to the appropriate Maven/Nexus repository (snapshot or not) and also possibly deploy applications from Hudson as well to our pre-prod systems. The fact that I'm using Mercurial is incidental.
Hopefully that clarified and didn't muddy my question...
I don't know about the books, I did our integration by using Hudson help.
I think, though, that one area is totally not clear out of the box: providing your own version of settings.xml ( that's where you may set custom repository, profiles, etc )
Here are the steps:
Go to Hudson->Manage Hudson->Maven 3 Configuration
Under 'Documents' tab click 'Add'
Change 'Type' drop-down to 'SETTINGS'
Give it a meningful name ( e.g. my-custom-settings )
Cut and paste the WHOLE xml that you would usually put into $HOME/.m2/settings.xml
Hit 'Save' button at the bottom of the screen.
Now you are ready to setup Maven project
Create new job and tie it to your source control
Add 'Invoke Maven 3' build step
Click 'Advanced' button
In expanded list find 'Settings' drop down
Choose 'my-custom-settings'.
With custom settings you can provide deploy credentials, custom profiles, etc.
I really wish Hudson team would have provided similar instructions in their help for Maven build step, instead of links to 'Settings Reference' at maven.apache.org website.
As for mercurial integration, quick search returned this article -> http://www.ashlux.com/wordpress/2010/06/16/triggering-hudson-builds-with-mercurial-hooks/
I am not mercurial expert, but the article is consistent with the setup we used for our SCM integration.
I wrote a blog which talks about setting up project using Jenkins and maven, If i am right Jenkins is a spin off from Hudson. Try it out it might help
http://prasannatalakanti.blogspot.com/2011/08/continuous-integration-using-open.html

Resources