I\'m using maven 2.0.9 with Eclipse 3.3.2.
I\'m used to launching a fresh build once per day by a mvn clean install
.
Then, if I refresh my Eclipse project,
To solve this problem here is what I did:
-----------Cut below here for script--------------
/*
* Menu: Find System Prints > Beanshell
* Script-Path: /GroovyMonkeyScripts/monkey/UpdateMavenDerived_Beanshell.gm
* Kudos: Bjorn Freeman-Benson & Ward Cunningham & James E. Ervin
* License: EPL 1.0
* LANG: Beanshell
* DOM: http://groovy-monkey.sourceforge.net/update/plugins/net.sf.groovyMonkey.dom
*/
out.println("Setting target directories to derived status.");
var projects = workspace.getRoot().getProjects();
for ( var i = 0; i < projects.length; i++) {
var project = projects[i];
if (project.isOpen()) {
out.println("Project: " + project.getName());
var members = project.members();
for ( var j = 0; j < members.length; j++) {
if (members[j].getName().equals("target")) {
out.println("setting derived status on: "+ members[j].getFullPath());
members[j].setDerived(true);
}
}
}
}
I had some issues because some solutions here only work for some views, so I made an illustrated summary.
Tested in Eclipse 4.4 (Luna), should work like this since 3.7 according to other answers here.
Package Explorer View Menu → Filters...
→ check Name filter patterns
and input target
.
Be careful, this will hide all folders and files named target
, not just the default maven build directory! The Project Explorer view has a better option without this issue.
Project Explorer View Menu → Custom View...
→ search for "maven" and check Maven build folder
.
Checking this option hides the build directory as defined in the projects pom.xml configuration.
Solution for Indigo [SR2]
Project Explorer
> Customize View
> Filters
> [*] Maven Build Folder
Did you try configuring the "Java Element Filters" option dialog box, (through the top-right arrow of the project explorer) ?
If needed, you can define your own ViewerFilter
The maven plugin does not hide away the target directory. It does however use the maven target folders to configure eclipse. So target/classes and target/test-classes are used by eclipse, and eclipse filters these folders out. This is done by "mvn eclipse:eclipse" as well as by the m2eclipse plugin. What is left visible is everything in the target directory besides these two folders (the generated jar file for example).
You can create a filter for the package explorer, but that will not influence the "open resource".
Reconfigure "clean" in Maven not to delete target directory:
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<!-- delete directories that will be generated when you
start the develpment server/client in eclipse
-->
<fileset>
<directory>target</directory>
<includes>
<include>**/*</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
(found at: http://maven.40175.n5.nabble.com/how-to-NOT-delete-target-dir-td3389739.html#a3413930)