andromedarabbit
9/21/2015 - 12:56 PM

Example gradle build to upload a Spring Boot based jar to nexus

Example gradle build to upload a Spring Boot based jar to nexus

group = "foo"

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.8.RELEASE")
    }
}

apply plugin: "java"
apply plugin: "maven"
apply plugin: "spring-boot"

sourceCompatibility = 1.8
targetCompatibility = 1.8

jar {
    baseName = "bar"
    version = "0.1.0-SNAPSHOT"
}

configurations {
    deployerJars
}

repositories {
    mavenCentral()
}

dependencies {

    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-actuator")

    testCompile("org.springframework.boot:spring-boot-starter-test")

    deployerJars("org.apache.maven.wagon:wagon-http:2.7")
}



uploadArchives {
    repositories {
        mavenDeployer {
            configuration = configurations.deployerJars

            repository(url: "https://nexushost/content/repositories/releases") {
                authentication(
                        userName: "user",
                        password: "password"
                )
            }

            snapshotRepository(url: "https://nexushost/content/repositories/snapshots") {
                authentication(
                        userName: "user",
                        password: "password",
                )
            }

            pom {
                groupId = project.group
                artifactId = jar.baseName
                version = jar.version
                project {
                    parent {
                        groupId "org.springframework.boot"
                        artifactId "spring-boot-starter-parent"
                        version "1.1.8.RELEASE"
                    }
                }
            }
        }
    }
}