{"id":53,"date":"2012-02-15T00:45:42","date_gmt":"2012-02-14T23:45:42","guid":{"rendered":"http:\/\/www.flamingpenguin.co.uk\/blog\/?p=53"},"modified":"2012-02-15T00:45:42","modified_gmt":"2012-02-14T23:45:42","slug":"github-maven-plugins","status":"publish","type":"post","link":"https:\/\/www.flamingpenguin.co.uk\/blog\/2012\/02\/15\/github-maven-plugins\/","title":{"rendered":"Github Maven Plugins"},"content":{"rendered":"<p>Anyone hosting projects built with maven on Github will probably be interested in the <a href=\"https:\/\/github.com\/github\/maven-plugins\" title=\"Github Maven Plugins\">Github Maven plugins<\/a><\/p>\n<p>At the moment there are two plugins, one for uploading artifacts to the download section of your Github project, and another for uploading your maven site to the <a href=\"http:\/\/pages.github.com\/\" title=\"Github Pages\">gh-pages branch<\/a> of your repository.<\/p>\n<p>You need to put something like this, or a bit cleverer, in your maven settings.xml:<\/p>\n<pre lang=\"xml\">\r\n<profiles>\r\n    <profile>\r\n      <id>github-properties<\/id>\r\n      <properties>\r\n        <github.global.userName>myusername<\/github.global.userName>\r\n        <github.global.password>mypassword<\/github.global.password>\r\n      <\/properties>\r\n    <\/profile>\r\n  <\/profiles>\r\n  <activeProfiles>\r\n    <activeProfile>github-properties<\/activeProfile>\r\n  <\/activeProfiles>\r\n<\/pre>\n<h3>site plugin<\/h3>\n<p>Then configure the plugins in your project. For the site plugin you need something like this, which will upload to github each tiem you run the site goal in maven.<\/p>\n<pre lang=\"xml\">\r\n<build>\r\n   <plugins>\r\n      <plugin>\r\n         <groupId>com.github.github<\/groupId>\r\n         <artifactId>site-maven-plugin<\/artifactId>\r\n         <version>0.5<\/version>\r\n         <executions>\r\n            <execution>\r\n               <goals>\r\n                  <goal>site<\/goal>\r\n               <\/goals>\r\n               <phase>site<\/phase>\r\n               <configuration>\r\n                  <message>Creating site for ${project.version}<\/message>\r\n               <\/configuration>\r\n            <\/execution>\r\n         <\/executions>\r\n      <\/plugin>\r\n<\/pre>\n<h3>multi-module projects<\/h3>\n<p>I&#8217;m not clear on how the multi-module support is supposed to work. The way I have got it to work is by using `path` and `merge` in the modules:<\/p>\n<pre lang=\"xml\">\r\n<configuration>\r\n    <path>modulename<\/path>\r\n    <merge>true<\/merge>\r\n    ...\r\n<\/configuration>\r\n<\/pre>\n<p>my theory is that if you build `site` in your parent project, then it will be uploaded first, clearing the whole site. Then each of the sub modules will be built merging each site into the parent site in the correct subdirectory. This seems to work, but the top level project run with `merge=false` wipes out you site for a while until the child modules complete. So if your project takes a while to build (or fails!) visitors might get disappointed. The only alternative to this seems to be to have `merge=true` on all the projects, but that will leave anything that doesn&#8217;t get overwritten unaffected. YMMV.<\/p>\n<h3>download plugin<\/h3>\n<p>You can have each of your releases uploaded to github for other people to download. I use a profile to only sign and upload my release builds and not every snapshot.<\/p>\n<pre lang=\"xml\">\r\n<profile>\r\n    <id>release-sign-artifacts<\/id>\r\n    <activation>\r\n        <property>\r\n            <name>performRelease<\/name>\r\n            <value>true<\/value>\r\n        <\/property>\r\n    <\/activation>\r\n    <build>\r\n        <plugins>\r\n            <plugin>\r\n                <groupId>org.apache.maven.plugins<\/groupId>\r\n                <artifactId>maven-gpg-plugin<\/artifactId>\r\n                <version>1.4<\/version>\r\n                <executions>\r\n                    <execution>\r\n                        <id>sign-artifacts<\/id>\r\n                        <phase>verify<\/phase>\r\n                        <goals>\r\n                            <goal>sign<\/goal>\r\n                        <\/goals>\r\n                    <\/execution>\r\n                <\/executions>\r\n            <\/plugin>\r\n            <plugin>\r\n               <groupId>com.github.github<\/groupId>\r\n               <artifactId>downloads-maven-plugin<\/artifactId>\r\n               <version>0.4<\/version>\r\n               <executions>\r\n                  <execution>\r\n                     <goals>\r\n                        <goal>upload<\/goal>\r\n                     <\/goals>\r\n                     <phase>install<\/phase>\r\n                     <configuration>\r\n                        <description>${project.version} release of ${project.name}<\/       description>\r\n                        <override>true<\/override>\r\n                        <includeAttached>true<\/includeAttached>\r\n                     <\/configuration>\r\n                  <\/execution>\r\n               <\/executions>\r\n           <\/plugin>\r\n        <\/plugins>\r\n    <\/build>\r\n<\/profile>\r\n<\/pre>\n<p>The more I use maven and github for Open Source development the better it gets, and this github integration is super-smooth. I have pretty much single click global publishing of my whole project source, documentation and artifacts. Combined with the super easy and free nexus and maven central access provided by <a href=\"https:\/\/docs.sonatype.org\/display\/Repository\/Sonatype+OSS+Maven+Repository+Usage+Guide\" title=\"sonatype oss\">sonatype OSS<\/a> and the <a href=\"http:\/\/www.cloudbees.com\/\" title=\"cloudbees\">jenkins CI server instance provied by cloudbees<\/a> this is as close to as good a dev environment as you can get &#8211; and all for no money. Oh yeah, and I forgot about the <a href=\"http:\/\/eclipse.org\/m2e\/\" title=\"maven eclipse\">eclipse maven integration<\/a>. We&#8217;ve come along way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Anyone hosting projects built with maven on Github will probably be interested in the Github Maven plugins At the moment there are two plugins, one for uploading artifacts to the download section of your Github project, and another for uploading &hellip; <a href=\"https:\/\/www.flamingpenguin.co.uk\/blog\/2012\/02\/15\/github-maven-plugins\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,7],"tags":[],"class_list":["post-53","post","type-post","status-publish","format-standard","hentry","category-continuous-integration","category-java"],"_links":{"self":[{"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/posts\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":0,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/posts\/53\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}