[email protected]

Gradle Small Hints #2 - Deploy and Integrate Maven Artifacts on Github

The following steps are necessary to deploy and integrate artifacts in a Maven repository hosted on Github:

Assumption is that you have a clb_mvnrepo Github repository which manages your Maven Repository in a releases and snapshots branch.

Build and Deploy

Clone the snapshots and releases branches of your Maven Repository to the local machine. You will publish the artifacts of your project which you build into this target directory.

  git clone -b releases  https://github.com/talfco/clb_mvnrepo.git clb_mvnrepo_releases 
  git clone -b snapshots https://github.com/talfco/clb_mvnrepo.git clb_mvnrepo_snapshots 

In the build.gradle File of your project add the following entries:

At the top of the file add the maven publish plugin

  apply plugin: 'groovy' 
  apply plugin: 'maven-publish' 

Additionally add the publishing configuration which points to your local Maven repository clone to your build.gradle

  publishing { 
    publications { 
      maven(MavenPublication) { 
        groupId "com.cloudburo" 
        artifactId 'clb-gradleTask' 
        version '1.0.1-SNAPSHOT' 
        from components.java 
    repositories { 
      maven { url "/Users/Felix/Development/workspace-grails/clb_mvnrepo_snapshots"} 

Depending on the version number of 1.1.0 or 1.1.0-SNAPSHOT configure the publishing configuration for the releases or snapshots local GIT clone directory.

The gradle publish command will build your project and deploy it to your clb_mvnrepo directory.

Having published it into your publish directory, commit and push via the git commands to your Github snapshot/release directory.

Integrate Released Artifacts

You can now reference the released libraries via the following gradle configuration, assuming you released clb-gradleTask library

  repositories { 
    maven { url 'https://github.com/talfco/clb_mvnrepo/raw/snapshots' } 
  dependencies { 
    classpath group : 'com.cloudburo' , name : 'clb-gradleTask' , version : ‚1.0.1-SNAPSHOT' } 

comments powered by Disqus