Maven clean won't delete copied resources
eclipse, java, maven
Solution
If question is `how to disable eclipse to run specific plugin` than you can put in under specific profile that is active by default
<project>
...
<profiles>
<profile>
<id>not-eclipse</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
...
</plugins>
</build>
</profile>
...
</project>
and place `! not-eclipse` in profile settings of eclipse project
Problem
To make my life easier, I configured my maven to put my deployed application in a different folder (`/deploy`) than the default (so it doesn't mix with `classes/`, `surefire-reports` directories and so forth). It works fine, except that when I try to run `mvn clean`, it only deletes the jar and copied dependencies, but NOT the copied resources. UPDATE It appears they are being deleted, but then get placed back immediately. It appears to be related to using Eclipse and `Build Automatically`, but I'm not sure why changing Maven's configuration would have this effect on Eclipse. END UPDATE UPDATE 2 At the present moment, none of the answers are correct. This problem clearly has little to do with the `deploy` directory; it seems that maven-resources-plugin makes Eclipse copy resources as part of Build Automatically. But I'm not sure how to turn this off without stopping using maven-resources-plugin, and without stopping using Build Automatically I will give the bounty to someone who can explain how to do this. END UPDATE 2 Anyway, my directory looks something like this: ``` my-app |-- pom.xml |-- src | |-- main | | |-- java | | `-- resources | | |-- script.sh | | `-- config | | `-- app.properties | `-- test | |-- java | `-- resources `-- deploy |-- my-app.jar <----- This gets deleted correctly |-- lib <----- This gets deleted correctly | |-- dependency1.jar <----- This gets deleted correctly | |-- dependency2.jar <----- This gets deleted correctly |-- config <----- This DOES NOT get deleted correctly | `-- app.properties <----- This DOES NOT get deleted correctly `-- script.sh <----- This DOES NOT get deleted correctly ``` Here's my `pom` snippet: ``` <plugin> <artifactId>maven-jar-plugin</artifactId> <version>${maven.jar.version}</version> <configuration> <archive> <manifest> <mainClass>my.main.Class</mainClass> <packageName>my.main</packageName> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> </manifest> </archive> <excludes> <exclude><!-- the files I don't want in my jar --></exclude> </excludes> <outputDirectory>${basedir}/deploy</outputDirectory> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.1</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${basedir}/deploy/lib</outputDirectory> <includeScope>compile</includeScope> </configuration> </execution> </executions> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>copy-resources</id> <phase>install</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${basedir}/deploy</outputDirectory> <resources> <resource> <directory>${basedir}/src/main/resources</directory> <filtering>false</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.5</version> <configuration> <filesets> <fileset> <directory>deploy</directory> <includes> <include>**/*</include> </includes> <followSymlinks>false</followSymlinks> </fileset> </filesets> </configuration> </plugin> ```