membersound
membersound

Reputation: 86687

How to regenerate target folder on Maven 'package'?

My project compiled folder is /project/target/appname-0.24-SNAPSHOT/, which will will result in appname-0.24-SNAPSHOT.war on mvn package.

How can I clean/regenerate this specific target folder before packaging?

I cannot execute mvn clean as this would clear the whole target folder, which I'd like to prevent because it contains lots of auto-generated webservice classes, which then in turn also would have to be regenerated and take a lot of time.

I'd only like to regenerate my project resources in ${project.build.directory}. Is that possible?

maven config:

                            <filesets>
                                <fileset>
                                    <directory>target</directory>
                                    <excludes>
                                        <exclude>generated/*</exclude>
                                        <exclude>classes/*</exclude>
                                    </excludes>
                                    <followSymlinks>false</followSymlinks>
                                </fileset>
                            </filesets>

Upvotes: 0

Views: 3100

Answers (1)

Ankit Kumar
Ankit Kumar

Reputation: 1463

you can do that using the maven-clean-plugin with a combination of

  • excludeDefaultDirectories to stop it from deleting the whole directory
  • filesets to tell it what to delete

ref: http://maven.apache.org/plugins/maven-clean-plugin/clean-mojo.html

Upvotes: 2

Related Questions