Andre's Blog

20160216 How To Download Artifacts Nexus Using Gradle

[NEXUS] [GRADLE]

Put this script into a build.gradle and call gradle tasks, then you get the task copyNexus which will copy the configured tools to $buildDir/tools.

Calling the task unzipNexus will unzip the tools to ${buildDir}/unpacked.

FYI : Gradle will use the user anonymous, give it the roles it needs to be able to access the configured repositories!

apply plugin: "java"
apply plugin: 'maven'

repositories {
    maven {
        url "http://127.0.0.1:8081/nexus/content/repositories/releases"
    }
}

configurations {
    tools
}

dependencies {
    tools "group:artifact:version:specifier@zip"
}

task copyNexus(type: Copy) {
    from configurations.tools
    into "$buildDir/tools"
}

task unzipNexus(type: Copy) {

    dependsOn copyNexus

    def zipFile = file("$buildDir/tools/artifact-version-specifier.zip")
    def outputDir = file("${buildDir}/unpacked")

    from zipTree(zipFile)
    into outputDir    
}

Select where to go ...


The Blog
My Technical Blogs
Projects
Blogs Of Friends
RSS
CV/About
Me