Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

/**********
* Per Gradle requirements, this section MUST appear:
* 1. In the main project's build.gradle
* 2. Before any other directives, except buildscript
* This pulls _Gradle_ plugins
**********/
plugins {
/***********
* Facilitates SSH/SCP capabilities (see common.gradle tasks)
***********/
id 'org.hidetake.ssh' version '1.1.4'
}

Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication ("${nexusUser}", "${nexusPass}" as char[])
}
});

/**********
* This pulls in the common gradle script from:
* * A local path, if localCommons has a value OR
* * From Nexus, leveraging common* properties and getLatestCommonsVersion.
* The gradle file is applied directly to the running Gradle process
* and thus never needs to be downloaded to the local repo
**********/
if(System.env.LOCAL_COMMONS){
println "Using local commons: \033[1m${System.env.LOCAL_COMMONS}/common.gradle\033[0m"
apply from: "${System.env.LOCAL_COMMONS}/common.gradle"
}
else {
println "Using Commons version from Nexus: \033[1m${getLatestCommonsVersion()}\033[0m"
apply from: "${nexusDownload}?r=${commonsBaseRepo}-${repoTypeFromVersion(commonsVersion)}&g=${commonsGroupId}&a=${commonsArtifactId}&v=${URLEncoder.encode(getLatestCommonsVersion(), 'UTF-8')}&p=${commonsExtension}"
}

/***********
* Functions for establishing which common gradle script to download from Nexus
***********/

/***********
* Determine if the passed-in artifact is a snapshot
* (By checking if it ends with SNAPSHOT)
***********/
def isSnapshot(version){
def pattern = ~/.*SNAPSHOT/
return pattern.matcher(version).matches()
}
/***********
* Determine the repository type based on the version value
***********/
def repoTypeFromVersion(version) {
if (isSnapshot(version)) {
return "snapshots"
}
else {
return "releases"
}
}
/***********
* Query Nexus to determine the latest version of the common gradle script
***********/
def getLatestCommonsVersion() {
def repo = "${commonsBaseRepo}-${repoTypeFromVersion(commonsVersion)}"
def xml = "${nexusSearch}?r=${repo}&g=${commonsGroupId}&a=${commonsArtifactId}&v=${commonsVersion}*".toURL().text;
def metadata = new XmlSlurper().parseText(xml);
// Find the first returned element whose repository matches the requested artifact's repo type (snapshots or releases)
// (this will be the latest artifact matching the pattern, in the appropriate repository)
def artifactXml = metadata.data.depthFirst().find { node -> node.artifactHits.artifactHit.repositoryId.text() == repo }
return artifactXml.version.text();
}


/***********
* Project-specific tasks and configurations
***********/
gruntBuild {
if (isReleaseBranch()) {
commandLine 'grunt', 'build:dist', "--buildForDoD=${buildForDoD ?: "false"}"
} else if (System.getProperty("fastBuild") == "true") {
commandLine 'grunt', 'build:fastdev', "--buildForDoD=${buildForDoD ?: "false"}"
} else {
commandLine 'grunt', 'build:dev', "--buildForDoD=${buildForDoD ?: "false"}"
}
}

task runKarmaTests(type: Exec) {
commandLine 'grunt', 'test'
}

war {
dependsOn gruntBuild
from appDirName
manifest {
attributes("Commons-Version": getLatestCommonsVersion())
attributes("Implementation-Title": project.name)
from baseManifest
}
}

/***********
* Nexus repo to which artifacts will be published.
* Repo is computed at runtime
***********/
publishing {
publications {
maven(MavenPublication) {
from components.web
artifactId 'mytelederm'
pom.withXml {
asNode().appendNode('description', "${archivesBaseName}-${version} (From Jenkins build ${buildNumber}, using Git revision ${gitHash})")
}
}
}
}