Hi,

You should not create a plain java project and adding manually stuff to the
.classpath or .project.

Just remove your project from workspace, delete your .classpath, .project
file, and import it as a maven project.
M2e will generate a correct .classpath and .project that will handle
correclty the resources files.


On Sat, Mar 29, 2014 at 12:20 PM, Bruno Haible <[email protected]>wrote:

> Hi,
>
> With m2e 1.4.0.20130601 I observe that the .classpath file generated by
> "Maven > Update project" leads to inconsistent behaviour between Maven and
> Eclipse.
>
> Namely, when Eclipse builds the project, it copies all files except *.java
> and *.class
> from src/main/java/ to target/classes/, whereas Maven does not. This leads
> to different
> runtime behaviour (regarding whether resource files will be found or not),
> and the
> developer wastes time tracking this down.
>
>
> How to reproduce
> ================
>
> 1) In Eclipse, create a new plain "Java Project".
>    In its Java Build Path, set the source directory to src/main/java
> instead of src.
>
> 2) To the project's .project file, add the following code snippets:
>         <buildCommand>
>             <name>org.eclipse.m2e.core.maven2Builder</name>
>             <arguments>
>             </arguments>
>         </buildCommand>
> and
>         <nature>org.eclipse.m2e.core.maven2Nature</nature>
> 3) Add a pom.xml:
> <project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";
>         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd";>
>         <modelVersion>4.0.0</modelVersion>
>
>         <groupId>com.example</groupId>
>         <artifactId>zzztest</artifactId>
>         <version>1.0-SNAPSHOT</version>
>         <packaging>jar</packaging>
>         <name></name>
>
>         <properties>
>         </properties>
>
>         <dependencies>
>         </dependencies>
>
>         <build>
>         </build>
>
> </project>
>
> 4) In Eclipse, on the project, do "Refresh" (F5).
>
> 5) In Eclipse, on the project, do "Maven > Update project".
>
> 6) Create some files in the directory src/main/java/:
>   $ echo 'public class main {}' > main.java
>   $ touch main.xml
>   $ touch main.properties
>   $ touch other.class
> In Eclipse, on the project, do "Refresh" (F5).
>
> 7) Execute the compilation through maven:
>   $ mvn clean package; ls -1 target/classes/
>   main.class
>
> 8) Execute the compilation through Eclipse:
> In Eclipse, select the project, then do "Project > Clean..." (with
> "Build automatically" turned on).
>   $ ls -1 target/classes/
>   main.class
>   main.properties
>   main.xml
>   META-INF
>
> As you can see, Eclipse copies resource files to target/classes, while
> Maven does not.
>
>
> The problem
> ===========
>
> The problem is the .classpath that "Maven > Update project" generated.
> It contains the line
>   <classpathentry kind="src" output="target/classes" path="src/main/java">
>
> Instead, it should contain the line
>   <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
> With this line, the list of resources is consistent:
>   $ ls -1 target/classes/
>   main.class
>   META-INF
>
>
> Best regards,
>
> ----------------------------------------------------------------------------
> Bruno Haible                            Email: <[email protected]>
> IBM Deutschland
> Wilhelm-Fay-Straße 30-34
> 65936 Frankfurt am Main
> Germany
>
> ----------------------------------------------------------------------------
> IBM Deutschland Research & Development GmbH
> Geschäftsführung: Dirk Wittkopp
> Sitz der Gesellschaft: Böblingen
> Registergericht: Amtsgericht Stuttgart, HRB 243294
>
> _______________________________________________
> m2e-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/m2e-users
>



-- 
Adrien Rivard
_______________________________________________
m2e-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/m2e-users

Reply via email to