Skip to content

Instantly share code, notes, and snippets.

@datherra
Created December 7, 2015 06:47
Show Gist options
  • Save datherra/082ecc1633d8a1b273d7 to your computer and use it in GitHub Desktop.
Save datherra/082ecc1633d8a1b273d7 to your computer and use it in GitHub Desktop.
Gradle Download file / dependencies outside of repos
ext {
wlsInstaller = 'wls1036_dev.zip'
wlsInstallerSourceUrl = "http://mysever/content/com/oracle/weblogic/wls/10.3.6/${wlsInstaller}"
localEnvDir = "${projectDir}/.local"
wlsInstallerDestPath = "${localEnvDir}/${wlsInstaller}"
wlsHome = "${localEnvDir}/wls1036_dev/"
}
def download(String remoteUrl, String localUrl) {
def localFile = new FileOutputStream(localUrl)
def out = new BufferedOutputStream(localFile)
out << new URL(remoteUrl).openStream()
out.close()
}
task downloadWebLogic {
description 'Fetches WLS Dev edition from HTTP Server'
outputs.file wlsInstallerDestPath // skip task if up-to-date
doLast {
file(localEnvDir).mkdir()
download(wlsInstallerSourceUrl, wlsInstallerDestPath)
}
}
task extractWeblogic(type: Copy, dependsOn: downloadWebLogic) {
description 'Unpacks previously downloaded WLS Dev edition'
from zipTree(wlsInstallerDestPath)
into wlsHome
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment