We use Maven to compile our project on the build server. We update our sources from SVN, and then run "mvn install" from the project folder, creating a jar, which we then deploy to our production servers.
To save compilation time, we save the compiled classes before recompilation (in the target / classes folder maven creates). Thus, Maven only needs to recompile new or modify java files.
But there is a problem with the moved / deleted files: updating SVN removes the .java files from the source path, but Maven does not remove the compiled .class files from the target / classes. The same goes for files that are deleted from the main / resource folder. Thus, the remote / moved classes and remote resources still end up in the jar file that we deploy on our production servers, and this causes problems.
I know that we can "mvn clean" to get rid of any compiled files, but in this way we need to recompile the whole project for each assembly, which costs a lot of time.
Does anyone know a way to remove obsolete .class files and resources before or during Maven compilation?
source share