Quick answer
Yes, Maven's target folder is safe to delete. It contains compiled classes and packaged artifacts; mvn package rebuilds it.
Rebuild with mvn package
What is it?
target/ is Maven's build output: compiled classes, test reports, and packaged JARs or WARs.
Why does it get so big?
- Packaged artifacts including fat JARs
- Test reports and generated sources
- Multi-module builds have one target per module
How to clean it from the command line
Review what a command matches before you run anything with rm -rf. These deletions are permanent.
What not to delete
- pom.xml
- ~/.m2/repository (local dependency repository)
How Gigaflush handles Maven
Gigaflush lists target only when pom.xml sits right beside it, shows each folder's size, preselects nothing, and re-checks the folder immediately before deleting it. Symlinks and parent-directory paths are refused.
FAQ
Is it safe to delete the Maven target folder?
Yes. mvn package or mvn install recreates it.
Can I delete ~/.m2/repository?
Yes, but Maven re-downloads every dependency and anything you installed locally with mvn install is lost.