Eclipse project and maven dependency - java

I have the project in eclipse with static folder (lib). This folder contains a lot of libraries, also build process of this project based on the maven. Can I automate import(using eclipse maven plugin) all libraries for lib folder to the maven dependencies or I should do it manually?
Thanks.

Can I automate import (using eclipse maven plugin) all libraries for lib folder to the maven dependencies or I should do it manually?
To strictly answer your question, there is no automated tool, although you could maybe script something in the spirit of Finding the right version of the right JAR in a maven repository.
And see Maven, how to add additional libs not available in repo for the various possibilities to deal with your JARs.

Related

Use Maven Library without Drinking Maven Koolaid

I want to use the diffplug/Durian library, but do not want to use Maven. Is there a way to use a Maven library without using Maven itself in a project?
This has a link to the .jar and lists it's dependencies.
http://mvnrepository.com/artifact/com.diffplug.durian/durian/3.4.0
Download the jar - then all the jar's dependencies and their dependencies and add them to the class path.
I found that IntelliJ IDEA allows for exporting of a Maven module to a JAR, that can be used in non-Maven projects.
https://www.jetbrains.com/help/idea/2016.1/downloading-libraries-from-maven-repositories.html
And needed to know what a "Maven Coordinate" was. I found it for the library in question at https://mvnrepository.com/artifact/com.diffplug.durian/durian/3.4.0, and it is the string "com.diffplug.durian:durian:3.4.0".
Basically, follow Project Structure->Project Settings->Libraries->"+"->New Project Library->From Maven. The resultant dialog takes a Maven coordinate, and has a "Download To" option, that will make a nice JAR at the specified location, from the Maven library you import. Can add source and javadocs as well. After doing the download, you navigate to the system folder containing the new JAR, and stick it in your real non-Maven project (an Eclipse project, in my case).

What is the right way to export a jar using maven for a library project?

I have a library project which is built in maven. It has its dependencies. I need to export this project as a jar (Not a runnable jar). Should I include the dependencies along with my jar or should I not? Because when I exported the dependencies with my jar, there were conflicts when the same jars of different versions were used for projects that added this project as a dependency. But if I don't export with the dependencies, at run time this library project throws NoClassDefFound errors for its dependencies. So what is the right way to do this? If I don't export the dependencies with my jar, is there a way that the project using this library project could download those jars for the library project? If that is how I would do it, then wouldn't it mean that the project using this project must be using maven too? It won't be a good practice as whoever uses this library should be able to use whatever the build tools they want. I am pretty new to maven. Please advice.
It is largely to taste, some open source projects do both, providing with for and without so that it is easier to use in larger projects.
If you are using Maven for your other projects you can, when you declare a dependency on this library tell maven to exclude some of its component jars.

Include a Netbeans Maven project in a Netbeans Ant project

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.

How to install a maven build project?

I want to install the following plugin:
https://github.com/AgileReview-Project/AgileReview-EclipsePlugin
Its a maven project. I already successfully build the plugin with maven. Now, I want to install it.
How can I install it? When I build the file with Maven, no Jar file was created that I can use for installation.
pom is container of sub-modules, I see a lot of sub-directories in the project.
Somewhere, nested within the project structure you will find artifacts (modules) with jar packaging. Maven generally builds everything into /target subdirectories of each module. So after mvn install look into target subdirectory in a module with jar packaging.
The link you have (https://github.com/AgileReview-Project/AgileReview-EclipsePlugin) is the actual work code project of the plugin. (It is only interesting for the people working on the plugin or others who want to change/improve it).
According to AgileReview website, you'll have to simply do the old-way plugin installation. All the steps and infos are here

How to quickly replace a Maven Dependency with an Eclipse project?

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

Categories