We have a project set up with maven for resolving dependancies. It usually works fine, but now I am trying to compile and run it on a new PC and I have problem with missing dependencies in Eclipse.
What is funny is that if I run "mvn package" in console or in eclipse, it works fine and even produces war containing all necessary jars. Only Eclipse complains with "The project was not built since its build path is incomplete. Cannot find the class file for org.slf4j.Logger...". If I compare the project with some other computer (where project works fine), I notice that there are quite a few libraries missing under "Maven dependencies" listing in Eclipse. Eventhough they are in the packaged war and they can be found also under repository folder.
So, the jar-s are there just Eclipse won't list them all under "Maven dependencies". What can I do?
Computer is running on Windows 7 with 64bit java & eclipse.
Well, I tried everything posted here, unfortunately nothings works in my case. So, trying different combinations I came out with this one that solved my problem.
1) Open the .classpath file at the root of your eclipse's project.
2) Insert the following entry to the file:
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
Then, rebuild your project at eclipse (Project->Clean-Build).
You now can check at the Java Build Path of you project at the Libraries tab the Maven Dependencies included:
Problem solved!
I don't know what exactly solved it, but I did 4 things in Eclipse:
Window->Preferences: Maven->Installations: Global settings -> open file and hardcoded localRepository
Project->Clean
right click on project: Maven->Update dependencies
right click on project: Maven->Update project configuration
I guess it was the Update dependencies since right after first two there were no change.
I'm also new to Eclipse, and I've been having a similar problem where Eclipse just won't recognize an import statement, even though all signs point to the dependency having been successfully downloaded.
You should check that your dependency file has actually been downloaded by going to the command line and typing
mvn dependency:tree
If you see your package there, then but Eclipse doesn't acknowledge it, the thing that works for me (sometimes) is to go to the terminal, cd into the project folder, and type
mvn eclipse:clean
then
mvn eclipse:eclipse
Finally refresh project in eclipse
I don't know why this works, and sometimes it doesn't work once, then doing it again does work... so worth a try!
I had this issue for dependencies that were created in other projects. Downloaded thirdparty dependencies showed up fine in the build path, but not a library that I had created.
SOLUTION: In the project that is not building correctly,
Right-click on the project and choose Properties, and then Maven.
Uncheck the box labeled "Resolve dependencies from Workspace
projects"
Hit Apply, and then OK.
Right-click again on your project and do a Maven->Update Snapshots
(or Update Dependencies)
And your errors should go away when your project rebuilds (automatically if you have auto-build enabled).
My Project was just screwed up. Here is how I fixed it for Eclipse Indigo x64 (J2EE 3.7.3):
Deleted my POM file (backedup of course).
Project Context Menu > Maven > Disable Maven Nature.
Deleted the project (but not contents on disk).
Re-imported as Import > General > Existing Project.
Project Context Menu > Configure > Convert to Maven Project....
Accept defaults from Maven wizard.
Overwrite POM with your backedup POM. (Now you have Maven Dependencies folder).
Maven Update/Clean for good measure.
Hope that helps someone. :)
Well, I tried everything posted here, unfortunately nothings works in my case. So, trying different combinations I came out with this one that solved my problem.
1) Open the .classpath file at the root of your eclipse's project.
2) Insert the following entry to the file:
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
Then, rebuild your project at eclipse (Project->Clean-Build).
For me the problem was maven couldn't find the settings.xml file which is located in myMavenFolder\conf.
What I did to fix the issue was to select the right location of the settings.xml file from eclipse:
Window -> Preferences -> Maven -> User Settings
Finally, hit apply and update your project
Just in case anybody has tried all the other options and you are still stuck, try right-clicking on the project folder, head over to Maven option and click the "add dependency" button. For some reason Eclipse isn't updating the dependencies manually from the pom.xml at first try.
I had a similar problem. I solved it by running the Maven->Update Project Configuration action
So I'm about 4 or 5 years late to this party, but I had this issue after pulling from our repo, and none of the other solutions from this thread worked out in my case to get rid of these warnings/errors.
This worked for me:
From Eclipse go to to Window -> Preferences -> Maven (expand) -> Errors/Warnings. The last option reads "Plugin execution not covered by lifecycle configuration" - use the drop-down menu for this option and toggle "Ignore", then Apply, then OK. (At "Requires updating Maven Projects" prompt say OK).
Further Info:
This may not necessarily "fix" the underlying issue(s), and may not qualify as "best practice" by some, however it should remove/supress these warnings from appearing in Eclipse and let you move forward at least. Specifically - I was working with Eclipse Luna Service Release 1 (4.4.1) w/ Spring Dashboard & Spring IDE Core (3.6.3), and m2e (1.5) installed, running on Arch Linux and OpenJDK 1.7. I imported my project as an existing maven project and selected OK when warned about existing warnings/errors (to deal with them later).
(Sorry, I'm not a designer, but added picture for clarity.)
For the following steps worked in my case:
1 On eclipse, right click on the desired project Maven -> Disable Maven Nature
2 Right click again then go to Properties. Delete every evidence of external Maven dependency leaving only JRE System Library.
3 Right click one more time on the project then go to Configure -> Convert to Maven Project
None of the solutions above worked for me, so this answer is for anyone else in my situation. I eventually found the problem myself, and a different solution. The pom.xml file contained a dependencyManagement tag that wrapped the dependencies, and M2Eclipse would not add the Maven Dependencies folder when this was present. So, I removed this tag, then carried out the solution offered by Ualter Jr., and Eclipse immediately added the missing folder!
Here is the steps which i followed.
1. Deleted maven project from eclipse.
2. Deleted all the file(.setting/.classpath/target) other than src and pom from my source folder.
3. imported again as a maven project
4. build it again, you should be able to see maven dependencies.
This is how I solved it
Window->Preferences: Maven->User Settings (Click on "open file" in resulting window, or just edit settings.xml with an external text editor like Notepad)
Make sure localRepository (which is displayed in this window) is correct. I had a typo in my file.
Once you have corrected settings.xml, click on Update Settings, which is on this same Preferences->Maven->User Settings screen.
Now rebuild, and it will install the latest JAR's in the correct location.
My answer is similar to that of #JerylCook: find another .classpath file in a working Maven project, edit your bad ones as that good working ones. The key is to add
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
in every <classpathentry> of type con and src. Don't forget to change <classpathentry .... /> to <classpathentry ...>xxx</classpathentry>.
At last, update the maven project and reinstall/rebuild in maven.
I got this error when had an error in Pom.
Run mvn eclipse:eclipse command on console to check that pom is parsable or not.
If not parsable search for the error.
If you have "nested paths" errors after performing Maven -> Update Project Configuration (or in Juno it's "Update Configuration...") then your build path is misconfigured.
Right-click project -> Build Path -> Configure Build Path
Ensure that only '/src' and directories at that level are included. If you have e.g. '/src' and also '/src/main/resources' present, this is incorrect. The second resource ('/src/main/resources') is "nested" under the first ('/src') which is causing your inability to import resources, since it prevents eclipse from seeing maven dependencies.
My issue sounds similar so I'll add to the discussion. I had cancelled the import of an existing maven project into Eclipse which resulted in it not being allowed to Update and wouldn't properly finish the Work Space building.
What I had to do to resolve it was select Run As... -> Maven build... and under Goals I entered dependency:go-offline and ran that.
Then I right clicked the project and selected Maven -> Update Project... and updated that specific project.
This finally allowed it to create the source folders and finish the import.
I could solve the error by
1) Right click (your maven project) -> maven -> maven install
After successful installation
2) Right click (your maven project) -> maven -> update project. And the whole error of maven got solved!
For me it was sufficient add a buildCommand (org.eclipse.m2e.core.maven2Builder) and a nature (org.eclipse.m2e.core.maven2Nature) in the .project file, like this:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>iText</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>
and I had
I had a similar issue and have tried all the answers in this post. The closest I had come to resolving this issue was by combining the Joseph Lust and Paul Crease solutions. I added the backed up pom.xml file after deleting and reimporting the project, and nothing showed up until I deleted the dependency management tag in the pom.xml and magically the dependencies folder was there.
However, it broke up the child POM's since they need the parent pom.xml dependency management to function, and as a result my MVN was not functioning properly on the project either from Eclipse or the command line, giving a broken pom.xml error.
The last solution if all fails, is to manually import the .jar files needed by your project. Right click the project Properties -> Java Build Path -> Libraries and Add external Jar.
If your MVN is working correctly from the command line and you have done a successful build on the project, you will have all the repos needed in your .m2/repository folder. Add all the external jars mentioned in your dependencies tag of pom.xml and you will see a referenced library section in your Eclipse, with all the pesky red errors gone.
This is not the optimal solution, but it will let you work in Eclipse without any errors of missing dependencies, and also allow you to build the Maven project both from Eclipse and command line.
This same problem happened to me, and it was because there an error in downloading a jar due to repo issues, indicated by a red flag in the pom.xml.
I added another repository so the red flag in the pom.xml disappeared and Eclipse then loaded the pom again, resolved its issue and listed the maven dependencies in Project Explorer. it sounds simple and obvious to resolve visible issues, but since Eclipse was quite happy to run maven, and build successfully, it was not obvious that the red flag and repo issue were at the root of its unwillingness to parse the pom and list the maven dependencies
mvn eclipse:clean
then from eclipse: "Maven Update Project" does the trick!
update the .classpath to below will work every time.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="WEB-INF/" kind="src" path="src/main/webapp"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Maven Dependencies: What solved it for me in Eclipse?
I added the dependency in the "pom" file. I did a build, but could not see the Maven Dependency in the Eclipse.
Next Step: Closed the project.
Then Reopened the project.
I could see the Maven dependencies.
I experienced a similar problem lately after i created a maven project, the maven dependencies folder did not appear in the project structure.To solve this simply add any dependency in the pom file, such as in code below, or right-click on the project and go to maven and select add dependency, search for any dependency such as junit add this, and the maven dependency should appear on your project structure now.
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.9.RELEASE</version>
<scope>runtime</scope>
</dependency>
</dependencies>
Just right click over Project folder and under maven > Update project > Select your project > OK.
it will automatically download all dependencies under pom.xml to folder named Maven Dependencies.
Open the .classpath file at the root of your eclipse's project.
It's so amazing that this one problem has so many different causes and possible solutions. I found yet a different solution that worked for me.
Well, it's not so much a solution but a discovery: I can see the Maven Dependencies node in the Package Explorer, which is the default for the Java perspective, but I can not see it in the Java EE perspective, which uses the Project Explorer by default. Both of those explorers look very similar at quick glance, so you may expect to see the Maven Dependencies in both.
As I was trying to figure this out, I hadn't realized that difference, so it wasn't really a problem for me in the end after all.
the whole project looked weird in eclipse, maven dependencies folder were missing, it showed some types as unknown, but I was able to build it successfully in maven. What fixed my issue was adding gen folder to source path on project build path.
Probably this is similar to this Android /FBReaderJ/gen already exists but is not a source folder. Convert to a source folder or rename it
Related
I have an Eclipse/Gradle project that looks like the following. One directory for .proto descriptors and one directory for the generated .java files for inclusion in other projects.
src/main/java
src/main/proto
I want to add my src/main/proto directory as an Eclipse source folder to make editing easier.
So naturally I add <classpathentry kind="src" path="src/main/proto"/> to my .classpath file. The source folder is added and everything is great until I run Gradle->Refresh which unkindly removes the source folder. My guess is that Gradle doesn't find any .java files in the proto folder and therefore removes the entire folder from .classpath. Is there any way to prevent this?
I have also tried:
<classpathentry kind="src" path="src/main/proto">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
from this question without success.
so the thing is that gradle will (re)-generate the .classpath file from scratch if you do the refresh. So anything you haven't defined at the gradle level will be lost!
How do you define the src folders in Gradle ?
Try to put the following block into you build.gradle:
sourceSets {
main {
java {
srcDirs 'src/main/proto'
}
}
}
This should add 'src/main/proto' to the eclipse classpath as long as the folder contain at least one file!
I'm working on a project that has lots of different Maven projects. I've been doing a bunch of JUnit testing on these projects, and usually this goes well. I open up Eclipse, right click in package explorer->Import... Existing Maven Projects and I'm able to import the project fine. I can build, drill down to src/test/java... Right click on the file and do a Run As JUnit test. Every now and then though, I can't get this to work. If I right click to do a Run As, all I get is AspectJ/Java application. There's no JUnit tests.
I noticed that the icon next to the project folder only has an M and a folder icon, whereas with projects that do work, there's a folder, M, AND a AJ. I've also noticed that it doesn't seem to sort the files into their packages like normal Java projects. It seems like it's not treating the project as an AspectJ project. How do I get Eclipse to recognize this Maven project as a Java project?
Several of the existing answers should work, but those suggesting to add a Java facet will only work if your project already is of (or you want to convert it to) a faceted nature, and the one suggesting you change your pom.xml will only work if you then re-import your project as a maven project.
If you'd like to "fix" your existing project, i.e. add a Java nature without converting it to faceted form and without deleting and re-importing, just edit your .project file (externally, or with the Navigator view in eclipse, as it won't show up in your package explorer) and add the java builder and java nature to the existing maven builder/nature:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>yourprojectname</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<!-- add this build command -->
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<!-- this would've already been there -->
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<!-- add this nature -->
<nature>org.eclipse.jdt.core.javanature</nature>
<!-- this would've already been there -->
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Note the different capitalisation (javabuilder but maven2Builder, javanature but maven2Nature).
As soon as you save, it should re-build automatically. You may have to manually add any source folders (Project properties -> Java Build Path -> Source tab -> Add Folder....
Right-click on Project -> Properties -> Project Facets, then choose all facets that apply for your case (e.g. java).
mvn eclipse:eclipse will create necessary .project files which will add java nature & other properties to the project
I was facing the same problem and the steps below solved it in my case:
1- Open the pom.xml of the problematic project.
2 -In the overview tab, check the Artifact/Packaging settings.
3- If it is set to "pom" change it to "jar".
4- Save your changes and then delete the project from eclipse only and re-import it.
Hope that helps!
It depends on the Eclipse project facet properties (if you are using Java EE), I suggest you right click on project properties and see which facet is defined for your project.
I faced the same problem(after importing pom.xml to eclipse,the project is not treated as a java one,and there is only "maven project builder" in project builders property,but no "java builder") in eclipse luna.
Re-importing maven project after deleting ".settings" folder and ".project" file did not work.
Re-importing after a workspace switch worked for me.
I talked to a co-worker and I was able to "fix" the problem. I did a delete from Eclipse (not from disk) and immediately re-did the Maven import and now it magically works.
It seems like if there was an error with the pom.xml, particularly if the parent version was wrong, that the maven project doesn't get imported/created properly. Once I fixed the problems in the POM, the project would build fine without any problems but it was still only a Maven project. Once I removed it and re-imported it, THEN it treated it as a Maven/AspectJ project.
Check the pom.xml file for projects that don't get the AspectJ nature (AJ on the project). Are they missing the AspectJ-Maven plugin? They should have a section like:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<!-- use this goal to weave all your main classes -->
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<complianceLevel>1.6</complianceLevel>
</configuration>
</plugin>
Also take a look at his question: Maven/AJDT project in Eclipse
There are two ways this can be achieved.
1) By Changing the project nature.
Right-click on Project -> Properties -> Project Natures, then choose all natures that apply for your case (e.g. java).
(OR)
2) By updating the .project file and add all the natures that are required for the project. This .project file is located at the root folder of the project. If the file does not exist for any reason, create a new file, and add the sections for each nature that is required e.g., as follows.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>yourprojectName</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
I know that this question was a long time ago...
I just resolved the issue by these 2 steps below.
run cmd "mvn eclipse:eclipse" in the root directory of the project
right-click on the project in eclipse then select "import as project"
My five cents...
In my case I was 'losing' always the 'Java' nature of the project because the pom file was set to 'package as ear'. There was no error or warning message though, which would be nice to have. As soon as I changed the package to 'jar' I could set the nature of the project to Java and it is persisted.
I also tried all the approaches described in this thread. Modifying only .project is not enough because the maven libraries will not be used for building the project and the project build will fail. mvn eclipse:eclipse will create a long and useless .classpath without actually using m2e.
The easiest way is to create a new java project, convert it to the Maven project and open the .project and .classpath for this new project. Then make similar changes for the imported Maven project.
The important changes for the .project file have been described but in order to use the Maven dependencies in Eclipse something like this should be in the .classpath file
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Using facets is not an option in this case because with facets Eclipse doesn't use m2e and the maven dependencies. Again the dependencies with facets have to be managed manually.
I tried all this with Eclipse 4.6.2 Neon.
I had the same problem. In my case it was some defect in eclipse workspace. I recreated it (deleted .metadata directory) and that fixed the issue.
If you have tried Amos M. Carpenter's solutions on the .project and didn't work, go to Project -> Properties -> Project Nature and Add... Java, Apply and Close button.
Nothing above helped me. After hours of trying (shortly before crying) I imported the projects not by "Import from existing maven projects" but instead with "Projects from Git".
Everything is fine now. The Java Projects are Java Projects again!
Right click the project and click on the Properties --> Select Maven --> (In active maven profiles) give "pom.xml", Apply and close. enter image description here
Go to u r project folder and delete .settings
and rebuild the maven application
then try with running project
Good Luck
I have a strange behavior in the Tomcat deployment process made by my Eclipse WTP.
I am using Eclipse 3.7 (Indigo), WTP 3.3, no m2eclipse plugin, Java 1.6, Tomcat 5.5.
My application is a web application that have some other projects as dependencies, as well as some third-parties dependencies.
My project is managed by Maven, and everything works fine when we build the application using this tool.
To work on my project using Eclipse, I run mvn eclipse:clean eclipse:eclipse and then, I import my projects in the IDE.
My problem occurs when I want to deploy this web application on a Tomcat 5.5 server (this server is managed by Eclipse).
When I create a new Tomcat server, and deploy my my-project-portal application in it, it only adds the my-project-xxx dependencies, as well as few third-parties dependencies (about 9 of the hundreds defined).
On one of my colleagues desktop (he is using Eclipse 3.5), no third-parties dependency are deployed at all, just the my-project-xxx JAR...
However, when I look at the web-app project properties, in Java Build Path > Libraries, or in "Deployment Assembly", the list of dependencies is correct and complete.
Notes
I did some tests with an older Eclipse (3.3, with WTP 3.1) and I do not encounter any deployment issue.
However, this WTP was still using the "Java EE Modules Dependencies", which is not the case of the latest WTP version.
Until now, we used a custom Maven plugin after the mvn eclipse:eclipse that copies all the dependencies (including transitives ones) into my-webapp-project/WebContent/WEB-INF/lib.
Doing that, Eclipse automatically deployed the content of these dependencies, and thus, we got all the dependencies in the Tomcat server.
Questions
What is wrong with my process?
Do I really need to copy all the dependencies in the WEB-INF/lib directory?
What is the normal procedure when we want to deploy a web application on a Tomcat server, using Eclipse?
Here is an extract of my Eclipse configuration files after running mvn eclipse:eclipse:
.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/asm/asm/2.2.2/asm-2.2.2.jar" sourcepath="M2_REPO/asm/asm/2.2.2/asm-2.2.2-sources.jar"/>
<classpathentry kind="src" path="/my-project-business"/>
...
<classpathentry kind="output" path="WebContent/WEB-INF/classes"/>
</classpath>
.settings/org.eclipse.wst.common.component
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="my-project-portal">
<property name="context-root" value="my-project-portal"/>
<wb-resource deploy-path="/" source-path="/WebContent"/>
<property name="java-output-path" value="/WebContent/WEB-INF/classes"/>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
...
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/my-project-business/my-project-business">
<dependency-type>uses</dependency-type>
</dependent-module>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
</wb-module>
</project-modules>
I think you have a misconfiguration problem because:
If your project is managed by maven, you will never need to set your '.classpath' with the dependencies needed by this tool, for example if you need one different library or change the version of one, you will need to update the configuration in your eclipse project, etc. Idem for your 'org.eclipse.wst.common.component' file.
I think you will need to install the WTP support for m2eclipse like #stivlo says, of course install the m2eclipse and review your project configuration, because you need to remove all the dependencies defined in those files.
Right now, I never copy all the dependencies in the /WEB-INF/lib directory, because I don't want to have to keep an eye on those directory. For example, when I need to start Tomcat, the m2eclipse plug-in deploys automatically all the libraries and differences (i.e static files, classes, resource files, etc) in the internal Eclipse directory related and that's it, the server starts with the context, with all the files needed. I'm always using the plugins related in Eclipse for convenience.
I use maven and eclipse (with m2eclipse) for Java projects. I usually start with
$ mvn archetype:create \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.whatever.app \
-DartifactId=wonderapp
$ mvn eclipse:eclipse
and then import the project into eclipse. The build path in eclipse now contains an "Excluded: **" pattern for the src/main/resource path. If I put for example the log4j.properties file in src/main/resources, it will not be copied to the output path and hence log4j won't work properly.
(source: skitch.com)
After I ran mvn eclipse:eclipse, the .classpath file in the root directory contains this line:
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
After importing in eclipse, it has changed to:
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
I end up having to manually remove the "**" pattern. Is there any way so that I don't have to do this?
I use maven and eclipse (with m2eclipse) for Java projects. I usually start with (...) and then import the project into eclipse.
Why do you use mvn eclipse:eclipse with m2eclipse? Just create your project and then Import... > Existing Maven Project.
I'm using JUnit 3 in Eclipse Galileo. The junit.jar (located in the project in vendor/lib/) contains both the classes and the javadoc. In my project which I share using CVS, I want the doc to be available for everybody who checks-out the project. So I committed the .classpath file.
When adding the javadoc path to the lib using the Eclipse UI I get the following classpath entry:
<classpathentry kind="lib" path="vendor/lib/junit.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/MyProject/vendor/lib/junit.jar!/javadoc"/>
</attributes>
</classpathentry>
Note that "MyProject" is the local name of the Project. This name is not necessarily the same for each person on the team (also I have multiple local copies, which must have different names). So this classpath entry is not portable from one copy of the project to another.
What I want to achieve is a javadoc location which is only relative to the project (as is the lib files location for example).
I tried the following without success:
<classpathentry kind="lib" path="vendor/lib/junit.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:vendor/lib/junit.jar!/javadoc"/>
</attributes>
</classpathentry>
How should I set the classpath entry so that the javadoc is taken from a jar in the project without reference to the platform or external location?
May be you have to place the folder "MyProject" to CVS so that everyone will get same folder name.
My understanding, a big project usually contains many eclipse projects and we often put them together in one folder. like:
+trunk/
+ MyProject
+ module1
+ module2
+ .....
+ modulen
+ YourProject
+ yourModule1
+ yourModule2
+ .....
+ yourModulen
It works fine to me until now.
As far as I understand, if your jar file is not in the root of the project, you must use an absolute path to reference it. If you would like to use a relative path to the project, you might have to consider moving the jar file to the root of the project.
HTH,
Jc