Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dineshr93/bf62bb4b5c6e8c3f29e74a078c39f4af to your computer and use it in GitHub Desktop.
Save dineshr93/bf62bb4b5c6e8c3f29e74a078c39f4af to your computer and use it in GitHub Desktop.
Simplification of Generating & Tracking of maven dependencies.
Prerequisite: 1. Make sure you have set your user name and password in the settings.xml (check in Resource folder included in package)in (C:\Users\Dinesh\.m2). (if <localRepository> tag is present, then it is the path of local repo. )
Prerequisite: 2. Take only the projects pom.xml file.
1. Create a folder and put the POM.xml file in it.
2. Open command prompt and cd(change directory) to that folder which contains POM.xml file.
3. First to get the binaries use below command.
mvn dependency:copy-dependencies -DoutputDirectory=\your directory\
3.1. Build may get Failure due to some dependencies may not be available in the public repository.
3.2. Hence for dealing such case, Note down the missing dependencies from the command prompt and we have to get the source manually from the desired source.
3.3. Alter the POM file to point it to all that downloaded dependency files.
We must include 2 additional tag under that each missing dependency.
<scope>system</scope>
<systemPath>Path to that missing jar file (ex: project-1.0.0.jar)</systemPath>
So download manually into the system and alter the POM with scope and systempath tags to point it to the file. So the Pom file now becomes.
3.4. Now re-run the above command now the Build should get successful.
4. To get the Source add “–Dclassifier=sources” along with the above command.
5. Bonus: Even we can able to find the dependencies and transitive dependencies easily in a tree structure. i.e We can able to see which jar came from which library using below command.
mvn dependency:tree (removes repeated jars)or
mvn dependency:tree –Dverbose (shows repeated jars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment