Gradle - Nexus

About

Calling nexus from Gradle

Management

Configuration

Gradle - Maven plugin

plugins {
    id 'maven'
}

Download

Gradle has a built in dependency management component that supports the Maven repository format.

  • The below definition allows Gradle to download the public dependencies
repositories {
    maven {
        url "http://localhost:8081/repository/maven-public/"
    }
}

Upload

UploadArchives

With the uploadArchives

Steps:

nexusUrl=http://localhost:8081/nexus
nexusUsername=admin
nexusPassword=admin123
  • UploadArchive definition
uploadArchives {
  repositories {
    mavenDeployer {
      repository(url: "${nexusUrl}/content/repositories/releases") {
          authentication(userName: nexusUsername, password: nexusPassword)
      }
      snapshotRepository(url: "${nexusUrl}/content/repositories/snapshots") {
          authentication(userName: nexusUsername, password: nexusPassword)
      }
    }
  }
}
  • Then upload
cd projectRoot
gradle upload

UploadShadow (Fat jar)

See Doc

Example with maven

uploadShadow {
  repositories {
    mavenDeployer {
      repository(url: "${nexusUrl}/content/repositories/snapshots") {
          authentication(userName: nexusUsername, password: nexusPassword)
    }
  }
}

Example

https://github.com/sonatype/nexus-book-examples/tree/master/gradle

Documentation / Reference







Share this page:
Follow us:
Task Runner