views:

18

answers:

3

I have seen this:

<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>

In my Eclipse .classpath file many times when creating a new Maven project, but I can not seem to figure out - what in the heck does excluding="**" mean?

EDIT: I guess what I am trying to get at here, is that though it seem like excluding="**" should exclude everything in src/main/resources, yet - it does not. When I create a test project and put in folders (for example: META-INF) they DO in fact show up in target/classes. Why? What is the point of the exclusion then?

TIA

+1  A: 

** is a special pattern that matches every file in the base path and all files in all sub directories of it. In your example it simply excludes all files inside src/main/resources.

x4u
Then why when I do a project clean does everything in src/main/resources still end up in target/classes?
javamonkey79
+1  A: 

It basically means 'exclude everything'. ** is a wildcard that matches any file or directory, anywhere in a directory tree.

It's useful for Subversion .svn folders, for example, which can appear at any level in a source tree. In that case you could exclude **/.svn, which would match any .svn folder. In this case, **/ is matching any directory in the tree.

Richard Fearn
Yet, when I add folders and source files to src/main/resources they still show up in target/classes; this doesn't seem to line up.
javamonkey79
+1  A: 

Since you are using m2eclipse, the .project file in your project contains

<buildCommand>
    <name>org.maven.ide.eclipse.maven2Builder</name>
    <arguments>
    </arguments>
</buildCommand>

This is overriding the Java builder, and copying the folders in /src/main/resources into the /target/classes directory.

If you were to remove the above build command, and clean your project, the files in /src/main/resources should go away. If you add in the build command, your files should reappear.

I realize this doesn't answer the stated question of what excluding="**" does, but this explains the behavior your are seeing.

Matt