This document discusses lightweight developer provisioning using Gradle. It describes how Gradle tasks and Groovy can be used to automate the creation and updating of a software development environment (SEU). Dependencies are expressed as Gradle configurations and stored in an artifact repository. The document provides examples of customizing an SEU by mounting network drives, initializing databases, and restoring Solr indexes using Gradle tasks. It also outlines how to easily build software package files and publish them to a repository.
4. Software Industrialization
/> Automation of repetitive and laborious tasks
/> Better software quality through standardized, streamlined tooling
/> Well integrated tool chain leads to a higher productivity of your team
/> Better cost efficiency and competitiveness
4
… Dev Test …
7. So what are the problems?
/> Individual SEUs produce different results and strange bugs
/> The SEU of a new project is often a copy of a previous project
/> Older versions of a SEU can not easily be restored
/> Manual and error prone update procedure of individual SEUs
/> Batch files. No good IDE support for shell scripting
7
8. The solution ...
/> Use a build tool for the automated creation and update of a SEU
/> Gradle tasks and Groovy are used for all required shell scripting
/> Everything is version controlled just like „normal" source code
/> Required software packages are expressed as dependencies
/> Software packages are stored in an artifact repository like Nexus
8
11. The most minimalistic SEU gradle.build file
11
plugins {
id 'de.qaware.seu.as.code.base' version '2.2.0'
}
seuAsCode {
seuHome = 'G:'
projectName = 'Gradle Summit 2016'
}
- Specify a driver letter or directory
- Use VHD or sparse image file
$ ./gradlew bootstrapSeu
$ ./gradlew updateSeu
15. Software dependencies and their configurations
15
repositories {
maven { url 'https://dl.bintray.com/seu-as-code/maven' }
jcenter()
}
dependencies {
seuac 'org.codehaus.groovy.modules.scriptom:scriptom:1.6.0'
seuac 'com.h2database:h2:1.4.188'
home 'de.qaware.seu.as.code:seuac-home:2.0.0'
software 'de.qaware.seu.as.code:seuac-environment:2.0.0:jdk8'
software 'org.gradle:gradle:2.13'
software 'net.java:openjdk8:8u40:x86'
}
The configuration name determines the installation
directory of the software dependency.
16. Use the Git or SVN plugins to manage your sources
16
plugins {
id 'de.qaware.seu.as.code.git' version '2.2.0'
}
git {
gradle {
url 'https://github.com/lreimer/gradle.git'
directory file("$seuHome/codebase/gradle/")
branch 'HEAD'
username gitUsername
password gitPassword
}
}
$ ./gradlew gitCloneGradle
$ ./gradlew gitCloneAll
$ ./gradlew gitPullGradle
17. Use the Git or SVN plugins to manage your sources
17
plugins {
id 'de.qaware.seu.as.code.svn' version '2.2.1'
}
subversion {
docs {
url 'https://github.com/seu-as-code/seu-as-code.documentation'
directory file("$seuHome/docbase/documentation/")
username svnUsername
password svnPassword
}
}
$ ./gradlew svnCheckoutDocs
$ ./gradlew svnCheckoutAll
$ ./gradlew svnUpdateDocs
18. Secure your passwords with the Credentials plugin
18
plugins {
id 'de.qaware.seu.as.code.credentials' version '2.2.0'
}
repositories {
maven {
url 'https://your.compnay.com/nexus/repo'
credentials {
username project.credentials.get('nexusUsername')
password project.credentials.get('nexusPassword')
}
}
}
$ ./gradlew setCredentials --key nexusUsername
$ ./gradlew setCredentials --key nexusPassword
19. Easy SEU customization using plain Gradle tasks
/> Gradle build scripts are code! Be creative.
/> Gradle provides several useful predefined tasks: Copy, Exec, Sync, …
/> Gradle tasks can easily reuse Ant tasks.
/> Gradle tasks can be implemented in Groovy code.
19
SEU-as-code v1.0 has been implemented solely by using Gradle tasks!
22. Example 3: Restore Solr index data
ext.cores = ['de_DE', 'en_GB', 'zh_CN']
task solrRestoreAll(group: 'Solr') { }
cores.each { coreName ->
def name = coreName.replaceAll("_", "").capitalize()
task "solrRestore${name}"(type: Sync, group: 'Solr') {
from zipTree("$rootDir/scripts/solr/${coreName}.zip")
into "$seuHome/software/solr-4.7.2/example/solr/${coreName}"
}
solrRestoreAll.dependsOn "solrRestore${name}"
}
22
23. Building software packages is easy
/> Software packages are plain JAR files (software + customizations)
/> 44 package builds are available at Github, continuously growing
/> Currently, there are 26 packages available via the public Bintray repo
https://bintray.com/seu-as-code/maven
/> Commercial packages should be upload to private company repo
/> It only takes about 15-30 minutes!
23
24. Software packages are easily build with Gradle
24
1
Download Unpack Customize
Package Publish
2 3
4 5
25. L E T ’ S B U I L D A
G R A D L E P A C K A G E
26. Download
26
plugins {
id 'de.undercouch.download' version '1.2'
}
import de.undercouch.gradle.tasks.download.Download
task downloadArchive(type: Download) {
src 'https://services.gradle.org/distributions/gradle-2.13-all.zip'
dest "$buildDir"
}
1
Most software packages can be downloaded.
27. Unpack
27
task extractArchive(type: Copy, dependsOn: downloadArchive) {
from {
zipTree("$buildDir/${project.name}-${version}-all.zip")
}
into "$buildDir/files"
}
2
Extract downloaded archive into build directory.
29. Package
29
4
task buildPackage(type: Jar, dependsOn: extractArchive) {
baseName project.name
version version
extension 'jar'
// classifier 'x86'
destinationDir buildDir
from "$buildDir/files"
from "files"
}
Use a classifier for OS specific packages
Customization files are located here.
32. The SEU-as-code Roadmap
/> Add support for Mac OS X SEU and mixed platform SEUs
/> Continuously add more and more software packages
/> Create plugin to securely store credentials in OS X key store
/> Create plugin to build software packages even quicker
/> Write and improve documentation and user’s guide
32