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

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.

Related

Swift Package Manager - How to add checkouts to source control? [duplicate]

I started using new Xcode 11 which integrates SPM.
I added first dependency to my project:
but detected that files are not fetched into my project folder but into Xcode's cache:
I would like to commit all my dependencies files into my main project repository so my question is:
Is it possible to change location of fetched packages via SPM using Xcode 11?
It's somewhat possible, although the solution isn't necessarily a good or great practice, so I can't recommend.
Set the DerivedData in workspace settings to be relative to the workspace.
Add gitignore rules such that the workspace/WORKSPACE_NAME_DIR/SourcePackages/checkouts and related files are includes. Maybe best to ensure repositories directory is not included.
Add a Run Script phase to remove .git and .gitignore files in the checkouts directory.
Obviously, this is fragile largely through fighting the way SPM works. The workspace settings are per person so it's not great in teams.
SwiftPM integration has been setup to prevent this. It clones the files into a DerivedData/ProjectName-[RandomStuff]. You should commit your Package.resolved into the repo to ensure that you get the same version of each dependency across clones of the project.

Creating a teamcity project from versioned controlled settings

I have a git repository for a project with a .teamcity folder in it containing versioned teamcity settings. Assuming I have deleted this project from the teamcity server (by first disabling versioned settings and then deleting the project) how can I re-import it?
The use case here is being able to create a new project using a template generator, e.g. yeoman or dotnet new, and be able to import that easily into a parent TeamCity project.
Our current teamcity version is: TeamCity Enterprise 10.0.4 (build 42538), so things may have improved in later versions.
So I think I have figured this out, these are the steps that worked for me.
Create a new project, making sure the Project ID is set correctly
Add a VCS root pointing to your repo that contains your project
Enable versioned settings making sure to select use settings from VCS and choosing the Kotlin settings format
Select "Import settings from VCS" when prompted
In more detail...
Make sure the Project ID for your project matches what you have in your .teamcity file
For example if your .teamcity file contains .teamcity\MyAwesomeProject, then you need to make sure your Project ID in teamcity is set to MyAwesomeProject.
use settings from VCS
If you don't tell TeamCity to use the vcs settings by default then it will do what it usually does and start checking things into source control for you.

Getting Maven to Report Which File Has Local Modifications

I have a Jenkins job that builds a simple Maven project. If all I do is build, it works just fine. The problem arises when I try and do a release, dry run or regular. It consistently fails with the Cannot prepare the release because you have local modifications error. I have wiped out the workspace, but the problem persists. Is there any way I can get Maven to tell me which file it thinks has been modified? I would assume that by wiping out the local workspace and immediately running the dry run release that there wouldn't be any opportunity for anything to get modified.
Please note, I do not have access to the Jenkins server or the slave that is running the actual release build, so I can't use any tools there (like SVN) to determine what is supposedly modified.
You can use the Maven SCM plugin to do a diff.
https://maven.apache.org/scm/maven-scm-plugin/diff-mojo.html
Basically, integrate the maven plugin upstream of the failure, and see if anything has been changed. I imagine you might be able to see the output in the log, but if you cannot, you might be able to move your "real" maven pom.xml aside and replace it with one that generates a diff file and with the help of the maven build helper plugin, attaches that file as an additional aritfact (to a pom target).
It turned out the solution to my problem was to not use the "Local to the workspace" strategy for my private Maven repository in the Jenkins job configuration. By changing that to the "Local to the executor" strategy the problem went away. I'm still not sure why it was having the problem in the workspace, but this solution resolved it form me, and might work for others.

Intellij does not displays repos on auto complete drop down

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.

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".

Resources