Deployable Artifacts in Maven project not updating when versions change
I have a Maven project that, when imported into IntelliJ IDEA, the deployable WAR artifacts (web.xml) were detected. I can add these artifacts to a Tomcat deployment and run them.
If I change the version of the Maven project (from 1.0.0-SNAPSHOT to 1.1.0-SNAPSHOT for example), everything seems to build OK, but when I try to build the deployable artifacts, the dependencies copied into the target/.../WEB-INF/lib folder are the old version.
The only mention of the old version is in the .idea/artifacts/*.xml files, where IntelliJ IDEA keeps track of the dependencies for the artifacts. It looks like these are not being kept up-to-date with the rest of the code.
The things I have tried are:
- Delete the .idea/artifacts folder and let IntelliJ IDEA recreate them. It does, but with no dependencies listed. I get "empty" deployable artifacts.
- "Ignore" the projects containing the deployable artifacts, delete the .iml file, unignore (to force a reimport). It has no effect on the artifact dependencies.
- If I do both of the above, I get "empty" artifacts.
Looking in the "Project Structure" / Modules, it seems like the dependencies are not all being updated to the new versions.
As I work on a large project, I would like to not have to alter these dependencies manually, as it should be getting them from Maven.
Any thoughts on how I can persuade IntelliJ IDEA to update the artifact dependencies based on what Maven is telling it?
I'm running IntelliJ IDEA Ultimate 2018.3.
Please sign in to leave a comment.
>the dependencies copied into the target/.../WEB-INF/lib folder are the old version.
What versions should be copied and what versions are sotred there (the exact files and where do they come from - are these are dependencies from other Maven modules or from local maven repository etc)? Does Maven command line build work and produces the needed dependency?
It works for me e.g. in this scenario: I modify Maven module dependency which is used in war artifact: change version in this module pom.xml, then change version in the web Maven module pom.xml to the same version, re-import Maven project: I see the versin is updated in `WEB-INF/lib`.
Also try the version from https://www.jetbrains.com/idea/download
Hi Andrey.
It used to work for me like you describe, however I now get the following:
Say I had updated the dependencies from 1.0.0-SNAPSHOT to 1.1.0-SNAPSHOT, all dependencies in the Maven project now refer to 1.1.0-SNAPSHOT. I have auto-import enabled, but I have also run "reimport".
Running "mvn install" builds with the correct dependencies (1.1.0-SNAPSHOT).
Running "Clean Artifacts" (to ensure the "WEB-INF/lib" is cleared) and then "Build Artifacts" copies the 1.0.0-SNAPSHOT from the Maven Repository into "WEB-INF/lib". There is no reference to 1.0.0-SNAPSHOT anywhere in the Maven pom.xml files in the project.
I can't copy my actual files here, but an example pom.xml would be as follows:
Even after running "reimport", in the ".idea/artifacts" folder, none of the ".xml" files describing the artifacts have been updated...
The "my-tools-1.0.0-SNAPSHOT.jar" is pulled from the local Maven repository.
I have tried deleting the ".idea/artifacts" folder, and when I "reimport", the folder is recreated, however it doesn't add any dependencies:
It is as if the artifact ".xml" files are simply not being updated from the Maven configuration.
Also, I can't currently try out the latest version (I have to get new versions authorised), but the other engineers on the project do not appear to have this issue.
I will create a new copy of the project and see if that helps, but keep my existing project and continue trying to resolve the issue.
Regards, RobC.
>Say I had updated the dependencies from 1.0.0-SNAPSHOT to 1.1.0-SNAPSHOT, all dependencies in the Maven project now refer to 1.1.0-SNAPSHOT.
Can you attach screenshot showing this result that you see?
>Running "Clean Artifacts" (to ensure the "WEB-INF/lib" is cleared) and then "Build Artifacts" copies the 1.0.0-SNAPSHOT from the Maven Repository into "WEB-INF/lib". There is no reference to 1.0.0-SNAPSHOT anywhere in the Maven pom.xml files in the project.
What do you have in dependencies list inder the Dependencies tab for this module (that have these dependencies that should be updated)? Do you see them in the list?
Make sure you have all these Maven modules imported in this IDE project, including all parent Maven modules that you reference in all your pom.xml files. Verify that you see them in Maven tool window
Hi, sorry, I can't upload a screenshot due to the nature of the project.
Basically all references to 1.0.0-SNAPSHOT are removed from the pom.xml files, replaced with 1.1.0-SNAPSHOT. Running a "mvn clean install" builds the correct version of all of the code (1.1.0-SNAPSHOT).
In the "Dependencies" tab for the module, the in-project dependencies are all defined as (for example):
without the version listed. I think this is correct.
The project has all Maven modules imported, including all parent Maven modules, all are visible in the Maven tool window.
The current state of the project is that I have removed the files from the ".idea/artifacts" folder, and they have been recreated but with no elements under "root". I would expect this to have been recreated with the correct dependencies, but perhaps there is something stopping this from being populated from Maven?
I have created a new copy of the project which seems to be working OK so far, so I guess there is some inconsistency in the project settings?
Note that I have tried several things to resolve the problem in the "broken" project, but the basic structure of the project (with Maven modules) is something like this (although our project is much more complex):
Where "project" and "common" are both "root" Maven modules loaded into one IntelliJ project by using "Import module" in the Project Structure.
I first noticed the issue when the versions of both "common" and "project" changed, so IntelliJ was busy processing that for a little while (our actual project contains several hundred Maven modules). Everything was reimported and the dependencies looked correct, but the deployed artifacts were the old versions, although none of the code referenced the old versions:
So in Project Structure, the dependencies of the Modules look correct, but the Output Layout of the Artifact has not been updated.
As our project has many (many!) modules and dependencies, this is not something I want to have to manage by hand.
>Where "project" and "common" are both "root" Maven modules loaded into one IntelliJ project by using "Import module" in the Project Structure.
Is there a parent module for these two Maven project? If there is one try to import it also in IDE.
It is hard to guess without screenshots of dependencies or artifact configurations or sample project. If issue remains it would be helpfult to have some reproducer (a project/screenshots of the artifacts and dependencies/the project configuration files zipped). You can upload them privately to ftp://ftp.intellij.net/.uploads / https://uploads.services.jetbrains.com or any file sharing service.
Same here actually. I use the latest IDEA Ultimate, 2021.3.3 that is.
The (annoying) way to get this working, is:
I have to manually delete "File -> Project Structure -> Artifacts" that I want to deploy (regardless of "exploded" or "war"), then maven reimport, which recreates the deleted artifacts in the correct version, then "Clear Content" on deployed artifact in Tomcat and restart it.
Basically a simple maven reimport does not update the version in the Artifacts list, hence the deletion up front.
I should also mention that this has been working back then, but stopped doing so at some unknown point in the past.
@Erich Mauerboeck unfortunately, I cannot reproduce this: when in the war module I change the version for one of the dependencies (to another module) and reimport the Maven project - I see it is updated in the IDE Artifact configuration in WEB-INF/lib artifact directory changes:
Looks quite different here:
The screenshot shows that the is basically no artifact configuration. Does maven import complete successfully? Does Maven build the web artifact correctly from the command line? If you can you provide a sample project I can take a look into it with more details.
That's what I noticed.

yes, maven works as expected. my colleagues also don't have this effect. maven build helper plugin is in place, so all folders are correctly detected also.
Unfortunately no, I cannot provide you with a sample project due to company policy restrictions.
Here is however a screenshot regarding the exact same project from my colleague:
Try deleting the existing project configuration (.idea project directory) and re-importing the project using File | new | Project from Existing Sources action.
Make also sure all the Java EE related bundled plugins are enabled in Plugins settings.
Setting up the workspace from scratch (which is what you actually proposed) seemed to have done the trick.
Is there any chance I get back my settings?
Could you please clarify which settings do you mean? Thanks.
all the stuff that resides in "workspace.xml".
If I restore the backed up file, chances are that my problem would come back ;-(
Sorry, the workspace.xml file contains "current" temporary information about the workspace environment. It is not sharable and is re-created from scratch when the project is re-created. See this article for more details.
so no chance for IDE window layout (for example) to come back? or another example (marked was unselected after reimport):
These are project-specific options. If they were changed, please manually return them to the states you were using previously.
ok. thank you very much!
Andrey Dernov I ran into a problem related to this.
Artifacts create steps:
spring boot project, use maven pom.xml
When I update the pom.xml file under the current module, Artifacts will not update.
The IDEA automatically generated MANIFEST.MF, also not update.
When I add or delete dependencies in pom.xml and refresh pom, Artifacts are not updated.
I think Artifacts should automatically detect pom.xml dependencies.
Can you help me with this problem? Or do I need to submit a youtrack?
This is expected when you create or change the artifact manually. IDE will not update it on Maven update. As I see you are creating the artifact manually. IDE will only update those artifacts, which were automatically created by IDE from Maven pom.xml.