Files
sdkman-cli/build.gradle
2019-11-22 14:40:42 +00:00

126 lines
3.1 KiB
Groovy

import org.apache.tools.ant.filters.*
buildscript {
repositories {
jcenter()
}
}
plugins {
id "com.jfrog.bintray" version "1.7"
}
apply plugin: 'groovy'
def userHome = System.getProperty('user.home')
ext.installBinDir = "${userHome}/.sdkman/bin"
ext.installSrcDir = "${userHome}/.sdkman/src"
def loadConfiguration() {
def environment = hasProperty('env') ? env : 'local'
ext.environment = environment
println "Environment is set to: $environment"
def configFile = file('config.groovy')
def config = new ConfigSlurper(environment).parse(configFile.toURL())
ext.config = config
}
loadConfiguration()
ext.buildNumber = System.getenv("TRAVIS_BUILD_NUMBER") ?: '0'
ext.sdkmanCliBuildVersion = "${config.sdkmanCliVersion}+${buildNumber}".toString()
repositories {
jcenter()
}
dependencies {
compile 'org.codehaus.groovy:groovy:2.4.17'
compile 'org.codehaus.groovy:groovy-templates:2.4.17'
compile 'org.codehaus.groovy:groovy-json:2.4.17'
testCompile 'junit:junit:4.12'
testCompile 'io.cucumber:cucumber-groovy:4.7.1'
testCompile 'io.cucumber:cucumber-junit:4.7.1'
testCompile 'io.cucumber:gherkin:5.1.0'
testCompile('org.spockframework:spock-core:1.3-groovy-2.4') {
exclude module: 'groovy-all'
}
testCompile('com.github.tomakehurst:wiremock:2.25.1') {
exclude module: 'junit'
}
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.29'
testCompile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.29'
}
test.testLogging.exceptionFormat = 'full'
task prepareScripts(type: Copy) {
from 'src/main/bash'
into 'build/scripts'
include '**/*'
filter(ReplaceTokens, tokens:
[
SDKMAN_VERSION: sdkmanCliBuildVersion,
SDKMAN_CANDIDATES_API: config.candidatesApi
]
)
}
test.dependsOn prepareScripts
task assembleArchive(type: Zip, dependsOn: prepareScripts) {
appendix = "cli"
version = sdkmanCliBuildVersion
from "build/scripts"
include "*.sh*"
}
assemble.dependsOn assembleArchive
task cleanInstallInit(type: Delete) {
delete installBinDir
}
task cleanInstallModules(type: Delete) {
delete installSrcDir
}
task installInit(type: Copy, dependsOn: [cleanInstallInit, prepareScripts]) {
from "build/scripts"
into installBinDir
include "sdkman-init.sh"
}
task installModules(type: Copy, dependsOn: [cleanInstallModules, prepareScripts]) {
from "build/scripts"
into installSrcDir
include "sdkman-*.sh"
exclude "sdkman-init.sh"
}
task install(dependsOn: [installInit, installModules])
bintray {
user = System.getenv('BINTRAY_USERNAME')
key = System.getenv('BINTRAY_API_KEY')
publish = true
filesSpec {
from 'build/distributions'
into '.'
}
pkg {
repo = 'generic'
name = 'sdkman-cli'
userOrg = 'sdkman'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/sdkman/sdkman-cli.git'
version {
name = sdkmanCliBuildVersion
desc = 'Binary zip distribution of SDKMAN bash client.'
released = new Date()
}
}
}