3

I cannot clean the maven project. who know the best way,thanks.

the maven project in eclipse.

when i run mvn clean package,first it will run successful

two times after, i cannot do it will get error.

Deleting C:\Codes...\target

BUILD ERROR

Failed to clean project: Failed to delete C:\Codes...\target

I already tried to shut dowm eclipse is still error.

i trid to login off and login in and it will be ok;

but it not a good way to solve it .

who know other way,thanks!

5 Answers 5

3

Some file of the target folder is locked by another program or you may not have permission to delete folder

so go and delete folder manually by using Windows Explorer if not open a windows explorer with administrative right and then go to that folder and delete.

now you can run mvn clean install it will works fine.

Sign up to request clarification or add additional context in comments.

Comments

0

It is not able to delete because you must be accessing some file from it. So simple solution would be to close any files which you might have opened from target folder [inside or outside eclipse]. Once you dont access the folder or any of its contents then folder shld get deleted.

Comments

0

If you continue to have this problem, you have something of a bother.

As Lokesh explains, something is holding a file handling, preventing maven from deleting the directory. It could be eclipse, or something from the build, it can be hard to spot.

If there are any files in the non-removable directory, they may provide you with a clue.

Comments

0

I've faced the same issue, there is a process that holds a lock in the file on some subfolder that Maven is trying to clean.

Check that your Tomcat instance is really stopped or look for java processes in Task Manager that shouldn't be there. If there then End Task. (My Case)

Check and close that file from notepad or any other application

If these steps failed, try restarting your machine. (This will definitely resolve)

Comments

0

I use MobaXterm to upload the war file to our test/prod servers. Somehow the tool keeps the file/folder locked and the delete is not allowed.

Solution:

  • Close MobaXterm and build. this can be inconvenient as the session is lost

  • Configure Maven to write the war file to a different directory than target. In MobaXterm use this dir to upload the file. As the maven clean doesn't need to delete this directory, everything works fine now.

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warName>NAME OF THE WAR FILE</warName>
                    <outputDirectory>SEPEREATE LOCATION (I use .../workspace/bin</outputDirectory>
                </configuration>
            </plugin>
        </plugins>
    
    </build>
    

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.