Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it possible to download source code using maven?

 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope there should be one way to get the source using maven.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you mean the source code for your dependencies. If the dependency source is deployed to the remote repository, you can get it using the Dependency plugin, specifying that you want the "source" classifers, like this:

mvn dependency:copy-dependencies -Dclassifier=source -Dmdep.failOnMissingClassifierArtifact=false

The sources will be in target/dependency.


 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter, Thanks for your reply but I mean source code is a jar file used to attach to eclipse source code. To know how a particular class is implemented.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You never mentioned Eclipse in your original question, so how was I supposed to know? This makes your question one about Eclipse, so I am moving your post.

If you are using m2eclipse, and you have a Maven project, m2eclipse automatically downloads and attaches source JAR files. (Check you project's Build Path, under the Libraries tab expand Maven Dependecnies and then look under each JAR, many of them should have Source Attachment entries - see the attached image.) Of course, the source JARs must be available in the repository for this to work automatically. If there is no source JAR, you can always select Source Attachment, click the Edit button, and then browse to the source location (which you will have to provide yourself).
sourcesjars.png
[Thumbnail for sourcesjars.png]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic