I have been facing an issue for a long time with the following command:
mvn clean install -PautoInstallSinglePackage
Sometimes it runs and just works. Other times it fails with this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.0.0:clean (default-clean) on project aem-mysite-project.ui.apps: Failed to clean project: Failed to delete C:\git\MySite\ui.apps\target\generated-sources\htl\org\apache\sling\scripting\sightly\apps\mysite\components\tabs\tabs__002e__html.java -> [Help 1]
The failure is seemingly random. It happens on various files, but it happens daily. I've been trying to chase this down, and I've been able to identify via an app called LockHunter.exe that the "Language Support for Java" plugin for VSCode by Red Hat is the culprit.
Does anyone have a solution for this? Are there alternative plugins for VSCode that can be used to easily work with AEM/Java projects from VSCode? Maybe a command I can pass to maven to get it to unlock?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Could you possibly be accessing the project's target through multiple applications at the same time? Like IDE + Windows Explorer etc. If yes, please close other applications before rebuilding the code.
In case it persists, close all applications accessing target folder. Delete target folder manually, then rebuild the code.
The only options I am aware of are:
1. Manually delete the target folder from your project
2. Restart the IDE, in your case VSCode
3. Run Maven one time with -Dmaven.clean.failOnError=false parameter
Try manually deleting the target folder from the ui.apps module and then run mvn clean install again. If that doesn’t work, run mvn clean separately before trying the build. Also, check if any program like an IDE (IntelliJ, Eclipse, VS Code) is using the folder—close it and any open terminals before retrying. If the issue persists, restarting your system might help.
Regards
Ayush
Could you possibly be accessing the project's target through multiple applications at the same time? Like IDE + Windows Explorer etc. If yes, please close other applications before rebuilding the code.
In case it persists, close all applications accessing target folder. Delete target folder manually, then rebuild the code.
To fix the Maven clean error:
1. Manually delete the target folder and run mvn clean install again.
2. Close VSCode and any other apps accessing the project directory.
3. Try running Maven with:
mvn clean install -Dmaven.clean.failOnError=false -PautoInstallSinglePackage
4. Restart your system if the issue persists.
Also, ensure the VSCode Java plugin is up to date or consider trying a different one.
I would recommend using IntelliJ as this won't come up over there. or whenever such issue happens you can either manually delete the target folder or restart the vs code and it will work.