krishnakumar
krishnakumar

Reputation: 173

maven eclipse plugin generate wrong class path entry

I am using maven 3.6.0 and using maven eclipse plugin in POM file for generating eclipse .classpath (for my dependencies) file. The build successfully completed and when i try to configure eclipse project. I got build path error like 1. jar is not present in class path, but the jar is there in lib folder 2. Expecting different jar version, but the version in lib is different

Instead of creating .classpath using maven. I created one locally and copying it as resource in my eclipse project.

 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.10</version>
                <configuration> 
                    <excludes>
                        <exclude>org.testng:testng</exclude>
                        <exclude>com.beust:jcommander</exclude>
                        <exclude>org.yaml:snakeyaml</exclude>                        
                        <exclude>org.apache-extras.beanshell:bsh</exclude>                       
                    </excludes>
                </configuration>
                <executions> 
                    <execution> 
                        <phase>prepare-package</phase> 
                        <goals> 
                            <goal>eclipse</goal> 
                        </goals> 
                    </execution> 
                </executions> 
            </plugin>
<execution>
                        <id>copy-eclipse-deps</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${setupDir}/Engine</outputDirectory>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <resources>        
                                <resource>
                                    <directory>${project.basedir}</directory>
                                    <includes>
                                        <include>.classpath</include>
                                        <include>.project</include>
                                    </includes>
                                </resource>
                            </resources>              
                        </configuration>            
                    </execution>

Currently i have just commented out .classpath line and copying the file as resource by correcting all the class path errors.

I want to achieve it through maven itself else i will end-up adding new entries in classpath every time i introduce third party jars.

Upvotes: 0

Views: 415

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35805

When you use Maven, you should not write anything manually into .classpath. Furthermore, you should not use the maven-eclipse-plugin at all.

When you use a recent Eclipse, m2e plugin in Eclipse automatically handles .classpath. The only place you add/edit dependencies is the pom.xml.

Upvotes: 0

Related Questions