{"id":1119,"date":"2010-07-27T09:18:39","date_gmt":"2010-07-27T14:18:39","guid":{"rendered":"http:\/\/www.andygibson.net\/blog\/?p=1119"},"modified":"2010-11-12T16:45:05","modified_gmt":"2010-11-12T21:45:05","slug":"installing-libraries-into-maven-from-source","status":"publish","type":"post","link":"https:\/\/www.andygibson.net\/blog\/tutorial\/installing-libraries-into-maven-from-source\/","title":{"rendered":"Installing libraries into Maven from source"},"content":{"rendered":"<p>This article describes how to install artifacts into Maven from the source code. To start with you should have installed Maven and downloaded the source code you want to install.  This same mechanism can be used for library jar files to archetypes that you want to install.<!--more--><\/p>\n<ol>\n<li>Open a command prompt and navigate to the directory where the Maven source code is. This is usually indicated by the presence of a <code>pom.xml<\/code> file in that directory.\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\n&gt; cd dev\\projects\\myproject\r\n\r\n<\/pre>\n<\/li>\n<li>Once in the maven project folder, there are a number of different commands you can use to install the project depending on what you need. The simplest form will compile, test, and install the artifacts into Maven.\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\n&gt;mvn install\r\n\r\n<\/pre>\n<\/li>\n<\/ol>\n<p>In some cases, you want to install the source and java doc files as well as the main jar file. This can be done by adding it onto the command line.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\n&gt;mvn javadoc:jar source:jar install\r\n\r\n<\/pre>\n<p>There may be times you want to make sure your build is completely clean before you start.  You can do this by adding the <code>clean<\/code> target onto the command. This deletes any current compiled sources so they will be regenerated from scratch. <\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\n&gt;mvn clean javadoc:jar source:jar install\r\n\r\n<\/pre>\n<p>While we added it at the start of the command, you don&#8217;t need to, you can put it at the end and it will still be executed first.<\/p>\n<h2>Skipping Tests<\/h2>\n<p>If you need to skip tests, you can do so by setting a command line parameter on the command line depending on how you want to skip the tests. While skipping tests is not advised, there are many cases where you might need to do so.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n-Dmaven.test.skip=true\r\n<\/pre>\n<p>This will skip the compilation and execution of the tests.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n-DskipTests=true\r\n<\/pre>\n<p>This will compile the tests, but skip the execution of them.<\/p>\n<p>See <a href=\"http:\/\/maven.apache.org\/plugins\/maven-surefire-plugin\/examples\/skipping-test.html\"> here<\/a> for more information on controlling test skipping in the <code>pom.xml<\/code> file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article describes how to install artifacts into Maven from the source code. To start with you should have installed Maven and downloaded the source code you want to install. This same mechanism can be used for library jar files to archetypes that you want to install.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[64],"tags":[65,35],"_links":{"self":[{"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/posts\/1119"}],"collection":[{"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/comments?post=1119"}],"version-history":[{"count":4,"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/posts\/1119\/revisions"}],"predecessor-version":[{"id":1649,"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/posts\/1119\/revisions\/1649"}],"wp:attachment":[{"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/media?parent=1119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/categories?post=1119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.andygibson.net\/blog\/wp-json\/wp\/v2\/tags?post=1119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}