Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Maven artifact with sources from command line?

How to install Maven artifact with sources?

so later I don't need to open a project in eclipse to see some code.

EDIT: I do know I can add to pom.xml this code

<plugin>         <artifactId>maven-source-plugin</artifactId>         <executions>                 <execution>                         <id>attach-sources</id>                         <phase>verify</phase>                         <goals>                                 <goal>jar</goal>                         </goals>                 </execution>         </executions> </plugin> 

but I would like to do it from command line(to make it more universal).

like image 420
IAdapter Avatar asked Feb 24 '11 09:02

IAdapter


People also ask

How do I download sources with Maven?

To download sources for dependencies of maven project, right click on project → Maven → Download Sources . Similarly to download JavaDoc for dependencies of maven project, right click on project → Maven → Download JavaDoc .

How do I download artifacts from Maven repository?

Download Jar From maven.org. There is another maven repository that you can download jar files from. Open a web browser and browse the URL maven.org or search.maven.org. Input the jar library group name or artifact name in the search box, it will list all matched jar libraries.

How do I download specific dependencies in Maven?

You can use the Maven Dependency Plugin to download dependencies. Run mvn dependency:copy-dependencies , to download all your dependencies and save them in the target/dependency folder. You can change the target location by setting the property outputDirectory .


2 Answers

To download sources for your dependencies:

mvn eclipse:eclipse -DdownloadSources=true 

To attach sources to an installation:

mvn source:jar install 

It's also preferable to use the goal source:jar-no-fork in your pom as described on the maven-source-plugin page.

like image 91
dogbane Avatar answered Oct 30 '22 19:10

dogbane


Simple, get your sources and JavaDocs:

mvn dependency:resolve -Dclassifier=javadoc mvn dependency:resolve -Dclassifier=sources 
like image 43
Joseph Lust Avatar answered Oct 30 '22 21:10

Joseph Lust