buildscript {
repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/seu-as-code/gradle-plugins' }
}
dependencies {
classpath 'de.qaware.seu.as.code:seuac-base-plugin:2.4.0'
}
}
apply plugin: 'de.qaware.seu.as.code.base'
Plugins
Base Plugin
A Gradle plugin to create SEU installations from code. It provides basic tasks to bootstrap and update the SEU and to install and update the software packages. The SEU can be configured and customized using the seuAsCode
extension.
Basic Usage
Build script snippet for use in all Gradle versions, using the Bintray Maven repository:
Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
plugins {
id 'de.qaware.seu.as.code.base' version '2.4.0'
}
Tasks
The plugin defines the following tasks:
Task name | Depends on | Type | Description |
---|---|---|---|
|
|
- |
Initial tasks to create the SEU from scratch. |
|
|
- |
Updates a the SEU installation and applies the latest configuration. |
|
- |
DestroySeuTask |
Destroy the complete SEU and deletes all directories. So be careful! |
|
- |
CreateSeuacLayoutTask |
Creates the basic directory layout for the SEU. |
|
- |
ApplyConfigurationTask |
Apply the software configuration and install packages. New dependencies are installed, obsolete software will be removed. |
|
- |
ApplyConfigurationTask |
Apply the home configuration and install packages. New dependencies are installed, obsolete software will be removed. |
|
- |
RunHooksTask |
Runs any software hooks after the installation. |
|
- |
RunHooksTask |
Runs any home hooks after the installation. |
|
- |
CreateAsciiBannerTask |
Creates the ASCII banner file. |
|
- |
StoreSeuacDbTask |
Store the current SEU software package configuration. |
Configurations
The plugin defines the following configurations:
Task name | Description |
---|---|
|
Used for dependencies that need to be put in the root classloader, e.g. SQL drivers |
|
Used for software dependencies that will be installed in the software directory. |
|
Used for dependencies that will be installed in the home directory. |
Extra Properties
The plugin defines the following extra properties, that may be used for platform specific behavior. This functionality will soon be removed from this plugin in favor of the platform plugin.
Task name | Description |
---|---|
|
The OS family, either |
|
The OS classifier, either |
|
The OS architecture, either |
Extension
The plugin defines the following extension properties in the seuAsCode
closure:
Property name | Type | Default value | Description |
---|---|---|---|
|
String |
- |
The home directory for this SEU. Can be a VHD or any other valid directory. |
|
String |
- |
The project name for this SEU. |
|
SeuacLayout |
- |
Optional. Defines the directory layout for this SEU. |
|
SeuacDatastore |
- |
Optional. Defines the datastore used to persist the SEU configuration. Currently H2 (use jdbc:h2:seuac as URL) and MapDB (use file:mapdb:seuac as URL) are supported. |
|
SeuacBanner |
- |
Optional. Defines the ASCII banner configuration. |
Examples
Defining basic SEU properties
seuAsCode {
// these two properties are mandatory
seuHome 'S:'
projectName 'SEU-as-code'
// the other properties are optional
layout {
codebase 'S:/codebase/'
docbase 'S:/docbase/'
home 'S:/home/'
repository 'S:/repository/'
software 'S:/software/'
temp 'S:/temp/'
}
datastore {
// this is for backwards compatibility to H2 1.3.x
// for latest H2 1.4.x you can enable the MVStore
url 'jdbc:h2:./seuac;mv_store=false'
// use this URL if you want to store things with MapDB
// url 'file:mapdb:./seuac'
user 'sa'
password 'sa'
}
banner {
font 'slant'
reflection 'no'
adjustment 'center'
stretch 'yes'
width 80
}
}
Install software as dependencies
The plugin configurations are used to determine the installation directory of the software package dependencies. You have to specify a Maven repository where these dependencies are located, in this case we used Bintray and JCenter.
repositories {
jcenter()
maven { url 'https://dl.bintray.com/seu-as-code/maven' }
}
dependencies {
// dependencies for the Groovy root classloader
seuac 'org.codehaus.groovy.modules.scriptom:scriptom:1.6.0'
seuac 'com.h2database:h2:1.4.188'
// mandatory dependencies for basic SEU setup
home 'de.qaware.seu.as.code:seuac-home:2.0.0'
software 'de.qaware.seu.as.code:seuac-environment:2.0.0:jdk8'
// additional dependencies for a Groovy development environment
software 'org.gradle:gradle:2.14'
software 'org.groovy-lang:groovy:2.4.4'
}
Building platform specific SEUs
In case you want to build platform specific SEUs with a lot of differences you can use the platform closure with its nested closures for each supported platform. This functionality will soon be removed from this plugin in favor of the platform plugin.
platform {
win { // add Windows specific code like dependencies or tasks here }
mac { // add MacOS specific code like dependencies or tasks here }
unix { // add Unix or Linux specific stuff like dependencies or tasks here }
x86 { // add 32-bit specific stuff like dependencies or tasks here }
x86_64 { // add 64-bit specific code like dependencies or tasks here }
}
Credentials Plugin
A Gradle plugin for the secure storage of your credentials either using the Windows Data Protection API (DPAPI) or the Mac OS keychain mechanism. Storing any credentials in clear text in your sources or your build file is not only bad practice, it is just plain stupid since this makes it really easy for a potential attacker to access your servers and systems.
Basic Usage
Build script snippet for use in all Gradle versions, using the Bintray Maven repository:
buildscript {
repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/seu-as-code/gradle-plugins' }
}
dependencies {
classpath 'de.qaware.seu.as.code:seuac-credentials-plugin:2.4.0.RC1'
}
}
apply plugin: 'de.qaware.seu.as.code.credentials'
Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
plugins {
id 'de.qaware.seu.as.code.credentials' version '2.4.0.RC1'
}
Tasks
The plugin defines the following tasks:
Task name | Depends on | Type | Description |
---|---|---|---|
|
- |
SetCredentialsTask |
Sets the credentials for a service. Invoke with |
|
- |
DisplayCredentialsTask |
Displays the credentials for a service of a credential. Invoke with |
|
- |
ClearCredentialsTask |
Clears the credentials for a service. Invoke with |
Extra Properties
The plugin defines the following extra extension properties:
Property name | Type | Default value | Description |
---|---|---|---|
|
Credentials |
- |
Object to query credentials. Invoke the |
Extension
The plugin defines the following closures in the credentials
extension:
Property name | Type | Default value | Description |
---|---|---|---|
|
String |
|
The custom location for the MacOS keychain file to use. |
|
String |
|
The custom location of the secure properties file under Windows. |
Examples
Command line usage
First add the credentials for the Nexus
service by invoking one of the following Gradle tasks, you will be asked for the username and password on the Console:
$ ./gradlew setCredentials --service Nexus
$ ./gradlew setCredentials --service Nexus --username fooUser
You can also display and clear the credentials from the command line using the following Gradle tasks:[source,shell]
$ ./gradlew displayCredentials --service Nexus $ ./gradlew clearCredentials --service Nexus
Using credentials in a build script
Once you have set the credentials via the command line you can then use this credential information in your build script, e.g. in the repositories section,via the credentials
extra property:
repositories {
mavenCentral()
maven {
url nexusUrl
credentials {
// use array type access to credentials via service name
username project.credentials['Nexus'].username
password project.credentials['Nexus'].password
// use getter access to credentials via service name
username project.credentials.get('Nexus').username
password project.credentials.get('Nexus').password
// or use string interpolation
username "${credentials['Nexus'].username}"
password "${credentials['Nexus'].password}"
}
}
}
Custom keychain or property file location
The plugin comes with sensible default values where the credentials are stored. On MacOS this will be the user’s default login keychain, and on Windows the secure-credentials.properties
file is stored in the user’s Gradle home dir. In case you want to override these locations you can define these using the`credentials` extension in your Gradle build file.
credentials {
keychainFile = "$projectDir/SEU-as-code.keychain"
propertyFile = "$projectDir/secure-credentials.properties"
}
Git Plugin
A Gradle plugin for handling Git repositories. It provides basic tasks to init, clone, commit, push and push Git repositories. This plugin does not require a Git CLI since it uses the JGit library under the hood. The repositories can be configured using the plugin extension.
Basic Usage
Build script snippet for use in all Gradle versions, using the Bintray Maven repository:
buildscript {
repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/seu-as-code/gradle-plugins' }
}
dependencies {
classpath 'de.qaware.seu.as.code:seuac-git-plugin:2.3.0.RC2'
}
}
apply plugin: 'de.qaware.seu.as.code.git'
Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
plugins {
id 'de.qaware.seu.as.code.git' version '2.3.0.RC2'
}
Tasks
The plugin defines the following tasks:
Task name | Depends on | Type | Description |
---|---|---|---|
|
all |
- |
Performs a Git init for all defined repositories. |
|
all |
- |
Performs a Git clone for all defined repositories. |
|
all |
- |
Performs a Git push for all defined repositories. |
|
all |
- |
Performs a Git pull for all defined repositories. |
|
all |
- |
Performs a Git status for all defined repositories. |
|
- |
GitInitTask |
Performs a Git init for the named Git repository. |
|
- |
GitCloneTask |
Performs a Git clone for the named Git repository. |
|
- |
GitStatusTask |
Performs a Git status for the named Git repository. |
|
- |
GitCommitTask |
Performs a Git commit for the named Git repository. Override message project property. |
|
- |
GitPushTask |
Performs a Git push for the named Git repository to remote origin. |
|
- |
GitPullTask |
Performs a Git pull for the named Git repository from remote origin. |
Extension
The plugin defines the following extension properties in the git
closure:
Property name | Type | Default value | Description |
---|---|---|---|
|
NamedDomainObjectContainer<GitRepository> |
- |
Contains the named Git repository definitions. |
|
String |
- |
The URL of the named Git repository. Include username and password in the URL. |
|
File |
- |
The local directory of the named Git repository. |
|
String |
- |
The branch name to use. Defaults to HEAD.
If |
|
String |
- |
The username used for authentication. |
|
String |
- |
The password used for authentication. |
|
GitOptions |
- |
The Git command options. |
Examples
Defining Git repositories
The following example defines the Git repository of the SEU-as-code plugins repo. The example does not hardcode the username and password properties, instead you should use either project properties or the SEU-as-code credentials plugin.
git {
SeuAsCodePlugins {
url 'https://github.com/seu-as-code/seu-as-code.plugins.git'
directory file("$seuHome/codebase/seu-as-code.plugins/")
branch 'HEAD'
username gitUsername
password gitPassword
options {
clone {
singleBranch = false
cloneSubmodules = true
noCheckout = false
timeout = 300
}
pull {
rebase = true
timeout = 600
}
push {
dryRun = false
pushAll = true
pushTags = true
timeout = 200
force = true
}
}
}
}
Working with Git repositories
Once you have defined one or more Git repositories using the plugin extension, you can perform the support operations by calling the associated tasks. Most of the command options from the configuration extension can also be set as commandline options.
$ ./gradlew gitCloneSeuAsCodePlugins
$ ./gradlew gitPullAll --rebase true
...
$ ./gradlew gitCommitSeuAsCodePlugins --message "New feature added."
$ ./gradlew gitPushAll --all
Platform Plugin
A basic Gradle plugin that allows to apply platform specific configurations in aGradle build file. Originally, this plugin has been developed to enable multi-platform SEUs. In a mixed team you sometimes have team members that develop under Windows, MacOS or Linux. But you want to support all these platform via one Gradle build file. But usually you need to use different dependency versions between these platforms or you may require different implementations of the same task depending on the platform.
Basic Usage
Build script snippet for use in all Gradle versions, using the Bintray Maven repository:
buildscript {
repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/seu-as-code/gradle-plugins' }
}
dependencies {
classpath 'de.qaware.seu.as.code:seuac-platform-plugin:1.0.0'
}
}
apply plugin: 'de.qaware.seu.as.code.platform'
Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
plugins {
id 'de.qaware.seu.as.code.platform' version '1.0.0'
}
Extra Properties
The plugin defines the following extra properties, that may be used for platform specific behaviour:
Task name | Description |
---|---|
|
The OS family, either |
|
The OS classifier, either |
|
The OS architecture, either |
Extension
The plugin defines the following closures in the platform
extension:
Property name | Type | Default value | Description |
---|---|---|---|
|
Closure |
- |
Apply configuration to project if running on Windows. |
|
Closure |
- |
Apply configuration to project if running on MacOS. |
|
Closure |
- |
Apply configuration to project if running on Linux or Unix. |
|
Closure |
- |
Apply configuration to project if running on x86 system. |
|
Closure |
- |
Apply configuration to project if running on x86_64 system. |
The following example shows the full extension configuration in code:
platform {
win { // add Windows specific code like dependencies or tasks here }
mac { // add MacOS specific code like dependencies or tasks here }
unix { // add Unix or Linux specific stuff like dependencies or tasks here }
x86 { // add 32-bit specific stuff like dependencies or tasks here }
x86_64 { // add 64-bit specific code like dependencies or tasks here }
}
Examples
Basic extension configuration
The following example uses the extension configuration to add platform specific dependencies as well as platform specific task definitions.
platform {
win {
dependencies {
software 'io.github.msysgit:git:1.9.5'
software 'org.gradle:gradle:2.13'
}
task helloSeuAsCode(group: 'Example') << {
println 'Hello SEU-as-code on Windows.'
}
}
mac {
dependencies {
software 'org.gradle:gradle:2.14'
}
task helloSeuAsCode(group: 'Example') << {
println 'Hello SEU-as-code on MacOS.'
}
}
}
Platform specific dependencies
The following example uses the $osClassifier
extra property as classifier to add a platform specific dependency.
dependencies {
software "de.qaware.seu.as.code:seuac-environment:2.3.0:$osClassifier"
}
Platform specific tasks
This example uses static methods from the Platform
class to enable tasks based on the current platform the build is running on.
import static de.qaware.seu.as.code.plugins.platform.Platform.isWindows
import static de.qaware.seu.as.code.plugins.platform.Platform.isMacOs
task helloWorldOnWindows(group: 'Example') {
enabled = isWindows()
doLast { println 'Hello World on Windows.' }
}
task helloWorldOnlyIfMac(group: 'Example') {
onlyIf { isMacOs() }
doLast { println 'Hello World only if Mac.' }
}
SVN Plugin
A Gradle plugin for handling SVN repositories. Provides basic tasks to checkout SVN repositories and update local directories. The repositories can be configured using an extension.
Basic Usage
Build script snippet for use in all Gradle versions, using the Bintray Maven repository:
buildscript {
repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/seu-as-code/gradle-plugins' }
}
dependencies {
classpath 'de.qaware.seu.as.code:seuac-svn-plugin:2.1.1'
}
}
apply plugin: 'de.qaware.seu.as.code.svn'
Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
plugins {
id 'de.qaware.seu.as.code.svn' version '2.1.1'
}
Tasks
The plugin defines the following tasks:
Task name | Depends on | Type | Description |
---|---|---|---|
|
all |
- |
Performs a SVN checkout of all defined repositories. |
|
all |
- |
Performs a SVN update of all defined repositories. |
|
- |
SvnCheckoutTask |
Performs a SVN checkout of the named SVN repository. |
|
- |
SvnUpdateTask |
Performs a SVN update of the named SVN repository. |
Extension
The plugin defines the following extension properties in the subversion
closure:
Property name | Type | Default value | Description |
---|---|---|---|
|
NamedDomainObjectContainer<SvnRepository> |
- |
Contains the named SVN repository definitions. |
|
String |
- |
The URL of the named SVN repository. |
|
File |
- |
The local checkout directory of the named SVN repository. |
|
String |
- |
The username used to authenticate. |
|
String |
- |
The password used to authenticate. |
Examples
Defining SVN repositories
The following example defines the SVN repository for the SEU-as-code plugins repo. The example does not hardcode the username and password properties, instead you should either use project properties or the SEU-as-code credentials plugin.
subversion {
SeuAsCodePlugins {
url 'https://github.com/seu-as-code/seu-as-code.plugins'
directory file("$seuHome/codebase/seu-as-code.plugins/")
username svnUsername
password svnPassword
}
}
Working with SVN repositories
Once you have defined one or more SVN repositories using the plugin extension, you can perform a SVN checkout and update on each repository individually or on all defined repos.
$ ./gradlew svnCheckoutSeuAsCodePlugins
$ ./gradlew svnUpdateAll