Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » M2E: Faulty generation of .classpath file?(M2E: Faulty generation of .classpath file?)
M2E: Faulty generation of .classpath file? [message #1829111] Thu, 25 June 2020 10:31 Go to next message
Chris Ainsley is currently offline Chris AinsleyFriend
Messages: 78
Registered: March 2010
Location: UK
Member
Hello,

I'm having very strange issues (?) with M2E. Maybe I've configured it wrong, but I really can't see how I have.

My directory structure for an Eclipse Maven project is as follows (I am 100% sure that Eclipse is treating the project as a Mavenized project):

/src-gen/main/java


  • Compile - YES
  • Copy contents to classpath - NO


/src/main/java


  • Compile - YES
  • Copy contents to classpath - NO


/src/main/resources


  • Compile - NO
  • Copy contents to classpath - YES


/src/main/java2


  • Compile - YES
  • Copy contents to classpath - YES


How I set this up in the pom.xml

Part 1 (top level):

I configure the two folders from which I should copy all resources in the <resources> section:

<resources>
	<resource><directory>src/main/resources</directory></resource>
	<resource><directory>src/main/java2</directory></resource>
</resources>


Part 2 (inside <plugins>)::

I configure the three folders that should be used as source folders for the Java compiler here (with .class files added to the classpath) here:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>src/main/resources</source>
<source>src/main/java2</source>
<source>src-gen/main/java</source>
</sources>
</configuration>
</execution>
</executions>
 </plugin>


THE PROBLEM

The problem comes that when I select the project and select ALT + F5, the .classpath file in the project is updated as follows:

<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/java2">
	<attributes>
		<attribute name="maven.pomderived" value="true"/>
	</attributes>
</classpathentry>


The problem is that excluding="**" is stopping any of the Java code from the src/main/java2 folder from being added to the classpath.

If I compile my project at the command line with "mvn clean package", everything is fine, it's the faulty generation of the ".classpath" file in Eclipse that is the issue.

Please can someone tell me how to resolve this issue.

Currently my workaround when I build is to build with maven, then to manually modify the classpath file until I rebuild. It's a frustrating workaround.

I'm happy to create this as an issue in the issues tracker if this is a bug.

Thanks,

Chris
Re: M2E: Faulty generation of .classpath file? [message #1829119 is a reply to message #1829111] Thu, 25 June 2020 12:01 Go to previous message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
I think M2E is adding excluding="**" for the src/main/java2 classpath entry because it's set as a resource folder:

<resources>
	<resource><directory>src/main/resources</directory></resource>
	<resource><directory>src/main/java2</directory></resource>
</resources>

Isn't setting java2 as a source folder thanks to the Build Helper plug-in enough to compile the sources contained in java2? As I understand it, using both the Build Helper plugin and <resources> means "compiles the source files to target/classes AND copy the source files to target/classes but without compiling them", is that really what you want?

That being said, I can't reproduce the issue on Eclipse 2019-09 with M2E 1.13:

<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java2">
	<attributes>
		<attribute name="maven.pomderived" value="true"/>
		<attribute name="optional" value="true"/>
	</attributes>
</classpathentry>

Are you using a recent Eclipse release? You may also want to ask the question on the M2E mailing list: you'll be more likely to have accurante answers.
Previous Topic:Maven POM problem after upgrade
Next Topic:jtable
Goto Forum:
  


Current Time: Sat Dec 05 00:15:10 GMT 2020

Powered by FUDForum. Page generated in 0.01604 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top