My snapshot version looks like 2.7.644-SNAPSHOT
So pom.xml normally look like
<parent>
<groupId>com.orderManager</groupId>
<artifactId>parent-pom</artifactId>
<version>2.7.644-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
But after a failed release my pom.xml file looks like
<parent>
<groupId>com.orderManager</groupId>
<artifactId>parent-pom</artifactId>
<version>2.7.644.344</version>
<relativePath>..</relativePath>
</parent>
When I try to correct all versions by running mvn versions:set -DnewVersion=2.7.644-SNAPSHOT, I get an error
mvn is trying to find the failed build jars in a remote repo for some reason.
I'm just trying to change the version names in pom.xml, there's no reason to download jars. Is there a way to run mvn versions:set without downloading current version's jars?
Simply before any plugin will be executed on project, Maven need to load your project and resolve needed dependencies.
In case when corrupt your project for any reason, you have options:
restore previous/correct version of code from scm - if you have
fix manually problematic versions in poms
That is pretty easy in Ultimate Itellij Idea.
In community version I have the following problems:
I can't open maven lifecycle window.
When I right click on pom.xml and choose Maven I see only
Using artifacts + build it's impossible to choose .war
It's worth saying that I have mvn project and I need to create .war from one of the subprojects
Are you sure you can't enable the Maven Tool window?
I'm using the Community Edition (2018.3, so not the latest one) and the Maven tool window is available (appears by default on the right), see below:
If you can't find it, try View/Tool Windows/Maven
You can achieve doing cmd into your project root folder and run the maven goal mvn clean install or mvn clean package
Before that make sure you define your project with as packaging of war type and also check you have maven installed and set maven home
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>war</packaging>
I have a project which I am attempting to install with maven. The pom.xml has a few properties in it which are modified when the maven install command is run depending on whatever version of a library we are attempting to build with:
<properties>
<some-version>0</some-version>
</properties>
The zero here is a placeholder, as we'll always specify a legitimate version during our build process. The version is then referenced later in the pom.xml to specify a few dependencies:
<dependencies>
<dependency>
<groupId>com.mycompany.myproduct</groupId>
<artifactId>someOtherProject</artifactId>
<version>${some-version}</version>
</dependency>
</dependencies
Building is done via make with the following commandline:
mvn -Dsome-version=1.6.2
Maven is able to correctly resolve the version and build as expected. However, the version being installed in my local maven repository (/home/user/.m2) doesn't have the correct version. The pom.xml that is installed does not have the updated version I set in the command line:
user#ubuntu:~/$ cat /home/user/.m2/repository/com/mycompany/myproduct/myproject/1.0.0/myproject-1.0.0.pom | grep some-version -C 1
<properties>
<some-version>0</some-version>
</properties>
--
<artifactId>someOtherProject</artifactId>
<version>${some-version}</version>
</dependency>
user#ubuntu:~/$
This is preventing any other project which depends on myproject from being able to build, as maven will complain that it can't find version 0 of someOtherProject:
[ERROR] Failed to execute goal on project myproject:
Could not resolve dependencies for project mycompany.myproduct:myproject:jar:1.0.0:
The following artifacts could not be resolved: com.mycompany.myproduct:someOtherProject:jar:0,
Could not find artifact com.mycompany.myproduct:someOtherProject:jar:0 in central (https://mycompany.com/artifactory/repo/) -> [Help 1]
What do I need to do for maven to install with the updated version in the pom? Obviously a terrible hackish solution would be to use sed and modify the pom file directly, but it seems that Maven should be able to actually leverage the command line settings when installing the pom. Otherwise the ability to set arguments on the command line seems remarkably limited in effectiveness.
Better you may set your property in pom.xml in <properties> tag like this -
<properties>
<property>
<name>some-version</name>
<value>1.6.2</value>
</property>
</properties>
If you use this then you don't have to provide the property each time you issue a mvn command from terminal.
mvn -Dsome-version=1.6.2 works as a substitution value for the scope of building than replacing the original POM with the new values. Hence is the behavior you see. I am not aware of any maven support to do so.
Under #JoopEggen's advice, I looked deeper into the maven versions plugin. It offered an update-property target which will actually update the pom.xml value on disk, rather than just passing in an overwrite during the build phase. I was able to solve my issue by calling
mvn versions:update-property -Dproperty=some-version -DnewVersion=1.6.2 -DsearchReactor=false -DallowSnapshots=true
in the makefile before calling mvn install. Disabling the reactor was necessary to prevent the plugin from rejecting values it couldn't find in the remote repo (see here), and allowSnapshots allows me to use version numbers such as 1.6.2-SNAPSHOT, useful when testing.
I have a project in IntelliJ IDEA which was created with Maven. I then specified a set of dependencies and external repositories in the Pom.xml file.
The project builds fine on command line if I do mvn install. When I open any of the code files in the IDE though it says all the classes handled by Maven dependencies aren't recognized - as it would for a normal project if I never added the required JARs to the build path.
I know in my Eclipse Maven projects (rather than IntelliJ) it usually shows an extra directory on the left which says "Maven Dependencies" and lists the JARs pulled in via maven. I don't see that here. What am I doing wrong?
Here's what my screen looks like:
Right click on the pom.xml -> Add as Maven project -> Reimport
For some reason re-import did not do the trick. After looking at this:
http://www.jetbrains.com/idea/webhelp/maven-importing.html
I set auto-import and then the problem went away though; hopefully it helps someone else. Thanks for the ideas everyone :).
After installing IntelliJ IDEA on a new computer I found myself with the same issue.
I had to update the remote maven repository. (Settings > Maven > Repositories)
Both local and remote repos needed to be updated. The remote one wasn't updated ever before this. After a restart everything worked fine. You might have to reimport your project.
You could go to:
File > Settings > Build, Execution, Deployment > Build Tools > Maven
and check if your pom.xml is not in the "Ignored Files" list.
I was running into similar issues. For me it ended up being that I was importing the project incorrectly. I had been doing
import project
<navigate to existing project and click top level directory>
follow the wizard
What solved my maven problems was to do
import project
<navigate to existing project and click the pom.xml
follow the wizard
For me File>>Invalidate Cache/Restart>>Invalidate and Restart worked in IntelliJ
Idea cannot download all dependent jar packages using maven,try the following operations:
mvn -U idea:idea
then all the dependent jar packages are download from the maven repository
A simple reimport and/or update of the repositories via Intellij did not do the trick for me.
Instead I had to delete the complete ~/.m2/repository directory and let maven sort everything out by itself. Afterwards Maven -> Reimport finished it off.
I've encountered a similar issue after refactoring my maven project into different modules. Re-importing on it's own usually doesn't work, but I've found that deleting the .iml files and then re-importing usually does the trick.
Ran into the "same" issue some days ago. It might not be related as my issue was more specific to Spring boot but as I was struggling with it and tried every solution on this post I'm going to share my experience.
What I was trying to do is to add one of my spring boot app into another project as a maven dependency. The dependency was resolved but I couldn't access my classes.
When no packaging is declared, Maven assumes the default packaging is JAR.
The JAR generated by the Spring Boot Maven Plugin overrides the default one generated by Maven.
The solution was:
The solution that we found is to generate another JAR which will be used as a dependency to be imported from other projects.
The full article which helped me solve my issue.
Hope it helps someone.
For reasons I don't understand, in my case, I needed turn on setting "Always update snapshots" in Build, Executions, Deployment > Build Tools > Maven.
That made IntelliJ redownload dependencies and make it work.
In my case the problem was that the project was in maven2 while intellj was configured for maven3. Switching to maven2 in settings solved the problem
Might be useful to others that were still stuck like me.
None of the suggested fix worked. Actually, not before I fixed my main problem which was the installation location of maven.
In my case, I did not use the standard location. Changing that location in the maven settings (Settings/Maven/Maven home repository) did the trick.
My 2 cents.
Cache is causing problems! Make sure to do the following:
In your terminal, go to project/module:
mvn clean install
In your IntelliJ:
File > Invalidate Caches > Invalidate
Right click on project/module > Maven > Reimport
For my case I should have checked the work offline
Go to File>Settings >Build, Execution, Deployment >Build tools>Maven
Then check Work Offline
Worked for me:
mvn -U idea:idea
Since mvn -U updates the dependencies, check what mvn -U does: https://stackoverflow.com/a/26224957/6150881
Before this I have tried following steps but these have not helped:-
Deleted .idea and .iml file
Invalidate cache and restart
Maven -> Reimport .
This happened to me when I had mistakenly set my IntelliJ to power saving mode. Power Saving mode is displayed by battery icon with half empty charge. Disabling that fixed the problem.
This also happened to me after upgrading Intellij to 1.4.15. I tried to re-import the whole project with same result, but enabling Maven Auto Import did the tricks.
Looks like there are several, valid reasons why intelliJ would ignore a pom file.
None of the previous answers worked in my case, so here's what did work, in case someone else runs into this issue:
In this example, module3 was being completely ignored by IntelliJ. The pom.xml in that directory wasn't even being treated as a maven pom.
My project structure is like this:
myProject
module1
module2
module3
BUT, my (simplified) pom structure is like this:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>devs</groupId>
<artifactId>myProject</artifactId>
<version>0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>myProject</name>
<modules>
<module>module1</module>
<module>module2</module>
<modules>
<profiles>
<profile>
<id>CompleteBuildProfile</id>
<modules>
<module>module3</module>
</modules>
</profile>
</profiles>
</project>
To fix this, I modified the root <modules> element to add in module3 temporarily.
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
<modules>
Next re-import the root pom, and IntelliJ will add the module.
When that's done, revert the pom. IntelliJ will ask if you also want to remove module3 from the project structure. Click No.
Bam! Done. Module3 works and I can run my Integration tests from IntelliJ again :D
The problem was caused for me by selecting the project directory to be Imported when first starting IntelliJ rather than the pom.xml file for the project.
Closing the problem project and then following the Import process again but choosing the pom.xml resulted in a fully working project in the IDE.
For me the problem seems to be a conflict with the maven helper plugin (https://plugins.jetbrains.com/plugin/7179?pr=idea).
I disable it, and it works again :)
Go to
File > Settings > Build, Execution, Deployment > Build Tools > Maven
and check the Maven home directory. This should be the same maven installation used for command line
For me, what did the trick was to add the dependencies in File > Project Settings > Modules > Dependencies.
Just delete your project's .idea folder and re-import your project in IntelliJ.
If you have any dependencies in pom.xml specific to your organisation than you need to update path of setting.xml for your project which is by default set to your user directory in Ubuntu : /home/user/.m2/settings.xml -> (change it to your apache-maven conf path)
Go to -> intellij settings -> build,Execution, Deployement -> Build Tools -> Maven -> User settings file
Restart, Invalid caches, outside building, none worked for me.
Only Reimport worked finally. For others sake, putting it as answer:
Right click the project > Maven > Reimport
While importing a New project :
1.To identify all the modules in a project as maven modules:
File --->New Project Settings -->Build Execution deployment -->build tools --> maven ---> importing ---> enable "search for projects recursively"
Option1: Right-click on the main project folder => Add Framework Support => Check Maven option
Option2: right-click on the pom.xml file and click on "Add as a maven project"
This happened when I was upgrading from Java from 8 to 11 and Spring version. All the dependencies in the maven section disappeared as if no pom file existed. Was able to find the issue by doing
mvn clean
It showed me that one of the dependencies was missing version tag and it needed one.
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>
After adding version to the above dependency it started showing up all the dependencies under maven section.
In my case the my maven home path was pointing to Bundled Maven 3 instead of where my .m2 folder was located, fixed it by going to File > Settings > Build, Execution and Deployment > Maven > Maven home path and adding C:/Program Files/apache-maven-3.5.4
I am a "noob" with maven and I am running a mvn clean install for a open source project I found. I am trying to get it to build a jar file. When I run it the way it "supposedly" is going to work. I get this error...
Non-resolvable parent POM: Could not find artifact
com.gorillalogic.monkeytalk:monkeytalk:pom:1.0.12-SNAPSHOT and 'parent.relativePath'
points at wrong local POM # line 6, column 10 -> [Help 2]
For the pom.xml file # line 6-10 I have...
<parent>
<groupId>com.gorillalogic.monkeytalk</groupId>
<artifactId>monkeytalk</artifactId>
<version>1.0.12-SNAPSHOT</version>
</parent>
Is there a step I am missing? I can give more code if you need it?
Thanks in advance!
You are missing the parent projects pom.
Most likely your folder structure looks like this:
.../moneytalk_Foo/pom.xml
.../moneytalk_Foo/someFolder
but it should look like this:
.../pom.xml
.../moneytalk_Foo/pom.xml
.../moneytalk_Foo/someFolder
Or that parent is a project into itself and you must download it and call mvn install on it yourself.
the parent project maybe not installed yet, try run the parent project "monkeytalk" as Maven install.
Not sure if this is a cure all for everyone seeing this, but for me it was because my maven settings.xml file was not being found. Maven uses this file to locate remote repos for downloading SNAPSHOT files so if it can't find the settings.xml file then parent.relativePath is essentially undefined. Pretty crappy error message for this IMO, it should dump the value of parent.relativePath to give some indication of an undefined var.