Alex Rivera | Logout

Is there a way to hide Maven 2 "target/" folder in Eclipse 3?

Asked 2008-11-12T10:15:03.957
49

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, it will be "polluted" by files from Maven's target directory.

That's very annoying while performing searches, getting resources by "open resource" and so on.

Is there a way to avoid Eclipse looking in this folder?

Edit
Report

3 Answers

4

To solve this problem here is what I did:

  • Install Groovy Monkey for Eclipse
  • Created a Bean Shell Script "UpdateMavenDerived_Beanshell.gm" to mark any directory named target as derived.
  • -----------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);
                }
            }
        }
    }
    
    answered 2011-06-15T15:12:44.883
    3

    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

    answered 2008-11-12T12:25:14.117
    0

    When Eclipse freezes, looking at the process activity, I can see it browsing all my target, .hg and .git directories. Moreover, those directories are also copied into Eclipse's bin directory. A lot of CPU and disk usage for nothing.

    Not cleaning the target directory is not an acceptable solution.

    There was a solution using a Monkey script (http://maven.40175.n5.nabble.com/Eclipse-amp-target-directory-td72354.html) but the project has been closed.

    I still look for a solution to tell Eclipse to ignore Maven target directories, as well as .hg and .git directories.

    Eclipse continuously watching those is a pain.

    I also use m2eclipse but it doesn't solve that issue.

    answered 2011-05-11T13:34:33.257

    Your Answer