saravana_pc saravana_pc - 1 month ago 12
Java Question

m2eclipse not copying src/main/resources to target

I have a maven project and I have installed m2eclipse. When I build the project, the files inside src/main/resources are not getting copied into target/classes folder.
Any help is highly appreciated.

Answer

After reading all your comments about when resources get copied and when they don't (i.e., everything works fine until Eclipse build gets called), it's very possible that maven2Builder is disabled. You could have maven2Nature which neatly configures your classpath, but if you disable maven2Builder, only sources will be compiled and copied to target/classes (or whatever is configured in your .classpath) due to active Java Builder.

Consider a very simple demo-project configuration (.project file in Eclipse project root):

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>m2demo</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <!-- 
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
         -->
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
    </natures>
</projectDescription>

In this example, I have commented maven2Builder which results in exactly the same behavior you are getting.

I usually like to see the actual .project and .classpath file contents, but it all can be accessed via Project Properties. You will find a 'Builders' section in you project properties, and there should be 'Maven Project Builder' checkbox item.

Comments