Maven dependencies in external jar files not loading - java

I'm having a spring based project which does not have any build management tools like maven/gradle. For dependencies I'm adding the jar files to the build path. Some dependencies like aws-java-sdk and others having only pom.xml files in their jar files. These additional dependencies for the jar files are not getting downloaded from maven central repo. Is there any additional configuration need to be done for this?

For dependency resolution, you need a build tool.
The standard tools nowadays are Maven or Gradle.

Related

Difference between plugins and dependency in maven tool (unpack jar)

I'm new to the maven tool, below is what I have understood about plugins and dependency:
Plugin is a Jar file which executes the task, and dependency is a Jar which provides the class files to execute the task.
What is the difference in maven between dependency and plugin tags in pom xml?
When I define something in the dependency tag, nothing is downloaded to my target folder. Whereas the same thing defined in the plugin tag downloads it in the target folder. Why plugin unpacks the jar file?
Update:
Plugins were unpacked as it was defined in the goal of the plugin.
Plugins and dependencies are completely different things.
Plugins are used by Maven during the build. They form the different parts of the build.
Dependencies are artifacts that should be used by the Java program you create in your build.
So you e.g. need the Maven compiler plugin to compile the code, but add guava as a dependency if your application wants to use guava.
When i define something in dependency tag, nothing is downloaded to my
target folder.
Exactly, all dependencies are placed into $USER_HOME/.m2/repository. They can be used by other mvn projects.
Whereas same thing defined in plugin tag downloads it in target folder. Why > plugin unpacks the jar file?
Can you share your pom.xml? It may depend on your configuration.

Download jar with dependencies using Maven

I would like to use Maven to download a "fat" jar- one that includes all of its dependencies. (The same sort of jar that is built using the jar-with-dependencies descriptor Ref in the maven-assembly-plugin)
The default behavior of mvn dependency:copy is to download the jar and all of its dependencies in separate files. This is not what I want. I want the dependencies to be included in the jar itself.
How do I achieve this using Maven? If it's not possible, is there some sort of manual way of assembling the fat jar myself given all its dependency JARs?

What are the differences between Maven Jar Plugin and Maven Assembly Plugin?

Could somebody explain me the exactly differences between these two Maven plugins and when it is useful to work with one of these plugins?
Maven jar plugin simply creates a jar files with all SOURCE files [.class files compiled from .java files] packed in it. However, a jar itself cannot be deployed as it generally has dependencies on 3rd party jar files or other library jar files which are needed to execute SOURCE jar file.
This is where Maven assembly plugin comes into picture. It creates a package of an extension of your choice like .zip, .tar, .gz which is a fully deployable package with all dependencies packed in it. You can also specify directory structure in assembly plugin which should be created when package is deployed on server.
So a assembly plugin is always used in combination with jar plugin.
Maven Jar plugin provides the capability to build and sign jars.The plugin use Maven Archiver to handle jar content and manifest configuration.
Maven Assembly Plugin is used to create all assemblies.
For More Info visit- http://maven.apache.org/plugins/maven-jar-plugin/
http://maven.apache.org/plugins/maven-assembly-plugin/

Build the pom file to download the dependencies with eclipse

I download a j2ee project with a pom file which mention the dependency jar files needed. I want to know to run this pom file and download the jars need for my project? I right click and ran the pom file as maven build. Then it prompt me the Edit and Configuration UI which has the goals and profiles.
What are the values that i need to specify here?
Also is there any special configuration i need to add to eclipse (helios)?
How does the necessary jar files downloaded? Is it from the xsi:schemaLocation location specify in the pom file?
You can use these maven goals for that.
eclipse:eclipse - Download the dependency jars and set them to the classpath(you need to configure your settings.xml in the maven with the maven archiva repo path for maven to download jars from there)
install - build the project and install it in the local repo.
Have a look at this answer for the whole list of goals.
IF you install the Maven to Eclipse integration plugin (m2e), Eclipse will automagically add the project dependencies to the project's build path, and download them in the process.

Eclipse project and maven dependency

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.

Categories