I know how to add maven dependencies in eclipse. But I am looking for organizing them.
After issuing
eclipse:eclipse
and importing the project in the eclipse, all the dependency library appears.
Now from what i have experience all the dependent jar were all under the "Maven Dependencies". But i see all the jar are loose - just under the project name.
Basically what i am interested is from
to this :
Rather than using mvn eclipse:eclipse and importing as existing project, got to
File-> Import-> Maven-> Existing Maven Projects
and select your project from there. If you do it that way, your maven dependencies should come up under Maven Dependencies section.
Related
I have some projects with many json files that when compiling them with maven generate many java bean classes and I have a main project that has the maven dependency of these other projects. Well, if the other projects are closed, when updating the maven dependencies it gets the compiled projects in my .m2 folder and the main project does not show errors in STS, but, instead, the projects are open, STS changes that dependency from the .m2 folder to the open project, and it does not find the java classes in the source folder because they are in the target.
How can I tell STS not to use the projects that are named the same as the maven dependencies? This way I compile the projects independently from the console and update the dependencies to the main project when necessary.
Right-click on the project, select "Maven" and then "Disable Workspace Resolution". I do this for every project. I wish there was a way to set this as a global preference. I wrote a shell script that whacks on all the .settings files in my project to set this flag for all my existing projects.
I am using Maven m2e as my Eclipse project.
My Maven project was acting weird so I right clicked my pom.xml and went to run as -> maven build then under goals I first did eclipse:clean and then eclipse:eclipse. Before I did that all my JARs were inside the Maven Dependencies folder. Now most of my jars are located in my project folder, outside the maven dependencies folder. Why is that? And how can I revert those changes?
This is how it looks now:
mvn eclipse:eclipse is a relic from ancient times, don't use it.
Basically, what it does is taking the information from a pom.xml and using it to create a native Eclipse project. That was a nice approach 5 years ago, when Eclipse didn't understand Maven projects, but ever since m2eclipse / m2e were introduced, this approach was deprecated in favor of these plugins that actually try to understand the pom.xml.
I have a Netbeans Ant project that uses a Jar file generated from a Netbeans Maven project. I would like to "include" the Maven project directly in the Ant project to be able to proper debug both projects. The Maven project was converted from an Ant project and before the conversion this include was possible. I have control over both projects, but converting the Ant project to a Maven project is not really an option at this point. What is the best approach to make an Ant based project and a Maven based project "work" together i Netbeans?
Thanks
it should work if your ant project includes the maven local repository jar as dependency. Maven support does automatic binary->open project source conversion for local repo artifacts.
I have setup a Dynamic Web Project in Eclipse using Maven. The Web Project has a lot of dependencies to other JARs. The JARs are properly added to the WEB-INF/lib folder in Maven/Eclipse. Many of the JARs though are results of other plain Java projects. I want to have the JARs represented by their resepective Java projects in Eclipse from time to time (but not for all of them).
So how do I quickly replace a normal Maven Dependency JAR by its Eclipse project?
Currently I:
Remove the Maven Dependency (Right click on the JAR, Maven -> Exlude Maven Artifact)
Edit the Build path and add the corresponding Eclipse project
Mark the project also in the "Export and Order" section of the Build path
Edit the Deployment Assembly properties and add the Eclipse project there as well (so it goes into WEB-INF/lib at runtime).
If your web projects is a maven project (little "m" in the upper left corner) and you have installed the M2E-WTP plugin (included in the Keplar JavaEE package), this will happen automatically, i.e. when the dependent project is open in the workspace, it will be a project link, if it is closed, your web project will use the jar file as dependency.
If you are using M2Eclipse, I gess you should enable Workspace resolution.
Both projects should be maven projects.
If you're using mvn eclipse plugin, make sure, they both have a pom.xml and call :
mvn eclipse:clean eclipse:eclipse
I've got project with a few sub modules.
mvn clean install
works absolutely fine. But in Eclipse with the parent project open none of the maven dependencies are available and so all my Java source files are full of indicated compilation errors (they're not listed in the build path for the project). If I open one of the sub modules as a project there are no indicated compilation problems.
I've tried running
mvn clean install eclipse:clean eclipse:m2eclipsemvn clean install eclipse:clean eclipse:m2eclipse
and choosing project / update maven dependencies. Refreshing, closing and opening the project and Eclipse, etc.
Any ideas? Thanks in advance.
Getting m2eclipse to match maven's classpath
Just use Import... > Existing Maven Projects and import your multi-modules Maven project, that's all.
But in Eclipse with the parent project open none of the maven dependencies are available and so all my Java source files are full of indicated compilation errors (they're not listed in the build path for the project).
A parent project (i.e. with a pom packaging) is not a Java project, it's just there as a facility to make editing the parent pom.xml from the IDE possible (and that's already nice, importing nested projects inside Eclipse was initially not even possible).
If I open one of the sub modules as a project there are no indicated compilation problems.
That's how you are supposed to do things.
I've tried running (...)
You are not supposed to use the Maven Eclipse Plugin when using m2eclipse and this is not supported. Either use one or the other. If you decide to use m2eclipse, use Import... > Existing Maven Projects as suggested.