├── gradle.properties
├── Gemfile
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── seuac-git-plugin
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── gradle-plugins
│ │ │ │ ├── seuac-git.properties
│ │ │ │ └── de.qaware.seu.as.code.git.properties
│ │ └── groovy
│ │ │ └── de
│ │ │ └── qaware
│ │ │ └── seu
│ │ │ └── as
│ │ │ └── code
│ │ │ └── plugins
│ │ │ └── git
│ │ │ ├── GitUser.groovy
│ │ │ ├── GitPushOptions.groovy
│ │ │ ├── GitCloneOptions.groovy
│ │ │ ├── GitPullOptions.groovy
│ │ │ ├── GitInitTask.groovy
│ │ │ ├── GitStatusTask.groovy
│ │ │ ├── GitCommitOptions.groovy
│ │ │ ├── AbstractGitTask.groovy
│ │ │ ├── GitOptions.groovy
│ │ │ ├── GitPullTask.groovy
│ │ │ ├── GitPushTask.groovy
│ │ │ ├── GitCloneTask.groovy
│ │ │ └── GitCommitTask.groovy
│ └── test
│ │ └── groovy
│ │ └── de
│ │ └── qaware
│ │ └── seu
│ │ └── as
│ │ └── code
│ │ └── plugins
│ │ └── git
│ │ ├── GitStatusTaskSpec.groovy
│ │ ├── GitInitTaskSpec.groovy
│ │ ├── GitRepositorySpec.groovy
│ │ ├── GitPullTaskSpec.groovy
│ │ ├── GitCommitTaskSpec.groovy
│ │ └── GitPushTaskSpec.groovy
├── gradle.properties
└── LICENSE
├── seuac-svn-plugin
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── gradle-plugins
│ │ │ │ ├── seuac-svn.properties
│ │ │ │ └── de.qaware.seu.as.code.svn.properties
│ │ └── groovy
│ │ │ └── de
│ │ │ └── qaware
│ │ │ └── seu
│ │ │ └── as
│ │ │ └── code
│ │ │ └── plugins
│ │ │ └── svn
│ │ │ ├── SvnUpdateTask.groovy
│ │ │ ├── SvnCheckoutTask.groovy
│ │ │ ├── SvnRepository.groovy
│ │ │ ├── AbstractSvnTask.groovy
│ │ │ └── SvnPlugin.groovy
│ └── test
│ │ └── groovy
│ │ └── de
│ │ └── qaware
│ │ └── seu
│ │ └── as
│ │ └── code
│ │ └── plugins
│ │ └── svn
│ │ ├── SvnUpdateTaskSpec.groovy
│ │ └── SvnCheckoutTaskSpec.groovy
├── gradle.properties
└── LICENSE
├── seuac-base-plugin
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── gradle-plugins
│ │ │ │ ├── seuac-base.properties
│ │ │ │ └── de.qaware.seu.as.code.base.properties
│ │ └── groovy
│ │ │ └── de
│ │ │ └── qaware
│ │ │ └── seu
│ │ │ └── as
│ │ │ └── code
│ │ │ └── plugins
│ │ │ └── base
│ │ │ ├── CreateSeuacLayoutTask.groovy
│ │ │ ├── DestroySeuTask.groovy
│ │ │ ├── SeuacDatastore.groovy
│ │ │ ├── DatastoreProviderFactory.groovy
│ │ │ ├── SeuacBanner.groovy
│ │ │ ├── StoreSeuacDbTask.groovy
│ │ │ ├── ApplyConfigurationTask.groovy
│ │ │ └── RunHooksTask.groovy
│ └── test
│ │ ├── resources
│ │ ├── h2-1.3.176.jar
│ │ ├── seuac-mac-1.0.0.zip
│ │ ├── seuac-test-1.0.0.zip
│ │ ├── seuac-unix-1.0.0.zip
│ │ ├── seuac-win-1.0.0.zip
│ │ └── META-INF
│ │ │ └── hooks
│ │ │ └── testHook.groovy
│ │ └── groovy
│ │ └── de
│ │ └── qaware
│ │ └── seu
│ │ └── as
│ │ └── code
│ │ └── plugins
│ │ └── base
│ │ ├── PlatformSpec.groovy
│ │ ├── RunHooksTaskSpec.groovy
│ │ ├── DatastoreProviderFactorySpec.groovy
│ │ ├── CreateAsciiBannerTaskSpec.groovy
│ │ ├── StoreSeuacDbTaskSpec.groovy
│ │ ├── SeuacDatastoreSpec.groovy
│ │ ├── CreateSeuacLayoutTaskSpec.groovy
│ │ ├── DetroySeuTaskSpec.groovy
│ │ ├── PersistenceServiceFactorySpec.groovy
│ │ └── ApplyConfigurationTaskSpec.groovy
├── gradle.properties
└── LICENSE
├── seuac-homebrew-plugin
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── gradle-plugins
│ │ │ │ ├── seuac-homebrew.properties
│ │ │ │ └── de.qaware.seu.as.code.homebrew.properties
│ │ └── groovy
│ │ │ └── de
│ │ │ └── qaware
│ │ │ └── seu
│ │ │ └── as
│ │ │ └── code
│ │ │ └── plugins
│ │ │ └── homebrew
│ │ │ ├── StoreBrewSeuacDbTask.groovy
│ │ │ └── InstallHomebrewTask.groovy
│ └── test
│ │ └── groovy
│ │ └── de
│ │ └── qaware
│ │ └── seu
│ │ └── as
│ │ └── code
│ │ └── plugins
│ │ └── homebrew
│ │ ├── StoreBrewSeuacDbTaskTest.groovy
│ │ ├── InstallHomebrewTaskTest.groovy
│ │ ├── HomebrewPluginTest.groovy
│ │ └── ApplyBrewSoftwareTaskTest.groovy
├── gradle.properties
├── LICENSE
└── README.md
├── seuac-platform-plugin
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── gradle-plugins
│ │ │ │ ├── seuac-platform.properties
│ │ │ │ └── de.qaware.seu.as.code.platform.properties
│ │ └── groovy
│ │ │ └── de
│ │ │ └── qaware
│ │ │ └── seu
│ │ │ └── as
│ │ │ └── code
│ │ │ └── plugins
│ │ │ └── platform
│ │ │ └── SeuacPlatformPlugin.groovy
│ └── test
│ │ └── groovy
│ │ └── de
│ │ └── qaware
│ │ └── seu
│ │ └── as
│ │ └── code
│ │ └── plugins
│ │ └── platform
│ │ ├── PlatformSpec.groovy
│ │ └── SeuacPlatformPluginSpec.groovy
├── gradle.properties
└── LICENSE
├── seuac-chocolatey-plugin
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── META-INF
│ │ │ │ └── gradle-plugins
│ │ │ │ │ ├── seuac-chocolatey.properties
│ │ │ │ │ └── de.qaware.seu.as.code.chocolatey.properties
│ │ │ └── set-env-choco.cmd
│ │ └── groovy
│ │ │ └── de
│ │ │ └── qaware
│ │ │ └── seu
│ │ │ └── as
│ │ │ └── code
│ │ │ └── plugins
│ │ │ └── chocolatey
│ │ │ └── StoreChocolateySeuacDbTask.groovy
│ └── test
│ │ └── groovy
│ │ └── de
│ │ └── qaware
│ │ └── seu
│ │ └── as
│ │ └── code
│ │ └── plugins
│ │ └── chocolatey
│ │ ├── StoreChocolateySeuacDbTaskTest.groovy
│ │ └── ChocolateyPluginTest.groovy
├── gradle.properties
└── LICENSE
├── seuac-credentials-plugin
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── gradle-plugins
│ │ │ │ ├── seuac-credentials.properties
│ │ │ │ └── de.qaware.seu.as.code.credentials.properties
│ │ └── java
│ │ │ └── de
│ │ │ └── qaware
│ │ │ └── seu
│ │ │ └── as
│ │ │ └── code
│ │ │ └── plugins
│ │ │ └── credentials
│ │ │ ├── Encryptor.java
│ │ │ ├── win
│ │ │ └── DPAPIEncryptor.java
│ │ │ ├── CredentialsException.java
│ │ │ ├── SetCredentialsTask.java
│ │ │ ├── DisplayCredentialsTask.java
│ │ │ ├── CredentialsExtension.java
│ │ │ ├── ClearCredentialsTask.java
│ │ │ ├── SeuacCredentialsPlugin.java
│ │ │ ├── CredentialsProperty.java
│ │ │ ├── CredentialsStorageFactory.java
│ │ │ ├── Credentials.java
│ │ │ ├── SystemConsole.java
│ │ │ ├── OperatingSystem.java
│ │ │ └── CredentialsStorage.java
│ └── test
│ │ ├── resources
│ │ └── SEU-as-code.keychain
│ │ └── groovy
│ │ └── de
│ │ └── qaware
│ │ └── seu
│ │ └── as
│ │ └── code
│ │ └── plugins
│ │ └── credentials
│ │ ├── linux
│ │ └── SecretServiceAPICredentialsStorageSpec.groovy
│ │ ├── OperatingSystemSpec.groovy
│ │ ├── CredentialsSpec.groovy
│ │ ├── SeuacCredentialsPluginSpec.groovy
│ │ └── CredentialsPropertySpec.groovy
├── gradle.properties
└── LICENSE
├── settings.gradle
├── .gitignore
├── .travis.yml
├── Gemfile.lock
├── README.md
├── contributing.json
├── CONTRIBUTING.md
└── gradlew.bat
/gradle.properties:
--------------------------------------------------------------------------------
1 | version=3.0.0-bin
2 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | gem 'travis'
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seu-as-code/seu-as-code.plugins/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/resources/META-INF/gradle-plugins/seuac-git.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.git.GitPlugin
--------------------------------------------------------------------------------
/seuac-svn-plugin/src/main/resources/META-INF/gradle-plugins/seuac-svn.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.svn.SvnPlugin
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/resources/META-INF/gradle-plugins/seuac-base.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.base.SeuacBasePlugin
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/resources/META-INF/gradle-plugins/de.qaware.seu.as.code.git.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.git.GitPlugin
--------------------------------------------------------------------------------
/seuac-svn-plugin/src/main/resources/META-INF/gradle-plugins/de.qaware.seu.as.code.svn.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.svn.SvnPlugin
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/resources/META-INF/gradle-plugins/de.qaware.seu.as.code.base.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.base.SeuacBasePlugin
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/resources/h2-1.3.176.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seu-as-code/seu-as-code.plugins/HEAD/seuac-base-plugin/src/test/resources/h2-1.3.176.jar
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/src/main/resources/META-INF/gradle-plugins/seuac-homebrew.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.homebrew.HomebrewPlugin
2 |
--------------------------------------------------------------------------------
/seuac-platform-plugin/src/main/resources/META-INF/gradle-plugins/seuac-platform.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.platform.SeuacPlatformPlugin
--------------------------------------------------------------------------------
/seuac-chocolatey-plugin/src/main/resources/META-INF/gradle-plugins/seuac-chocolatey.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.chocolatey.ChocolateyPlugin
2 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/resources/seuac-mac-1.0.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seu-as-code/seu-as-code.plugins/HEAD/seuac-base-plugin/src/test/resources/seuac-mac-1.0.0.zip
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/resources/seuac-test-1.0.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seu-as-code/seu-as-code.plugins/HEAD/seuac-base-plugin/src/test/resources/seuac-test-1.0.0.zip
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/resources/seuac-unix-1.0.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seu-as-code/seu-as-code.plugins/HEAD/seuac-base-plugin/src/test/resources/seuac-unix-1.0.0.zip
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/resources/seuac-win-1.0.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seu-as-code/seu-as-code.plugins/HEAD/seuac-base-plugin/src/test/resources/seuac-win-1.0.0.zip
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/resources/META-INF/gradle-plugins/seuac-credentials.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.credentials.SeuacCredentialsPlugin
2 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/src/main/resources/META-INF/gradle-plugins/de.qaware.seu.as.code.homebrew.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.homebrew.HomebrewPlugin
2 |
--------------------------------------------------------------------------------
/seuac-platform-plugin/src/main/resources/META-INF/gradle-plugins/de.qaware.seu.as.code.platform.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.platform.SeuacPlatformPlugin
--------------------------------------------------------------------------------
/seuac-chocolatey-plugin/src/main/resources/META-INF/gradle-plugins/de.qaware.seu.as.code.chocolatey.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.chocolatey.ChocolateyPlugin
2 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/test/resources/SEU-as-code.keychain:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/seu-as-code/seu-as-code.plugins/HEAD/seuac-credentials-plugin/src/test/resources/SEU-as-code.keychain
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/resources/META-INF/gradle-plugins/de.qaware.seu.as.code.credentials.properties:
--------------------------------------------------------------------------------
1 | implementation-class=de.qaware.seu.as.code.plugins.credentials.SeuacCredentialsPlugin
2 |
--------------------------------------------------------------------------------
/seuac-chocolatey-plugin/src/main/resources/set-env-choco.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | set ChocolateyInstall=%SOFTWARE_DIR%\chocolatey
3 | set ChocolateyBinRoot=%SOFTWARE_DIR%
4 | set PATH=%ChocolateyInstall%\bin;%PATH%
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include 'seuac-base-plugin'
2 | include 'seuac-credentials-plugin'
3 | include 'seuac-git-plugin'
4 | include 'seuac-platform-plugin'
5 | include 'seuac-svn-plugin'
6 | include 'seuac-homebrew-plugin'
7 | include 'seuac-chocolatey-plugin'
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .gradle/
3 | build/
4 | *.iml
5 | classes/
6 |
7 | # Ignore Gradle GUI config
8 | gradle-app.setting
9 |
10 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
11 | !gradle-wrapper.jar
12 | .gradletasknamecache
13 |
--------------------------------------------------------------------------------
/seuac-svn-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | version=2.3.0
2 |
3 | displayName=Gradle SVN plugin
4 | description=A Gradle plugin for handling SVN repositories.
5 | websiteUrl=https://github.com/seu-as-code/seu-as-code.plugins/tree/master/seuac-svn-plugin
6 | scmUrl=https://github.com/seu-as-code/seu-as-code.plugins.git
7 | issueTrackerUrl=https://github.com/seu-as-code/seu-as-code.plugins/issues
8 | bintrayRepo=gradle-plugins
--------------------------------------------------------------------------------
/seuac-git-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | version=3.0.0
2 |
3 | displayName=Gradle Git plugin
4 | description=A Gradle plugin for handling Git repositories.
5 | websiteUrl=https://github.com/seu-as-code/seu-as-code.plugins/tree/master/seuac-git-plugin
6 | scmUrl=https://github.com/seu-as-code/seu-as-code.plugins.git
7 | issueTrackerUrl=https://github.com/seu-as-code/seu-as-code.plugins/issues
8 | bintrayRepo=gradle-plugins
9 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | version=3.0.0
2 |
3 | displayName=Gradle Credentials plugin
4 | description=A Gradle plugin for the secure storage of credentials.
5 | websiteUrl=https://github.com/seu-as-code/seu-as-code.plugins/tree/master/seuac-credentials-plugin
6 | scmUrl=https://github.com/seu-as-code/seu-as-code.plugins.git
7 | issueTrackerUrl=https://github.com/seu-as-code/seu-as-code.plugins/issues
8 | bintrayRepo=gradle-plugins
9 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | version=1.3.1
2 |
3 | displayName=SEU-as-code Homebrew plugin
4 | description=A Gradle plugin to install, update and uninstall homebrew packages.
5 | websiteUrl=https://github.com/seu-as-code/seu-as-code.plugins/tree/master/seuac-homebrew-plugin
6 | scmUrl=https://github.com/seu-as-code/seu-as-code.plugins.git
7 | issueTrackerUrl=https://github.com/seu-as-code/seu-as-code.plugins/issues
8 | bintrayRepo=gradle-plugins
9 |
--------------------------------------------------------------------------------
/seuac-chocolatey-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | version=1.0.1
2 |
3 | displayName=SEU-as-code Chocolatey plugin
4 | description=A Gradle plugin to install, update and uninstall choloatey packages.
5 | websiteUrl=https://github.com/seu-as-code/seu-as-code.plugins/tree/master/seuac-chocolatey-plugin
6 | scmUrl=https://github.com/seu-as-code/seu-as-code.plugins.git
7 | issueTrackerUrl=https://github.com/seu-as-code/seu-as-code.plugins/issues
8 | bintrayRepo=gradle-plugins
9 |
--------------------------------------------------------------------------------
/seuac-platform-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | version=1.1.0
2 | displayName=SEU-as-code Platform plugin
3 | description=A basic Gradle plugin to apply platform specific configuration in a Gradle build file.
4 | websiteUrl=https://github.com/seu-as-code/seu-as-code.plugins/tree/master/seuac-platform-plugin
5 | scmUrl=https://github.com/seu-as-code/seu-as-code.plugins.git
6 | issueTrackerUrl=https://github.com/seu-as-code/seu-as-code.plugins/issues
7 | bintrayRepo=gradle-plugins
8 |
--------------------------------------------------------------------------------
/seuac-base-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | version=3.0.0
2 |
3 | displayName=SEU-as-code Base plugin
4 | description=A Gradle plugin to support SEU-as-code based development environments and easy developer provisioning.
5 | websiteUrl=https://github.com/seu-as-code/seu-as-code.plugins/tree/master/seuac-base-plugin
6 | scmUrl=https://github.com/seu-as-code/seu-as-code.plugins.git
7 | issueTrackerUrl=https://github.com/seu-as-code/seu-as-code.plugins/issues
8 | bintrayRepo=gradle-plugins
9 |
--------------------------------------------------------------------------------
/seuac-base-plugin/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2015 QAware GmbH
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/seuac-git-plugin/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2015 QAware GmbH
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/seuac-svn-plugin/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2015 QAware GmbH
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/seuac-chocolatey-plugin/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2018 QAware GmbH
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2015 QAware GmbH
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/seuac-platform-plugin/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2015 QAware GmbH
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2015 QAware GmbH
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/resources/META-INF/hooks/testHook.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | assert seuHome
17 | assert seuLayout
18 | assert projectName
19 | assert directory
20 | assert logger
21 | assert platform
22 | assert ext
23 | assert project
24 |
25 | logger.info "Executing hooks for $projectName SEU in $seuHome"
26 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitUser.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.gradle.api.tasks.Input
19 |
20 | /**
21 | * A holder class for personal information about the author and committer.
22 | *
23 | * @author lreimer
24 | */
25 | class GitUser {
26 | @Input
27 | String username
28 | @Input
29 | String email
30 | }
31 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitPushOptions.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | /**
19 | * Simple data class to model additional options for the GitPushTask.
20 | *
21 | * @author lreimer
22 | */
23 | class GitPushOptions {
24 | boolean dryRun = false
25 | boolean pushAll = false
26 | boolean pushTags = false
27 | int timeout
28 | boolean force
29 | }
30 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitCloneOptions.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | /**
19 | * Simple data class to model additional options for the GitCloneTask.
20 | *
21 | * @author lreimer
22 | */
23 | class GitCloneOptions {
24 | boolean singleBranch = false
25 | boolean cloneAllBranches
26 | boolean cloneSubmodules
27 | boolean noCheckout
28 | int timeout
29 | }
30 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitPullOptions.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | /**
19 | * Simple data class to model additional options for the GitPullTask.
20 | *
21 | * @author lreimer
22 | */
23 | class GitPullOptions {
24 | boolean rebase = false
25 | int timeout
26 | MergeStrategy strategy = MergeStrategy.RECURSIVE
27 |
28 | enum MergeStrategy {
29 | OURS, THEIRS, SIMPLE_TWO_WAY_IN_CORE, RESOLVE, RECURSIVE
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/Encryptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | /**
19 | * Encrypts and decrypts data.
20 | *
21 | * @author phxql
22 | */
23 | public interface Encryptor {
24 | /**
25 | * Encrypts the given plaintext.
26 | *
27 | * @param plaintext Plaintext.
28 | * @return Ciphertext.
29 | */
30 | byte[] encrypt(byte[] plaintext);
31 |
32 | /**
33 | * Decrypts the given ciphertext.
34 | *
35 | * @param ciphertext Ciphertext.
36 | * @return Plaintext.
37 | */
38 | byte[] decrypt(byte[] ciphertext);
39 | }
40 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitInitTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.eclipse.jgit.api.Git
19 | import org.eclipse.jgit.api.InitCommand
20 | import org.gradle.api.tasks.TaskAction
21 |
22 | /**
23 | * The task implementation to perform a Git init.
24 | *
25 | * @author lreimer
26 | */
27 | class GitInitTask extends AbstractGitTask {
28 | @TaskAction
29 | def doInit() {
30 | withExceptionHandling('Could not initialize Git repository.') {
31 | InitCommand init = Git.init()
32 | init.setBare(false).setDirectory(directory)
33 | init.call()
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: groovy
2 | sudo: false
3 |
4 | before_cache:
5 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
6 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
7 | cache:
8 | directories:
9 | - $HOME/.gradle/caches/
10 | - $HOME/.gradle/wrapper/
11 |
12 | jdk:
13 | - oraclejdk8
14 | - openjdk8
15 |
16 | env:
17 | - TERM=dumb
18 |
19 | before_install:
20 | - chmod +x gradlew
21 |
22 | script: ./gradlew build jacocoTestReport
23 |
24 | after_success: ./gradlew jacocoRootReport coveralls assembleReleaseDist
25 |
26 | deploy:
27 | provider: releases
28 | api_key:
29 | secure: nBC2rJFv31Ge4ZHZE0MHsK21TFFGpM0M8LyV9Jdc2RzvNp0HxHlBaL7sERL8iSeP0BoC/WHB7H7WDgDPFPdqTIS0Uyl7+4/m+Rn/1juFEJH2+fstqHUXO3u4RKqbLSRBMwlBEEgUfw5g60K6fwN+pf6XFNKwqW9M727O9z7lwOuxk9L3cz0ysvD1f+9Hdza4HAKGA5CSzWn1DbYohNF/xhG+YkFYm3gEVCzmHTymBz+o1BelKsRMKGgLbiP+Q58wBYx3zJEVSZaTPyQkAQt5UuIbdiZsgJuXaPiFYleXWxWj2iO09m/MPzy59Z+oGWT/X4wU/1Q2/ivAJY0cksLYeRUwmDbwHvkx4+iDP9S9n37Klyxk8QfhJH5Fm/aXu1blYCl9bgJS4dPrqqtkIjqdNYA4ydMZp3DGu+OfM6FLn/KYvKijGSgoKMzGbx2pKQLqCbl/3ksuUHNgr3UX5MExy5iy6x8RiK9KzuBdoj32w/Em8kbtcJHxvegy6s1L62g4BpGv3PshQC7r/7HCkZIjew6XwYWpirKBPoyU1b3BBBhI9XNuwhFJtG6+pzLZWV0Cv/wlQhZ1BHHsC3bUQcuqh1O0+l/nq6KogLdY8B+53gxAEBPlz/eEQ/Krh0ysg6fHZtNp7XjKxBTC8LJoP0f50UprxaF7hdmXy0mSv8jEa5A=
30 | file_glob: true
31 | file: ./build/distributions/*
32 | skip_cleanup: true
33 | on:
34 | tags: true
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/win/DPAPIEncryptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials.win;
17 |
18 | import com.sun.jna.platform.win32.Crypt32Util;
19 | import de.qaware.seu.as.code.plugins.credentials.Encryptor;
20 |
21 | /**
22 | * Uses DPAPI to encrypt/decrypt data.
23 | *
24 | * @author phxql
25 | */
26 | public class DPAPIEncryptor implements Encryptor {
27 | @Override
28 | public byte[] encrypt(byte[] plaintext) {
29 | return Crypt32Util.cryptProtectData(plaintext);
30 | }
31 |
32 | @Override
33 | public byte[] decrypt(byte[] ciphertext) {
34 | return Crypt32Util.cryptUnprotectData(ciphertext);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/seuac-svn-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/svn/SvnUpdateTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.svn
17 |
18 | import org.gradle.api.tasks.TaskAction
19 | import org.tmatesoft.svn.core.SVNDepth
20 | import org.tmatesoft.svn.core.wc.SVNRevision
21 |
22 | /**
23 | * The task implementation class to update a given SVN repository.
24 | *
25 | * @author lreimer
26 | */
27 | class SvnUpdateTask extends AbstractSvnTask {
28 | @TaskAction
29 | def doUpdate() {
30 | withExceptionHandling {
31 | def svnUpdateClient = createSvnUpdateClient(username, password)
32 | svnUpdateClient.doUpdate(directory, SVNRevision.HEAD, SVNDepth.INFINITY, false, false)
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | addressable (2.3.8)
5 | backports (3.6.6)
6 | coderay (1.1.0)
7 | ethon (0.7.4)
8 | ffi (>= 1.3.0)
9 | faraday (0.9.1)
10 | multipart-post (>= 1.2, < 3)
11 | faraday_middleware (0.10.0)
12 | faraday (>= 0.7.4, < 0.10)
13 | ffi (1.9.10-x64-mingw32)
14 | gh (0.14.0)
15 | addressable
16 | backports
17 | faraday (~> 0.8)
18 | multi_json (~> 1.0)
19 | net-http-persistent (>= 2.7)
20 | net-http-pipeline
21 | highline (1.7.3)
22 | json (1.8.3)
23 | launchy (2.4.3)
24 | addressable (~> 2.3)
25 | method_source (0.8.2)
26 | multi_json (1.11.2)
27 | multipart-post (2.0.0)
28 | net-http-persistent (2.9.4)
29 | net-http-pipeline (1.0.1)
30 | pry (0.9.12.6)
31 | coderay (~> 1.0)
32 | method_source (~> 0.8)
33 | slop (~> 3.4)
34 | pusher-client (0.6.2)
35 | json
36 | websocket (~> 1.0)
37 | slop (3.6.0)
38 | travis (1.8.0)
39 | addressable (~> 2.3)
40 | backports
41 | faraday (~> 0.9)
42 | faraday_middleware (~> 0.9, >= 0.9.1)
43 | gh (~> 0.13)
44 | highline (~> 1.6)
45 | launchy (~> 2.1)
46 | pry (~> 0.9, < 0.10)
47 | pusher-client (~> 0.4)
48 | typhoeus (~> 0.6, >= 0.6.8)
49 | typhoeus (0.7.3)
50 | ethon (>= 0.7.4)
51 | websocket (1.2.2)
52 |
53 | PLATFORMS
54 | x64-mingw32
55 |
56 | DEPENDENCIES
57 | travis
58 |
59 | BUNDLED WITH
60 | 1.10.6
61 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/CredentialsException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | import org.gradle.api.GradleException;
19 |
20 | /**
21 | * A custom Gradle exception to signal something went wrong with managed Credentials.
22 | *
23 | * @author lreimer
24 | */
25 | public class CredentialsException extends GradleException {
26 | /**
27 | * Initialize exception with error message.
28 | *
29 | * @param message the message
30 | */
31 | public CredentialsException(String message) {
32 | super(message);
33 | }
34 |
35 | /**
36 | * Initialize exception with error message and cause.
37 | *
38 | * @param message the error message
39 | * @param cause the cause
40 | */
41 | public CredentialsException(String message, Throwable cause) {
42 | super(message, cause);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitStatusTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.eclipse.jgit.api.Git
19 | import org.eclipse.jgit.api.StatusCommand
20 | import org.eclipse.jgit.lib.TextProgressMonitor
21 | import org.gradle.api.tasks.TaskAction
22 |
23 | /**
24 | * The task implementation to perform a Git status operation.
25 | *
26 | * @author lreimer
27 | */
28 | class GitStatusTask extends AbstractGitTask {
29 |
30 | @TaskAction
31 | def doStatus() {
32 | Git gitRepo = null
33 | withExceptionHandling('Could not get status for Git repository.') {
34 | gitRepo = Git.open(directory)
35 |
36 | StatusCommand status = gitRepo.status()
37 | status.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
38 | status.call()
39 | } always {
40 | if (gitRepo) {
41 | gitRepo.close()
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/seu-as-code/seu-as-code.plugins)
2 | [](https://coveralls.io/github/seu-as-code/seu-as-code.plugins?branch=master)
3 | [](https://github.com/seu-as-code/seu-as-code.plugins/blob/master/LICENSE)
4 |
5 | # SEU-as-code Plugins
6 |
7 | * SEU: German for software development environment (Software Entwicklungs-Umgebung)
8 | * as-code: to be able to configure, build and program the SEU as source code
9 |
10 | The SEU-as-code plugins are plain Gradle plugins for lightweight developer provisioning using Gradle. The plugins provide
11 | convenient configuration conventions and common SEU tasks for your daily work as a developer.
12 |
13 | ## Development
14 |
15 | For details on building and developing SEU-as-code plugins, please see the [Wiki](https://github.com/seu-as-code/seu-as-code.plugins/wiki/Development).
16 |
17 | ## Contributing
18 |
19 | Is there anything missing? Do you have ideas for new features or improvements? You are highly welcome to contribute
20 | your improvements, plugins or packages to the SEU-as-code projects. All you have to do is to fork this repository,
21 | improve the code and issue a pull request. You can also have a look at the [Contributor Guide](https://github.com/seu-as-code/seu-as-code.plugins/wiki/Contributor-Guide)
22 |
23 | ## Maintainer
24 |
25 | M.-Leander Reimer (@lreimer)
26 |
27 | ## License
28 |
29 | This software is provided under the Apache License, Version 2.0 license.
30 |
31 | See the `LICENSE` file for details.
32 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/credentials/linux/SecretServiceAPICredentialsStorageSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials.linux
17 |
18 | import de.qaware.seu.as.code.plugins.credentials.Credentials
19 | import spock.lang.Requires
20 | import spock.lang.Specification
21 |
22 | /**
23 | * Test spec for the MacOS Keychain credential store.
24 | *
25 | * @author lreimer
26 | */
27 | class SecretServiceAPICredentialsStorageSpec extends Specification {
28 |
29 |
30 | @Requires({ os.linux && !Boolean.valueOf(env['CI']) })
31 | def "Integration test on Linux"() {
32 | given:
33 | def storage = new SecretServiceAPICredentialsStorage()
34 | def credentials = new Credentials('Max', 'Mustermann')
35 |
36 | when:
37 | storage.setCredentials('spock', credentials)
38 | def found = storage.findCredentials('spock')
39 | storage.clearCredentials('spock')
40 |
41 | then:
42 | found?.username == credentials.username
43 | found?.password == credentials.password
44 | storage.findCredentials('spock') == null
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/SetCredentialsTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | import org.gradle.api.tasks.TaskAction;
19 |
20 | /**
21 | * Task to set the credentials for a given service.
22 | *
23 | * Invoke with 'gradle setCredentials --service [name of service]' or alternatively with
24 | * 'gradle setCredentials --service [name of service] --username [the username]'
25 | *
26 | * The task will query the username and password on the console to input the value of the credentials.
27 | *
28 | * @author phxql
29 | */
30 | public class SetCredentialsTask extends AbstractCredentialsTask {
31 |
32 | /**
33 | * Constructor initializing the tasks meta data.
34 | */
35 | public SetCredentialsTask() {
36 | this.setDescription("Sets the credentials.");
37 | }
38 |
39 | /**
40 | * Is executed from gradle when running the 'setStorage' task.
41 | */
42 | @TaskAction
43 | public void onAction() {
44 | getConsole().format("%n");
45 | getStorage().setCredentials(getService(), getUsername(), getPassword());
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/PlatformSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import spock.lang.Requires
19 | import spock.lang.Specification
20 | import spock.lang.Unroll
21 |
22 | /**
23 | * Test and check the Platform enum behaviour.
24 | *
25 | * @author lreimer
26 | */
27 | class PlatformSpec extends Specification {
28 |
29 | @Requires({ os.macOs })
30 | def "Check current on Mac OS"() {
31 | expect:
32 | Platform.current() == Platform.MacOs
33 | Platform.isMacOs()
34 | }
35 |
36 | @Requires({ os.windows })
37 | def "Check current on Windows"() {
38 | expect:
39 | Platform.current() == Platform.Windows
40 | Platform.isWindows()
41 | }
42 |
43 | @Unroll
44 | def "Check Platform from OS #name"() {
45 | expect:
46 | Platform.fromOsName(name) == os
47 |
48 | where:
49 | name || os
50 | 'Windows 98' || Platform.Windows
51 | 'Linux' || Platform.Unix
52 | 'Mac OS X' || Platform.MacOs
53 | 'Darwin' || Platform.MacOs
54 | 'OSX' || Platform.MacOs
55 | 'Android' || Platform.Unknown
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/seuac-platform-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/platform/PlatformSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.platform
17 |
18 | import spock.lang.Requires
19 | import spock.lang.Specification
20 | import spock.lang.Unroll
21 |
22 | /**
23 | * Test and check the Platform enum behaviour.
24 | *
25 | * @author lreimer
26 | */
27 | class PlatformSpec extends Specification {
28 |
29 | @Requires({ os.macOs })
30 | def "Check current on Mac OS"() {
31 | expect:
32 | Platform.current() == Platform.MacOs
33 | Platform.isMacOs()
34 | }
35 |
36 | @Requires({ os.windows })
37 | def "Check current on Windows"() {
38 | expect:
39 | Platform.current() == Platform.Windows
40 | Platform.isWindows()
41 | }
42 |
43 | @Unroll
44 | def "Check Platform from OS #name"() {
45 | expect:
46 | Platform.fromOsName(name) == os
47 |
48 | where:
49 | name || os
50 | 'Windows 98' || Platform.Windows
51 | 'Linux' || Platform.Unix
52 | 'Mac OS X' || Platform.MacOs
53 | 'Darwin' || Platform.MacOs
54 | 'OSX' || Platform.MacOs
55 | 'Android' || Platform.Unknown
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/contributing.json:
--------------------------------------------------------------------------------
1 | // https://gitmagic.io/rules
2 | {
3 | "commit": {
4 | "subject_cannot_be_empty": true,
5 | "subject_must_be_longer_than": 3,
6 | "subject_must_be_shorter_than": 101,
7 | "subject_lines_must_be_shorter_than": 101,
8 | "subject_must_be_single_line": true,
9 | "subject_must_be_in_tense": "past",
10 | "subject_must_start_with_case": "upper",
11 | "subject_must_end_with_dot": true,
12 | "subject_must_close_github_issue": false,
13 | "subject_must_include_github_issue": true,
14 | // Body is the rest of the commit message after the first paragraph,
15 | // separated by a blank line.
16 | "body_cannot_be_empty": false,
17 | "body_lines_must_be_shorter_than": 73,
18 | "body_must_close_github_issue": false,
19 | "body_must_include_github_issue": false
20 | },
21 |
22 | "pull_request": {
23 | "subject_cannot_be_empty": true,
24 | "subject_must_be_longer_than": 3,
25 | "subject_must_be_shorter_than": 101,
26 | "subject_must_be_in_tense": "past",
27 | "subject_must_start_with_case": "upper",
28 | "subject_must_not_end_with_dot": true,
29 | "subject_must_include_github_issue": false,
30 |
31 | "body_cannot_be_empty": true,
32 | "body_must_include_verification_steps": false,
33 | "body_must_close_github_issue": false,
34 | "body_must_include_github_issue": false
35 | },
36 |
37 | "issue": {
38 | "subject_cannot_be_empty": true,
39 | "subject_must_be_longer_than": 3,
40 | "subject_must_be_shorter_than": 101,
41 | "subject_must_be_in_tense": "imperative",
42 | "subject_must_start_with_case": "upper",
43 | "subject_must_not_end_with_dot": true,
44 | "body_cannot_be_empty": true,
45 | "body_must_include_reproduction_steps": false,
46 | "label_must_be_set": true
47 | },
48 | "branch": {
49 | "name_must_be_longer_than": 3,
50 | "name_must_be_shorter_than": 127,
51 | "name_must_include_github_issue": false
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/base/CreateSeuacLayoutTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.DefaultTask
19 | import org.gradle.api.GradleException
20 | import org.gradle.api.tasks.Nested
21 | import org.gradle.api.tasks.TaskAction
22 |
23 | /**
24 | * A simple tasks to create the SEU-as-code directory layout.
25 | *
26 | * @author lreimer
27 | */
28 | class CreateSeuacLayoutTask extends DefaultTask {
29 |
30 | @Nested
31 | SeuacLayout layout
32 |
33 | /**
34 | * Initialize the group and description for this task.
35 | */
36 | CreateSeuacLayoutTask() {
37 | group = 'SEU-as-code'
38 | description = 'Creates the SEU directory layout.'
39 | }
40 |
41 | /**
42 | * Create the directory layout and make all required directories. For incremental build support
43 | * the output will be initialized, except the codebase directory, this caused problems when the
44 | * SEU itself is located in codebase.
45 | */
46 | @TaskAction
47 | void mkdirs() {
48 | try {
49 | layout.mkdirs()
50 | } catch (IOException e) {
51 | throw new GradleException("Error creating SEU directory layout.", e)
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/seuac-svn-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/svn/SvnCheckoutTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.svn
17 |
18 | import org.gradle.api.GradleException
19 | import org.gradle.api.tasks.Input
20 | import org.gradle.api.tasks.TaskAction
21 | import org.tmatesoft.svn.core.SVNDepth
22 | import org.tmatesoft.svn.core.SVNURL
23 | import org.tmatesoft.svn.core.wc.SVNRevision
24 |
25 | /**
26 | * The task implementation class to checkout a given SVN repository.
27 | *
28 | * @author lreimer
29 | */
30 | class SvnCheckoutTask extends AbstractSvnTask {
31 |
32 | @Input
33 | String url
34 |
35 | @TaskAction
36 | def doCheckout() {
37 | withExceptionHandling {
38 | SVNURL repositoryURL = SVNURL.parseURIEncoded(url)
39 | def svnUpdateClient = createSvnUpdateClient(username, password)
40 |
41 | SVNRevision svnRevision = (revision == null ? SVNRevision.HEAD : SVNRevision.parse(revision))
42 |
43 | if (svnRevision == SVNRevision.UNDEFINED) {
44 | throw new GradleException("Invalid SVN revision: " + this.revision)
45 | }
46 |
47 | svnUpdateClient.doCheckout(repositoryURL, directory, SVNRevision.HEAD,
48 | svnRevision, SVNDepth.INFINITY, false)
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/RunHooksTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.testfixtures.ProjectBuilder
20 | import spock.lang.Specification
21 |
22 | /**
23 | * Test specification to check correct execution of hooks.
24 | *
25 | * @author lreimer
26 | */
27 | class RunHooksTaskSpec extends Specification {
28 | Project project
29 | File classesDir
30 |
31 | def setup() {
32 | project = ProjectBuilder.builder().build()
33 | classesDir = new File(RunHooksTaskSpec.getResource("/").toURI())
34 | }
35 |
36 | def "Define RunSoftwareHooksTask and runHooks"() {
37 | given: "a configured RunHooksTask"
38 | RunHooksTask task = project.task("runSoftwareHooks", type: RunHooksTask) {
39 | seuHome = 'S:'
40 | seuLayout = SeuacLayout.defaultLayout('S:')
41 | projectName = 'Base Plugin Test'
42 | target = classesDir
43 | deleteHooks = false
44 | }
45 |
46 | when: "we run the hooks"
47 | task.runHooks()
48 |
49 | then: "we expect no exceptions and an existing hooks dir"
50 | notThrown(Exception)
51 | assert new File(classesDir, 'META-INF/hooks/').exists()
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/DisplayCredentialsTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | import org.gradle.api.tasks.TaskAction;
19 |
20 | /**
21 | * Task to display the credentials for a given service.
22 | *
23 | * Invoke with 'gradle displayCredentials --service [name of service]'
24 | *
25 | *
26 | * @author lreimer
27 | */
28 | public class DisplayCredentialsTask extends AbstractCredentialsTask {
29 |
30 | /**
31 | * Constructor initializing the tasks meta data.
32 | */
33 | public DisplayCredentialsTask() {
34 | this.setDescription("Displays the credentials.");
35 | }
36 |
37 | /**
38 | * Is executed from gradle when running the 'setStorage' task.
39 | */
40 | @TaskAction
41 | public void onAction() {
42 | String service = getService();
43 | Credentials credentials = getStorage().findCredentials(service);
44 | if (credentials != null) {
45 | getConsole().format("%nCurrent credentials for service '%s' -> {'%s', '%s'}.%n", service,
46 | credentials.getUsername(), credentials.getPassword());
47 | } else {
48 | getConsole().format("%nNo credentials found for service '%s'.%n", service);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/CredentialsExtension.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | /**
19 | * The extension class for additional configuration options.
20 | *
21 | * @author lreimer
22 | */
23 | public class CredentialsExtension {
24 | /**
25 | * Name of the credentials configuration extension in the build script.
26 | */
27 | static final String NAME = "credentials";
28 |
29 | private String keychainFile = null;
30 | private String propertyFile = null;
31 |
32 | public String getKeychainFile() {
33 | return keychainFile;
34 | }
35 |
36 | public void setKeychainFile(String keychainFile) {
37 | this.keychainFile = keychainFile;
38 | }
39 |
40 | public String getPropertyFile() {
41 | return propertyFile;
42 | }
43 |
44 | public void setPropertyFile(String propertyFile) {
45 | this.propertyFile = propertyFile;
46 | }
47 |
48 | @Override
49 | public String toString() {
50 | final StringBuilder sb = new StringBuilder("CredentialsExtension{");
51 | sb.append("keychainFile='").append(keychainFile).append('\'');
52 | sb.append(", propertyFile='").append(propertyFile).append('\'');
53 | sb.append('}');
54 | return sb.toString();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/base/DestroySeuTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.DefaultTask
19 | import org.gradle.api.GradleException
20 | import org.gradle.api.tasks.TaskAction
21 |
22 | /**
23 | * A simple tasks to destroy the SEU. This will delete all the directories from
24 | * the SEU layout.
25 | *
26 | * @author lreimer
27 | */
28 | class DestroySeuTask extends DefaultTask {
29 |
30 | SeuacLayout layout
31 | SeuacDatastore datastore
32 |
33 | /**
34 | * Initialize the group and description for this task.
35 | */
36 | DestroySeuTask() {
37 | group = 'SEU-as-code'
38 | description = 'Destroy the complete SEU. Be careful!'
39 | }
40 |
41 | /**
42 | * Removes all the directories from the layout and resets the dependencies DB.
43 | */
44 | @TaskAction
45 | void destroy() {
46 | try {
47 | // remove all directories for the layout
48 | layout.rmdirs()
49 | } catch (IOException e) {
50 | throw new GradleException("Error destroying SEU directory layout.", e)
51 | }
52 |
53 | // remove all dependencies from the DB
54 | DatastoreProvider provider = DatastoreProviderFactory.instance.get(datastore)
55 | provider.reset()
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/seuac-platform-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/platform/SeuacPlatformPlugin.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.platform
17 |
18 | import org.gradle.api.Plugin
19 | import org.gradle.api.Project
20 |
21 | /**
22 | * The SEU-as-code platform plugin allows platform specific project configuration.
23 | *
24 | * @author lreimer
25 | */
26 | class SeuacPlatformPlugin implements Plugin {
27 | /**
28 | * Name of the osFamily extra property.
29 | */
30 | static final String OS_FAMILY = 'osFamily'
31 | /**
32 | * Name of the osClassifier extra property.
33 | */
34 | static final String OS_CLASSIFIER = 'osClassifier'
35 | /**
36 | * Name of the osArch extra property.
37 | */
38 | static final String OS_ARCH = 'osArch'
39 |
40 | @Override
41 | void apply(Project project) {
42 | def platform = Platform.current()
43 |
44 | // register extra properties for OS family, classifier and architecture
45 | project.extensions.extraProperties.set(OS_FAMILY, platform.osFamily)
46 | project.extensions.extraProperties.set(OS_CLASSIFIER, platform.osClassifier)
47 | project.extensions.extraProperties.set(OS_ARCH, platform.osArch)
48 |
49 | // register extension to project
50 | project.extensions.add(PlatformExtension.NAME, new PlatformExtension(project, platform))
51 | }
52 | }
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/ClearCredentialsTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | import org.apache.commons.lang3.StringUtils;
19 | import org.gradle.api.tasks.TaskAction;
20 |
21 | /**
22 | * Task to to clear the stored credentials for a given service.
23 | *
24 | * Invoke with 'gradle clearCredentials --service [name of service]' or alternatively with
25 | * 'gradle setCredentials --service [name of service] --username [the username]'
26 | *
27 | *
28 | * @author clboettcher
29 | */
30 | public class ClearCredentialsTask extends AbstractCredentialsTask {
31 |
32 | /**
33 | * Constructor initializing the tasks meta data.
34 | */
35 | public ClearCredentialsTask() {
36 | this.setDescription("Clears the credentials.");
37 | }
38 |
39 | /**
40 | * Is executed from gradle when running the 'clearCredentials' task.
41 | */
42 | @TaskAction
43 | public void onAction() {
44 | String service = getService();
45 | if (StringUtils.isNotBlank(service)) {
46 | getConsole().format("%n");
47 | String answer = getConsole().readLine("Clear credentials for service %s (y/N)?", service);
48 | if (StringUtils.equalsIgnoreCase(answer, "y")) {
49 | getStorage().clearCredentials(service);
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/credentials/OperatingSystemSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials
17 |
18 | import spock.lang.Requires
19 | import spock.lang.Specification
20 | import spock.lang.Unroll
21 |
22 | /**
23 | * The Spock spec of the OperatingSystem enum class.
24 | *
25 | * @author lreimer
26 | */
27 | class OperatingSystemSpec extends Specification {
28 | @Requires({ os.macOs })
29 | def "Check current on Mac OS"() {
30 | expect:
31 | OperatingSystem.isMacOs()
32 | OperatingSystem.isSupported()
33 | }
34 |
35 | @Requires({ os.windows })
36 | def "Check current on Windows"() {
37 | expect:
38 | OperatingSystem.isWindows()
39 | OperatingSystem.isSupported()
40 | }
41 |
42 | @Requires({ os.linux })
43 | def "Check current on Linux"() {
44 | expect:
45 | OperatingSystem.isLinux()
46 | OperatingSystem.isSupported()
47 | }
48 |
49 | @Unroll
50 | def "Check for OS #name"() {
51 | expect:
52 | OperatingSystem.forOsName(name) == os
53 |
54 | where:
55 | name || os
56 | 'Windows 98' || OperatingSystem.WINDOWS
57 | 'Linux' || OperatingSystem.LINUX
58 | 'Mac OS X' || OperatingSystem.MAC_OS
59 | 'Darwin' || OperatingSystem.MAC_OS
60 | 'OSX' || OperatingSystem.MAC_OS
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/homebrew/StoreBrewSeuacDbTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.homebrew
17 |
18 | import de.qaware.seu.as.code.plugins.base.DatastoreProvider
19 | import de.qaware.seu.as.code.plugins.base.DatastoreProviderFactory
20 | import de.qaware.seu.as.code.plugins.base.SeuacDatastore
21 | import org.gradle.api.DefaultTask
22 | import org.gradle.api.artifacts.Dependency
23 | import org.gradle.api.tasks.TaskAction
24 |
25 | /**
26 | * This task will store the SEU-as-code configuration to the configured storage.
27 | */
28 | class StoreBrewSeuacDbTask extends DefaultTask {
29 |
30 | File homebrewBasePath
31 | SeuacDatastore datastore
32 |
33 | /**
34 | * Initialize the group and description for this task.
35 | */
36 | StoreBrewSeuacDbTask() {
37 | group = 'SEU-as-code'
38 | description = 'Store the current SEU brew software package configuration.'
39 | }
40 | /**
41 | * Stores the SEU-as-code database for the brew software configuration.
42 | */
43 | @TaskAction
44 | void storeSeuacDb() {
45 | DatastoreProvider provider = DatastoreProviderFactory.instance.get(datastore)
46 | provider.init()
47 |
48 | project.configurations.brew.dependencies.each { Dependency d ->
49 | provider.storeDependency(d, [project.fileTree(new File("${homebrewBasePath}/Cellar/${d.name}/"))], 'brew')
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/base/SeuacDatastore.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.tasks.Input
19 |
20 | /**
21 | * Simple data type to represent the datastore configuration.
22 | *
23 | * @author lreimer
24 | */
25 | class SeuacDatastore {
26 |
27 | @Input
28 | String url
29 | @Input
30 | String user
31 | @Input
32 | String password
33 |
34 | /**
35 | * Short hand method to set the URL via method.
36 | *
37 | * @param aUrl a datastore provider URL
38 | */
39 | void url(String aUrl) {
40 | this.url = aUrl
41 | }
42 |
43 | /**
44 | * Short hand method to set the datastore user. Might be NULL.
45 | *
46 | * @param aUser a datastore user if required
47 | */
48 | void user(String aUser) {
49 | this.user = aUser
50 | }
51 |
52 | /**
53 | * Short hand method to set the datastore password. Might be NULL.
54 | *
55 | * @param aPassword a datastore password if required
56 | */
57 | void password(String aPassword) {
58 | this.password = aPassword
59 | }
60 |
61 | static SeuacDatastore temporaryDatastore() {
62 | def tmpDir = File.createTempDir()
63 | Runtime.runtime.addShutdownHook({ tmpDir.deleteDir() })
64 | def tmpSeuFile = tmpDir.toPath().resolve("seuac")
65 | new SeuacDatastore(
66 | user: 'sa',
67 | password: 'sa',
68 | url: "jdbc:h2:${tmpSeuFile.toAbsolutePath()}"
69 | )
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/DatastoreProviderFactorySpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package de.qaware.seu.as.code.plugins.base
18 |
19 | import org.gradle.api.GradleException
20 | import spock.lang.Specification
21 | import spock.lang.Unroll
22 |
23 | class DatastoreProviderFactorySpec extends Specification {
24 | @Unroll
25 | def "Get datastore provider class for #url"() {
26 | given:
27 | def datastore = new SeuacDatastore(url: url)
28 |
29 | when:
30 | def datastoreProviderClass = DatastoreProviderFactory.instance.getProviderClass(datastore)
31 |
32 | then:
33 | datastoreProviderClass != null
34 | datastoreProviderClass == expectedProviderClass
35 |
36 | when:
37 | def datastoreProviderClass2ndCall = DatastoreProviderFactory.instance.getProviderClass(datastore)
38 |
39 | then:
40 | datastoreProviderClass == datastoreProviderClass2ndCall
41 |
42 | where:
43 | url | expectedProviderClass
44 | "jdbc:h2:C:\\mydb" | JdbcH2DatastoreProvider
45 | "jdbc:h2:./mydb" | JdbcH2DatastoreProvider
46 | "jdbc:h2:/home/user/mydb" | JdbcH2DatastoreProvider
47 | "file:mapdb:mydb" | MapDbDatastoreProvider
48 | }
49 |
50 | def "Get unknown datastore provider class"() {
51 | given:
52 | def datastore = new SeuacDatastore(url: "invalid")
53 |
54 | when:
55 | DatastoreProviderFactory.instance.getProviderClass(datastore)
56 |
57 | then:
58 | thrown(GradleException)
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitCommitOptions.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.gradle.api.tasks.Input
19 | import org.gradle.api.tasks.Nested
20 |
21 | /**
22 | * Simple data class to model additional options for the GitCommitTask.
23 | *
24 | * @author lreimer
25 | */
26 | class GitCommitOptions {
27 | @Input
28 | String message = ''
29 |
30 | @Input
31 | boolean all = true
32 | @Input
33 | boolean noVerify
34 | @Input
35 | boolean amend
36 |
37 | @Nested
38 | private GitUser author
39 | @Nested
40 | private GitUser committer
41 |
42 | /**
43 | * Set the author information.
44 | *
45 | * @param closure the configuration closure
46 | */
47 | void author(Closure closure) {
48 | this.author = new GitUser()
49 | closure.delegate = this.author
50 | closure()
51 | }
52 |
53 | /**
54 | * Return the author.
55 | *
56 | * @return the author, may be NULL if unset
57 | */
58 | GitUser getAuthor() {
59 | return this.author
60 | }
61 |
62 | /**
63 | * Set the committer information.
64 | *
65 | * @param closure the configuration closure
66 | */
67 | void committer(Closure closure) {
68 | this.committer = new GitUser()
69 | closure.delegate = this.committer
70 | closure()
71 | }
72 |
73 | /**
74 | * Return the committer.
75 | *
76 | * @return the committer, may be NULL
77 | */
78 | GitUser getCommitter() {
79 | return committer
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/seuac-chocolatey-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/chocolatey/StoreChocolateySeuacDbTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.chocolatey
17 |
18 | import de.qaware.seu.as.code.plugins.base.DatastoreProvider
19 | import de.qaware.seu.as.code.plugins.base.DatastoreProviderFactory
20 | import de.qaware.seu.as.code.plugins.base.SeuacDatastore
21 | import org.gradle.api.DefaultTask
22 | import org.gradle.api.artifacts.Dependency
23 | import org.gradle.api.tasks.Nested
24 | import org.gradle.api.tasks.OutputDirectory
25 | import org.gradle.api.tasks.TaskAction
26 |
27 | /**
28 | * This task will store the SEU-as-code configuration to the configured storage.
29 | */
30 | class StoreChocolateySeuacDbTask extends DefaultTask {
31 |
32 | @OutputDirectory
33 | File chocolateyBasePath
34 | @Nested
35 | SeuacDatastore datastore
36 |
37 | /**
38 | * Initialize the group and description for this task.
39 | */
40 | StoreChocolateySeuacDbTask() {
41 | group = 'SEU-as-code'
42 | description = 'Store the current SEU chocolatey software package configuration.'
43 | }
44 |
45 | /**
46 | * Stores the SEU-as-code database for the chocolatey software configuration.
47 | */
48 | @TaskAction
49 | void storeSeuacDb() {
50 | DatastoreProvider provider = DatastoreProviderFactory.instance.get(datastore)
51 | provider.init()
52 |
53 | project.configurations.choco.dependencies.each { Dependency d ->
54 | provider.storeDependency(d, [project.fileTree(new File("${chocolateyBasePath}/lib/${d.name}/"))], 'choco')
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/seuac-svn-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/svn/SvnUpdateTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.svn
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.testfixtures.ProjectBuilder
20 | import spock.lang.Specification
21 |
22 | import static org.hamcrest.Matchers.*
23 | import static spock.util.matcher.HamcrestSupport.expect
24 | import static spock.util.matcher.HamcrestSupport.that
25 |
26 | /**
27 | * Test specification to check the basic SvnUpdateTask behaviour.
28 | *
29 | * @author lreimer
30 | */
31 | class SvnUpdateTaskSpec extends Specification {
32 | static final String TEST_SVN_UPDATE = 'testSvnUpdate'
33 | Project project
34 |
35 | def setup() {
36 | project = ProjectBuilder.builder().build()
37 | }
38 |
39 | def "Define SvnUpdateTask"() {
40 | expect: "the SVN update task to be undefined"
41 | that project.tasks.findByName(TEST_SVN_UPDATE), is(nullValue())
42 |
43 | when: "we defined the tasks with dummy parameters"
44 | project.task(TEST_SVN_UPDATE, type: SvnUpdateTask) {
45 | directory = new File("build")
46 | username = 'user'
47 | password = 'pwd'
48 | }.doUpdate()
49 |
50 | then: "we find the taks and the parameters have been set correctly"
51 | SvnUpdateTask task = project.tasks.findByName(TEST_SVN_UPDATE)
52 | expect task, notNullValue()
53 | expect task.group, equalTo('Version Control')
54 | expect task.directory, notNullValue()
55 | expect task.username, equalTo('user')
56 | expect task.password, equalTo('pwd')
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/AbstractGitTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.eclipse.jgit.api.errors.GitAPIException
19 | import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider
20 | import org.gradle.api.DefaultTask
21 | import org.gradle.api.GradleException
22 | import org.gradle.api.tasks.Input
23 | import org.gradle.api.tasks.Internal
24 | import org.gradle.api.tasks.options.Option
25 | import org.gradle.api.tasks.OutputDirectory
26 |
27 | /**
28 | * Base class for all concrete Git tasks.
29 | *
30 | * @author lreimer
31 | */
32 | abstract class AbstractGitTask extends DefaultTask {
33 |
34 | @Option(option = "gitTimeout", description = "The Git command timeout.")
35 | @Internal
36 | protected int gitTimeout
37 |
38 | /**
39 | * Initialize task with group.
40 | */
41 | AbstractGitTask() {
42 | group = 'Version Control'
43 | }
44 |
45 | @OutputDirectory
46 | File directory
47 |
48 | @Input
49 | String username
50 | @Input
51 | String password
52 |
53 | protected def withExceptionHandling(String message, Closure c) {
54 | try {
55 | c()
56 | } catch (GitAPIException e) {
57 | throw new GradleException(message, e)
58 | } catch (IOException ioe) {
59 | throw new GradleException(message, ioe)
60 | }
61 | this
62 | }
63 |
64 | protected def always(Closure c) {
65 | c()
66 | }
67 |
68 | protected UsernamePasswordCredentialsProvider createCredentialsProvider() {
69 | new UsernamePasswordCredentialsProvider(username ?: '', password ?: '')
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/base/DatastoreProviderFactory.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.GradleException
19 |
20 | /**
21 | * The factory singleton to get PersistenceService instances for a given SeuacDatastore configuration.
22 | *
23 | * @author lreimer
24 | */
25 | @Singleton
26 | class DatastoreProviderFactory {
27 |
28 | private def providers = ['jdbc:h2': JdbcH2DatastoreProvider, 'file:mapdb': MapDbDatastoreProvider]
29 |
30 | private Map instances = [:]
31 |
32 | /**
33 | * Creates a suitable PersistenceService instance for the given data store config.
34 | *
35 | * @param datastore the SeuacDatastore configuration
36 | * @return a suitable persistence service
37 | */
38 | DatastoreProvider get(SeuacDatastore datastore) {
39 | if (instances[datastore.url] == null) {
40 | def providerClass = getProviderClass(datastore)
41 | instances[datastore.url] = providerClass.newInstance(datastore)
42 | }
43 | instances[datastore.url]
44 | }
45 |
46 | Class> getProviderClass(SeuacDatastore datastore) {
47 | def key = keyFor(datastore)
48 | def providerClass = providers[key]
49 | if (providerClass == null) throw new GradleException("Unsupported PersistenceService for $datastore.url")
50 | return providerClass
51 | }
52 |
53 | private String keyFor(SeuacDatastore datastore) {
54 | for (def key : providers.keySet()) {
55 | if (datastore.url.startsWith(key)) {
56 | return key
57 | }
58 | }
59 | return ""
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/credentials/CredentialsSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials
17 |
18 | import org.apache.commons.codec.binary.Base64
19 | import spock.lang.Specification
20 |
21 | import java.nio.charset.Charset
22 |
23 | /**
24 | * Spec to check proper functionality of the Credentials class.
25 | *
26 | * @author lreimer
27 | */
28 | class CredentialsSpec extends Specification {
29 | def "Check toSecret and fromSecret"() {
30 | given:
31 | def secret = new Credentials('Max', 'Mustermann').toSecret()
32 |
33 | when:
34 | def credentials = Credentials.fromSecret(secret)
35 |
36 | then:
37 | secret == '''{"username":"Max","password":"Mustermann"}'''
38 | credentials.username == 'Max'
39 | credentials.password == 'Mustermann'
40 | }
41 |
42 | def "Check invalid secret representation"() {
43 | when:
44 | Credentials.fromSecret("invalid")
45 |
46 | then:
47 | thrown(CredentialsException)
48 | }
49 |
50 | def "Check UTF-8 charset"() {
51 | expect:
52 | Charset.forName("UTF-8").name() == "UTF-8"
53 | }
54 |
55 | def "toSecret then fromSecret with Base64"() {
56 | given:
57 | def credential = new Credentials('Max', 'Mustermann')
58 | def secret64 = Base64.encodeBase64String(credential.toSecret().getBytes(Charset.forName("UTF-8")))
59 |
60 | when:
61 | def decoded = new String(Base64.decodeBase64(secret64), Charset.forName("UTF-8"))
62 | def fromSecret = Credentials.fromSecret(decoded)
63 |
64 | then:
65 | fromSecret.username == 'Max'
66 | fromSecret.password == 'Mustermann'
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitOptions.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import groovy.transform.PackageScope
19 |
20 | /**
21 | * The options configuration class for the different Git commands the plugin supports.
22 | * This allows to set additional command specific configuration options.
23 | *
24 | * @author lreimer
25 | */
26 | class GitOptions {
27 |
28 | @PackageScope
29 | final GitPullOptions pull = new GitPullOptions()
30 |
31 | @PackageScope
32 | final GitCloneOptions clone = new GitCloneOptions()
33 |
34 | @PackageScope
35 | final GitPushOptions push = new GitPushOptions()
36 |
37 | @PackageScope
38 | final GitCommitOptions commit = new GitCommitOptions()
39 |
40 | /**
41 | * Apply the closure to the GitPullOptions.
42 | *
43 | * @param closure the configuration closure
44 | */
45 | void pull(Closure closure) {
46 | closure.delegate = pull
47 | closure()
48 | }
49 |
50 | /**
51 | * Apply the closure to the GitCloneOptions.
52 | *
53 | * @param closure the configuration closure
54 | */
55 | void clone(Closure closure) {
56 | closure.delegate = clone
57 | closure()
58 | }
59 |
60 | /**
61 | * Apply the closure to the GitPushOptions.
62 | *
63 | * @param closure the configuration closure
64 | */
65 | void push(Closure closure) {
66 | closure.delegate = push
67 | closure()
68 | }
69 |
70 | /**
71 | * Apply the closure to the GitCommitOptions.
72 | *
73 | * @param closure the configuration closure
74 | */
75 | void commit(Closure closure) {
76 | closure.delegate = commit
77 | closure()
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/CreateAsciiBannerTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.testfixtures.ProjectBuilder
20 | import org.junit.Rule
21 | import org.junit.rules.TemporaryFolder
22 | import spock.lang.Specification
23 |
24 | import static de.qaware.seu.as.code.plugins.base.SeuacBanner.defaultBanner
25 |
26 | /**
27 | * Test specification for the CreateAsciiBannerTask functionality.
28 | *
29 | * @author lreimer
30 | */
31 | class CreateAsciiBannerTaskSpec extends Specification {
32 |
33 | Project project
34 | File seuHome
35 |
36 | @Rule
37 | TemporaryFolder folder = new TemporaryFolder()
38 |
39 | void setup() {
40 | project = ProjectBuilder.builder().build()
41 | seuHome = folder.newFolder()
42 | }
43 |
44 | def "Define CreateAsciiBannerTask and doCreateAsciiBanner"() {
45 | given: "a configured CreateAsciiBannerTask"
46 | CreateAsciiBannerTask task = project.task("createAsciiBanner", type: CreateAsciiBannerTask) {
47 | projectName = 'SEU-as-code'
48 | bannerFile = new File(seuHome, DEFAULT_FILENAME)
49 | settings = defaultBanner()
50 | } as CreateAsciiBannerTask
51 |
52 | when: "we create the ASCII banner"
53 | task.doCreateAsciiBanner()
54 |
55 | then: "we expect the banner file to exist with the correct content"
56 | notThrown(Exception)
57 | fileExists()
58 | fileEndsWith('QAware GmbH')
59 | }
60 |
61 | private boolean fileExists() {
62 | new File(seuHome, CreateAsciiBannerTask.DEFAULT_FILENAME).exists()
63 | }
64 |
65 | private boolean fileEndsWith(String content) {
66 | def lines = new File(seuHome, CreateAsciiBannerTask.DEFAULT_FILENAME).readLines()
67 | lines.get(lines.size() - 1).endsWith(content)
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/StoreSeuacDbTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.testfixtures.ProjectBuilder
20 | import spock.lang.Specification
21 |
22 | import static de.qaware.seu.as.code.plugins.base.SeuacDatastore.temporaryDatastore
23 |
24 | /**
25 | * Test specification for the StoreSeuacDbTask.
26 | *
27 | * @author lreimer
28 | */
29 | class StoreSeuacDbTaskSpec extends Specification {
30 |
31 | Project project
32 | SeuacDatastore defaultDatastore
33 | DatastoreProvider provider
34 |
35 | void setup() {
36 | project = ProjectBuilder.builder().build()
37 | project.repositories.flatDir {
38 | dirs new File(StoreSeuacDbTaskSpec.getResource("/").toURI())
39 | }
40 |
41 | project.configurations.create('software')
42 | project.dependencies.add('software', ':seuac-test:1.0.0@zip')
43 |
44 | project.configurations.create('home')
45 | project.dependencies.add('home', ':seuac-test:1.0.0@zip')
46 |
47 | defaultDatastore = temporaryDatastore()
48 | provider = new JdbcH2DatastoreProvider(defaultDatastore)
49 | }
50 |
51 | def "Define StoreSeuacDbTask and storeSeuacDb"() {
52 | given: "a configured StoreSeuacDbTask"
53 | StoreSeuacDbTask task = project.task("storeSeuacDb", type: StoreSeuacDbTask) {
54 | datastore = defaultDatastore
55 | } as StoreSeuacDbTask
56 |
57 | when: "we store the DB"
58 | task.storeSeuacDb()
59 |
60 | then: "the DB should contain all files for all configurations"
61 | notThrown(Exception)
62 | findAllFiles('software').size() == 3
63 | findAllFiles('home').size() == 3
64 | }
65 |
66 | Set findAllFiles(String c) {
67 | provider.findAllFiles(['null:seuac-test:1.0.0@zip'] as Set, c)
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/SeuacCredentialsPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | import org.gradle.api.Plugin;
19 | import org.gradle.api.Project;
20 |
21 | /**
22 | * SEU-as-code Credentials plugin.
23 | *
24 | * Provides the 'credentials' object to get credentials and the 'setStorage' task to set credentials.
25 | *
26 | * @author phxql
27 | */
28 | public class SeuacCredentialsPlugin implements Plugin {
29 | @Override
30 | public void apply(Project project) {
31 | SystemConsole console = new SystemConsole();
32 | CredentialsStorageFactory factory = new CredentialsStorageFactory.Default(project);
33 |
34 | // register the credentials configuration with the project
35 | CredentialsExtension extension = new CredentialsExtension();
36 | project.getExtensions().add(CredentialsExtension.NAME, extension);
37 |
38 | CredentialsProperty property = new CredentialsProperty(factory);
39 | project.getExtensions().getExtraProperties().set(CredentialsProperty.NAME, property);
40 |
41 | SetCredentialsTask setCredentialsTask = project.getTasks().create("setCredentials", SetCredentialsTask.class);
42 | initTask(setCredentialsTask, console, factory);
43 |
44 | ClearCredentialsTask clearCredentialsTask = project.getTasks().create("clearCredentials", ClearCredentialsTask.class);
45 | initTask(clearCredentialsTask, console, factory);
46 |
47 | DisplayCredentialsTask displayCredentialsTask = project.getTasks().create("displayCredentials", DisplayCredentialsTask.class);
48 | initTask(displayCredentialsTask, console, factory);
49 | }
50 |
51 | private void initTask(AbstractCredentialsTask task, SystemConsole console, CredentialsStorageFactory factory) {
52 | task.setConsole(console);
53 | task.setStorageFactory(factory);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/base/SeuacBanner.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.tasks.Input
19 |
20 | /**
21 | * Simple data type to represent the ASCII art banner configuration.
22 | *
23 | * @author lreimer
24 | */
25 | class SeuacBanner {
26 | @Input
27 | String font = 'slant'
28 | @Input
29 | String reflection = 'no'
30 | @Input
31 | String adjustment = 'center'
32 | @Input
33 | String stretch = 'yes'
34 | @Input
35 | int width = 80
36 |
37 | /**
38 | * Convenience setter for the font to use.
39 | *
40 | * @param aFont a sdupported font
41 | */
42 | void font(String aFont) {
43 | this.font = aFont
44 | }
45 |
46 | /**
47 | * Convenience setter for the reflection to use.
48 | *
49 | * @param aReflection the reflection, either yes or no
50 | */
51 | void reflection(String aReflection) {
52 | this.reflection = aReflection
53 | }
54 |
55 | /**
56 | * Convenience setter for the adjustment to use.
57 | *
58 | * @param theAdjustment the adjustment, either left or center or right
59 | */
60 | void adjustment(String theAdjustment) {
61 | this.adjustment = theAdjustment
62 | }
63 |
64 | /**
65 | * Convenience setter for the stretch to use.
66 | *
67 | * @param theStretch the stretch, either yes or no
68 | */
69 | void stretch(String theStretch) {
70 | this.stretch = theStretch
71 | }
72 |
73 | /**
74 | * Convenience setter for the width to use.
75 | *
76 | * @param theWidth the width
77 | */
78 | void width(int theWidth) {
79 | this.width = theWidth
80 | }
81 |
82 | /**
83 | * Factory method to create the default banner settings.
84 | *
85 | * @return the default banner settings
86 | */
87 | static SeuacBanner defaultBanner() {
88 | new SeuacBanner()
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/seuac-svn-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/svn/SvnRepository.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.svn
17 |
18 | /**
19 | * The SvnRepository class is the value holder object for named SVN domain objects.
20 | *
21 | * @author lreimer
22 | */
23 | class SvnRepository {
24 | final String name
25 | String url
26 | File directory
27 | String username
28 | String password
29 | String revision
30 |
31 | /**
32 | * Required to construct by name.
33 | *
34 | * @param name the repo name
35 | */
36 | SvnRepository(String name) {
37 | this.name = name
38 | }
39 |
40 | /**
41 | * Short hand method to assign the URL value.
42 | *
43 | * @param aUrl the URL
44 | */
45 | void url(String aUrl) {
46 | this.url = aUrl
47 | }
48 |
49 | /**
50 | * Short hand method to assign the directory name value.
51 | *
52 | * @param aDirectory the directory
53 | */
54 | void directory(String aDirectory) {
55 | this.directory = new File(aDirectory)
56 | }
57 |
58 | /**
59 | * Short hand method to assign the directory value.
60 | *
61 | * @param aDirectory the directory
62 | */
63 | void directory(File aDirectory) {
64 | this.directory = aDirectory
65 | }
66 |
67 | /**
68 | * Short hand method to assign the username value.
69 | *
70 | * @param aUsername the username
71 | */
72 | def void username(String aUsername) {
73 | this.username = aUsername
74 | }
75 |
76 | /**
77 | * Short hand method to assign the password value.
78 | *
79 | * @param aPassword the password
80 | */
81 | def void password(String aPassword) {
82 | this.password = aPassword
83 | }
84 |
85 | /**
86 | * Short hand method to assign the revision value.
87 | *
88 | * @param aRevision the revision
89 | */
90 | def void revision(String aRevision) {
91 | this.revision = aRevision
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/SeuacDatastoreSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import spock.lang.Specification
19 |
20 | import static org.hamcrest.Matchers.equalTo
21 | import static org.hamcrest.Matchers.notNullValue
22 | import static org.hamcrest.Matchers.startsWith
23 | import static spock.util.matcher.HamcrestSupport.expect
24 | import static spock.util.matcher.HamcrestSupport.that
25 |
26 | /**
27 | * Test specification for the SeuacDatastore conventation.
28 | *
29 | * @author lreimer
30 | */
31 | class SeuacDatastoreSpec extends Specification {
32 | SeuacDatastore datastore
33 |
34 | void setup() {
35 | datastore = new SeuacDatastore()
36 | }
37 |
38 | def "Validate temporary datastore"() {
39 | given: "a temporary data store"
40 | datastore = SeuacDatastore.temporaryDatastore()
41 |
42 | expect: "the default values"
43 | that datastore, notNullValue()
44 | that datastore.url, startsWith('jdbc:h2:')
45 | that datastore.user, equalTo('sa')
46 | that datastore.password, equalTo('sa')
47 | }
48 |
49 | def "Basic property setter assignment"() {
50 | when: "we initialize the data store using setters"
51 | datastore.url = 'url'
52 | datastore.user = 'user'
53 | datastore.password = 'password'
54 |
55 | then: "we expect the correct values"
56 | expect datastore.url, equalTo('url')
57 | expect datastore.user, equalTo('user')
58 | expect datastore.password, equalTo('password')
59 | }
60 |
61 | def "Basic property method assignment"() {
62 | when: "we initialize the data store using methods"
63 | datastore.url 'url'
64 | datastore.user 'user'
65 | datastore.password 'password'
66 |
67 | then: "we expect the correct values"
68 | expect datastore.url, equalTo('url')
69 | expect datastore.user, equalTo('user')
70 | expect datastore.password, equalTo('password')
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/credentials/SeuacCredentialsPluginSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.testfixtures.ProjectBuilder
20 | import spock.lang.Specification
21 |
22 | import static org.hamcrest.Matchers.notNullValue
23 | import static spock.util.matcher.HamcrestSupport.expect
24 |
25 | /**
26 | * Basic test specification for the {@link SeuacCredentialsPlugin}.
27 | *
28 | * @author lreimer
29 | */
30 | class SeuacCredentialsPluginSpec extends Specification {
31 |
32 | private Project project
33 |
34 | def setup() {
35 | this.project = ProjectBuilder.builder().build()
36 | }
37 |
38 | def "Apply the plugin"() {
39 | when: "the plugin is applied"
40 | project.apply plugin: 'seuac-credentials'
41 |
42 | then: "we expect to find the tasks and the extension to be configured"
43 | SetCredentialsTask setCredentialsTask = (SetCredentialsTask) project.tasks.findByName('setCredentials')
44 | ClearCredentialsTask clearCredentialsTask = (ClearCredentialsTask) project.tasks.findByName('clearCredentials')
45 | DisplayCredentialsTask displayCredentialsTask = (DisplayCredentialsTask) project.tasks.findByName('displayCredentials')
46 |
47 | def extension = project.getExtensions().getExtraProperties().get('credentials')
48 |
49 | expect setCredentialsTask, notNullValue()
50 | expect setCredentialsTask.getConsole(), notNullValue()
51 | expect setCredentialsTask.getStorage(), notNullValue()
52 |
53 | expect clearCredentialsTask, notNullValue()
54 | expect clearCredentialsTask.getConsole(), notNullValue()
55 | expect clearCredentialsTask.getStorage(), notNullValue()
56 |
57 | expect displayCredentialsTask, notNullValue()
58 | expect displayCredentialsTask.getConsole(), notNullValue()
59 | expect displayCredentialsTask.getStorage(), notNullValue()
60 |
61 | expect extension, notNullValue()
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/CredentialsProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | /**
19 | * An instance of the class will be registered as extra property of the Grtadle project.
20 | * It mainly serves as a secure wrapper around the credential storage and provides a
21 | * convenient DSL way to access a credential for a service.
22 | *
23 | *
24 | * credentials {
25 | * // use array type access to credentials via service name
26 | * username project.credentials['nexus'].username
27 | * password project.credentials['nexus'].password
28 | *
29 | * // use getter access to credentials via service name
30 | * username project.credentials.get('nexus').username
31 | * password project.credentials.get('nexus').password
32 | *
33 | * // or use string interpolation
34 | * username "${credentials['nexus'].username}"
35 | * password "${credentials['nexus'].password}"
36 | * }
37 | *
38 | *
39 | * @author lreimer
40 | */
41 | public class CredentialsProperty {
42 | /**
43 | * Name of the credentials property in the build script.
44 | */
45 | static final String NAME = "credentials";
46 |
47 | private final CredentialsStorageFactory storageFactory;
48 |
49 | /**
50 | * Initialize the credentials property with a storage factory.
51 | *
52 | * @param storageFactory the storage factory
53 | */
54 | public CredentialsProperty(CredentialsStorageFactory storageFactory) {
55 | this.storageFactory = storageFactory;
56 | }
57 |
58 | /**
59 | * Returns the credentials with the given service name.
60 | *
61 | * @param service the service name
62 | * @return the credentials or Credentials.EMPTY if not found
63 | */
64 | public Credentials get(String service) {
65 | CredentialsStorage storage = storageFactory.create();
66 | Credentials credentials = storage.findCredentials(service);
67 | return (credentials != null) ? credentials : Credentials.EMPTY;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/base/StoreSeuacDbTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.DefaultTask
19 | import org.gradle.api.artifacts.Dependency
20 | import org.gradle.api.file.FileTree
21 | import org.gradle.api.tasks.Nested
22 | import org.gradle.api.tasks.TaskAction
23 |
24 | /**
25 | * This task will store the SEU-as-code configuration to the configured storage.
26 | */
27 | class StoreSeuacDbTask extends DefaultTask {
28 |
29 | @Nested
30 | SeuacDatastore datastore
31 |
32 | /**
33 | * Initialize the group and description for this task.
34 | */
35 | StoreSeuacDbTask() {
36 | group = 'SEU-as-code'
37 | description = 'Store the current SEU software package configuration.'
38 | }
39 |
40 | /**
41 | * Stores the SEU-as-code database for the current software configuration.
42 | */
43 | @TaskAction
44 | void storeSeuacDb() {
45 | DatastoreProvider provider = DatastoreProviderFactory.instance.get(datastore)
46 | provider.reset()
47 |
48 | project.configurations.software.dependencies.each { Dependency d ->
49 | List files = dependencyFiles(project.configurations.software.files(d))
50 | provider.storeDependency(d, files, 'software')
51 | }
52 |
53 | project.configurations.home.dependencies.each { Dependency d ->
54 | List trees = dependencyFiles(project.configurations.home.files(d))
55 | provider.storeDependency(d, trees, 'home')
56 | }
57 | }
58 |
59 | /**
60 | * Returns the FileTree of all given dependency files. Unzips all dependencies
61 | * and filters META-INF/ folders.
62 | *
63 | * @param files a set of files
64 | * @return a filtered FileTree
65 | */
66 | List dependencyFiles(Set files) {
67 | files.collect {
68 | project.zipTree(it).matching {
69 | include '*'
70 | exclude 'META-INF/'
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/homebrew/InstallHomebrewTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.homebrew
17 |
18 | import de.undercouch.gradle.tasks.download.DownloadAction
19 | import org.gradle.api.DefaultTask
20 | import org.gradle.api.file.FileCopyDetails
21 | import org.gradle.api.tasks.Input
22 | import org.gradle.api.tasks.TaskAction
23 | import org.slf4j.Logger
24 | import org.slf4j.LoggerFactory
25 |
26 | import java.nio.file.Paths
27 |
28 | /**
29 | * A simple task thats installs the latest version of Homebrew into the SEU.
30 | *
31 | * The target path can be configured.
32 | */
33 | class InstallHomebrewTask extends DefaultTask {
34 | private static final Logger LOGGER = LoggerFactory.getLogger(InstallHomebrewTask.class)
35 |
36 | @Input
37 | File homebrewBasePath
38 |
39 | InstallHomebrewTask() {
40 | group = 'SEU-as-code'
41 | description = 'Installs Homebrew into the SEU.'
42 | }
43 |
44 | @TaskAction
45 | void doInstall() {
46 | if (homebrewBasePath.exists()) {
47 | LOGGER.warn('Skip install of homebrew. {} exists', homebrewBasePath)
48 | return
49 | }
50 | LOGGER.info('Installing homebrew into {}', homebrewBasePath)
51 | homebrewBasePath.mkdirs()
52 |
53 | def tmpTar = File.createTempFile('homebrewInst', '.zip')
54 | tmpTar.deleteOnExit()
55 |
56 | def download = new DownloadAction(project)
57 | download.src 'https://github.com/Homebrew/brew/archive/master.zip'
58 | download.dest tmpTar
59 | download.execute()
60 |
61 | project.copy {
62 | from project.zipTree(tmpTar)
63 | includeEmptyDirs = false
64 | into homebrewBasePath
65 | eachFile { FileCopyDetails details ->
66 | def path = Paths.get details.path
67 | if (path.getNameCount() > 1) {
68 | details.path = details.path - (path.subpath(0, 1).toString() + '/')
69 | }
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/CreateSeuacLayoutTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.testfixtures.ProjectBuilder
20 | import org.junit.Rule
21 | import org.junit.rules.TemporaryFolder
22 | import spock.lang.Specification
23 |
24 | import static de.qaware.seu.as.code.plugins.base.SeuacLayout.defaultLayout
25 | import static org.hamcrest.Matchers.is
26 | import static org.hamcrest.Matchers.notNullValue
27 | import static spock.util.matcher.HamcrestSupport.expect
28 |
29 | /**
30 | * Basic test specification for the CreateSeuacLayoutTask.
31 | *
32 | * @author lreimer
33 | */
34 | class CreateSeuacLayoutTaskSpec extends Specification {
35 | static final String TEST_CREATE_SEUAC_LAYOUT = 'testCreateSeuacLayout'
36 |
37 | Project project
38 | File seuHome
39 | SeuacLayout testLayout
40 |
41 | @Rule
42 | TemporaryFolder folder = new TemporaryFolder()
43 |
44 | def setup() {
45 | project = ProjectBuilder.builder().build()
46 | seuHome = folder.newFolder()
47 | testLayout = defaultLayout(seuHome)
48 | }
49 |
50 | def "Define CreateSeuacLayoutTask and mkdirs"() {
51 | given: "a configured CreateSeuacLayoutTask"
52 | CreateSeuacLayoutTask task = project.task(TEST_CREATE_SEUAC_LAYOUT, type: CreateSeuacLayoutTask) {
53 | layout = testLayout
54 | } as CreateSeuacLayoutTask
55 |
56 | when: "we create the layout directories"
57 | task.mkdirs()
58 |
59 | then: "we expect all directories to exist"
60 | notThrown(IOException)
61 | expect project.tasks.testCreateSeuacLayout, notNullValue()
62 |
63 | expect testLayout.codebase.exists(), is(true)
64 | expect testLayout.docbase.exists(), is(true)
65 | expect testLayout.home.exists(), is(true)
66 | expect testLayout.repository.exists(), is(true)
67 | expect testLayout.software.exists(), is(true)
68 | expect testLayout.temp.exists(), is(true)
69 |
70 | expect task.outputs.files.files.size(), is(6)
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/DetroySeuTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.testfixtures.ProjectBuilder
20 | import org.junit.Rule
21 | import org.junit.rules.TemporaryFolder
22 | import spock.lang.Specification
23 |
24 | import static de.qaware.seu.as.code.plugins.base.SeuacDatastore.temporaryDatastore
25 | import static de.qaware.seu.as.code.plugins.base.SeuacLayout.defaultLayout
26 | import static org.hamcrest.Matchers.is
27 | import static spock.util.matcher.HamcrestSupport.expect
28 |
29 | /**
30 | * Basic test specification for the DestroySeuTask.
31 | *
32 | * @author lreimer
33 | */
34 | class DetroySeuTaskSpec extends Specification {
35 | static final String TEST_DESTROY_SEU = 'testDestroySeu'
36 |
37 | @Rule
38 | TemporaryFolder folder = new TemporaryFolder()
39 |
40 | Project project
41 | File seuHome
42 |
43 | SeuacLayout testLayout
44 | SeuacDatastore testDatastore
45 |
46 | def setup() {
47 | project = ProjectBuilder.builder().build()
48 | seuHome = folder.newFolder()
49 | testLayout = defaultLayout(seuHome)
50 | testLayout.mkdirs()
51 |
52 | testDatastore = temporaryDatastore()
53 | }
54 |
55 | def "Define DestroySeuTask and destroy a SEU layout"() {
56 | given: "a configured DestroySeuTask"
57 | DestroySeuTask task = project.task(TEST_DESTROY_SEU, type: DestroySeuTask) {
58 | layout = testLayout
59 | datastore = testDatastore
60 | } as DestroySeuTask
61 |
62 | when: "we destroy the SEU"
63 | task.destroy()
64 |
65 | then: "we expect no directories to exist any more"
66 | notThrown(IOException)
67 |
68 | expect testLayout.codebase.exists(), is(false)
69 | expect testLayout.docbase.exists(), is(false)
70 | expect testLayout.home.exists(), is(false)
71 | expect testLayout.repository.exists(), is(false)
72 | expect testLayout.software.exists(), is(false)
73 | expect testLayout.temp.exists(), is(false)
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/seuac-platform-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/platform/SeuacPlatformPluginSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.platform
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.testfixtures.ProjectBuilder
20 | import spock.lang.Specification
21 |
22 | import static org.hamcrest.Matchers.equalTo
23 | import static org.hamcrest.Matchers.notNullValue
24 | import static spock.util.matcher.HamcrestSupport.expect
25 |
26 | /**
27 | * Test specification for the SeuacPlatformPlugin.
28 | *
29 | * @author lreimer
30 | */
31 | class SeuacPlatformPluginSpec extends Specification {
32 |
33 | Project project
34 |
35 | def setup() {
36 | project = ProjectBuilder.builder().build()
37 | }
38 |
39 | def "Apply SeuacPlatformPlugin and check tasks"() {
40 | setup: "the plugin, apply it and configure the convention"
41 | project.apply plugin: 'seuac-platform'
42 | project.apply plugin: 'java'
43 |
44 | project.platform {
45 | win {
46 | dependencies {
47 | testImplementation group: 'junit', name: 'junit', version: '4.12'
48 | }
49 | }
50 | mac {
51 | dependencies {
52 | testImplementation group: 'junit', name: 'junit', version: '4.12'
53 | }
54 | }
55 | unix {
56 | dependencies {
57 | testImplementation group: 'junit', name: 'junit', version: '4.12'
58 | }
59 | }
60 | }
61 |
62 | when: "we evaluate the project"
63 | project.evaluate()
64 |
65 | then: "the extentions and all tasks are registered"
66 | expect project.extensions.findByName(PlatformExtension.NAME), notNullValue()
67 |
68 | expect project.extensions.extraProperties.get('osFamily'), equalTo(Platform.current().osFamily)
69 | expect project.extensions.extraProperties.get('osClassifier'), equalTo(Platform.current().osClassifier)
70 | expect project.extensions.extraProperties.get('osArch'), equalTo(Platform.current().osArch)
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/PersistenceServiceFactorySpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.GradleException
19 | import spock.lang.Specification
20 |
21 | import static de.qaware.seu.as.code.plugins.base.SeuacDatastore.temporaryDatastore
22 | import static org.hamcrest.Matchers.instanceOf
23 | import static org.hamcrest.Matchers.notNullValue
24 | import static spock.util.matcher.HamcrestSupport.expect
25 |
26 | /**
27 | * Test specification for the PersistenceServiceFactory.
28 | *
29 | * @author lreimer
30 | */
31 | class PersistenceServiceFactorySpec extends Specification {
32 | SeuacDatastore datastore
33 |
34 | void setup() {
35 | datastore = new SeuacDatastore()
36 | }
37 |
38 | def "Create a JDBC H2 PersistenceService instance"() {
39 | given: "a default H2 data store"
40 | datastore = temporaryDatastore()
41 |
42 | when: "we get the data store provider instance"
43 | DatastoreProvider service = DatastoreProviderFactory.instance.get(datastore)
44 |
45 | then: "we expect the correct H2 data store provider"
46 | expect service, notNullValue()
47 | expect service, instanceOf(JdbcH2DatastoreProvider)
48 | }
49 |
50 | def "Create a MapDB PersistenceService instance"() {
51 | given: "a MapDP data store URL"
52 | datastore.url = 'file:mapdb:./build/seuac.dbmap'
53 |
54 | when: "we get the data store provider instance"
55 | DatastoreProvider service = DatastoreProviderFactory.instance.get(datastore)
56 |
57 | then: "we expect the correct MapDB data store provider"
58 | expect service, notNullValue()
59 | expect service, instanceOf(MapDbDatastoreProvider)
60 | }
61 |
62 | def "Create unknown PersistenceService instance"() {
63 | given: "an unsupported datastore URL"
64 | datastore.url = 'unknown:db:seuac'
65 |
66 | when: "we get the data store provider instance"
67 | DatastoreProviderFactory.instance.get(datastore)
68 |
69 | then: "we expect a GradleException"
70 | thrown(GradleException)
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitPullTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.eclipse.jgit.api.Git
19 | import org.eclipse.jgit.api.PullCommand
20 | import org.eclipse.jgit.lib.Constants
21 | import org.eclipse.jgit.lib.TextProgressMonitor
22 | import org.eclipse.jgit.merge.MergeStrategy
23 | import org.gradle.api.tasks.Input
24 | import org.gradle.api.tasks.Internal
25 | import org.gradle.api.tasks.Nested
26 | import org.gradle.api.tasks.TaskAction
27 | import org.gradle.api.tasks.options.Option
28 |
29 | /**
30 | * The task implementation to perform a Git pull operation.
31 | *
32 | * @author lreimer
33 | */
34 | class GitPullTask extends AbstractGitTask {
35 |
36 | @Input
37 | String remote = Constants.DEFAULT_REMOTE_NAME
38 | @Internal
39 | MergeStrategy strategy = MergeStrategy.RECURSIVE
40 |
41 | @Option(option = "rebase", description = "Perform rebase after fetching.")
42 | @Input
43 | boolean rebase = false
44 |
45 | @TaskAction
46 | def doPull() {
47 | Git gitRepo = null
48 | withExceptionHandling('Could not pull from remote Git repository.') {
49 | gitRepo = Git.open(directory)
50 |
51 | PullCommand pull = gitRepo.pull()
52 | pull.setRemote(remote)
53 | pull.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
54 | pull.setCredentialsProvider(createCredentialsProvider())
55 |
56 | // set the additional options
57 | pull.setStrategy(strategy)
58 | pull.setRebase(rebase)
59 | pull.setTimeout(gitTimeout)
60 |
61 | pull.call()
62 | } always {
63 | if (gitRepo) {
64 | gitRepo.close()
65 | }
66 | }
67 | }
68 |
69 | /**
70 | * Apply the task specific options to this instance.
71 | *
72 | * @param options the task options
73 | */
74 | void applyOptions(GitPullOptions options) {
75 | this.rebase = options.rebase
76 | this.strategy = MergeStrategy.get(options.strategy.name())
77 | this.gitTimeout = options.timeout
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | Third-party patches are essential for keeping SEU-as-code great. We want to keep
4 | it as easy as possible to contribute changes that get things working in your
5 | environment. There are a few guidelines that we need contributors to follow so
6 | that we can have a chance of keeping on top of things.
7 |
8 | ## Getting Started
9 |
10 | * Make sure you have a [GitHub account](https://github.com/signup/free)
11 | * Submit a ticket for your issue, assuming one does not already exist.
12 | * Clearly describe the issue including steps to reproduce when it is a bug.
13 | * Make sure you fill in the earliest version that you know has the issue.
14 | * Fork the repository on GitHub
15 |
16 | ## Making Changes
17 |
18 | * Create a topic branch from where you want to base your work.
19 | * This is usually the master branch.
20 | * Only target release branches if you are certain your fix must be on that
21 | branch.
22 | * To quickly create a topic branch based on master; `git checkout -b
23 | fix/master/my_contribution master`. Please avoid working directly on the
24 | `master` branch.
25 | * Make commits of logical units.
26 | * Check for unnecessary whitespace with `git diff --check` before committing.
27 | * Make sure your commit messages are in the proper format.
28 |
29 | ````
30 | (#1234) Fixed some issue in the code.
31 |
32 | The first line is a real life imperative statement with a ticket number
33 | from our issue tracker. The body describes the behavior without the patch,
34 | why this is a problem, and how the patch fixes the problem when applied.
35 | ````
36 |
37 | * Make sure you have added the necessary tests for your changes.
38 | * Run _all_ the tests to assure nothing else was accidentally broken.
39 |
40 | ## Making Trivial Changes
41 |
42 | ### Documentation
43 |
44 | For changes of a trivial nature to comments and documentation, it is not
45 | always necessary to create a new ticket on GitHub. In this case, it is
46 | appropriate to start the first line of a commit with '(No issue)' instead of
47 | an issue number.
48 |
49 | ## Submitting Changes
50 |
51 | * Push your changes to a topic branch in your fork of the repository.
52 | * Submit a pull request to the repository in the puppetlabs organization.
53 | * Update your Jira ticket to mark that you have submitted code and are ready for it to be reviewed (Status: Ready for Review).
54 | * Include a link to the pull request in the ticket.
55 | * The core team looks at Pull Requests on a regular basis.
56 | * After feedback has been given we expect responses within two weeks. After two
57 | weeks we may close the pull request if it isn't showing any activity.
58 |
59 | # Additional Resources
60 |
61 | * [General GitHub documentation](https://help.github.com/)
62 | * [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
63 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/homebrew/StoreBrewSeuacDbTaskTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.homebrew
17 |
18 | import de.qaware.seu.as.code.plugins.base.DatastoreProvider
19 | import de.qaware.seu.as.code.plugins.base.JdbcH2DatastoreProvider
20 | import de.qaware.seu.as.code.plugins.base.SeuacDatastore
21 | import org.gradle.api.Project
22 | import org.gradle.testfixtures.ProjectBuilder
23 | import org.junit.Rule
24 | import org.junit.rules.TemporaryFolder
25 | import spock.lang.Requires
26 | import spock.lang.Specification
27 |
28 | import static de.qaware.seu.as.code.plugins.base.SeuacDatastore.temporaryDatastore
29 |
30 | /**
31 | * Unit test for the {@link StoreBrewSeuacDbTask}.
32 | */
33 | @Requires({ os.macOs })
34 | class StoreBrewSeuacDbTaskTest extends Specification {
35 |
36 | @Rule
37 | TemporaryFolder folder = new TemporaryFolder()
38 |
39 | Project project
40 | SeuacDatastore defaultDatastore
41 | DatastoreProvider provider
42 | File home
43 |
44 | void setup() {
45 | project = ProjectBuilder.builder().build()
46 | home = folder.newFolder()
47 |
48 | def maven3Dir = new File(home, 'homebrew/Cellar/maven3/')
49 | maven3Dir.mkdirs()
50 | new File(maven3Dir, 'test').createNewFile()
51 |
52 | defaultDatastore = temporaryDatastore()
53 | provider = new JdbcH2DatastoreProvider(defaultDatastore)
54 | }
55 |
56 | def "StoreBrewSeuacDb"() {
57 | setup: "the plugin, apply it and configure the convention"
58 | project.apply plugin: 'seuac-homebrew'
59 | project.dependencies.add('brew', ':maven3:')
60 |
61 | StoreBrewSeuacDbTask task = project.task("storeBrewSeuacDb", type: StoreBrewSeuacDbTask) {
62 | homebrewBasePath = new File(home, 'homebrew')
63 | datastore = defaultDatastore
64 | } as StoreBrewSeuacDbTask
65 | when: "we evaluate the task"
66 | task.storeSeuacDb()
67 |
68 | then: "the DB should contain all files for all configurations"
69 | notThrown(Exception)
70 |
71 | provider.findAllFiles(['null:maven3:null'] as Set, 'brew').size() == 1
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/homebrew/InstallHomebrewTaskTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.homebrew
17 |
18 | import de.qaware.seu.as.code.plugins.base.SeuacLayout
19 | import org.gradle.api.Project
20 | import org.gradle.testfixtures.ProjectBuilder
21 | import org.junit.Rule
22 | import org.junit.rules.TemporaryFolder
23 | import spock.lang.Requires
24 | import spock.lang.Specification
25 |
26 | import static de.qaware.seu.as.code.plugins.base.SeuacLayout.defaultLayout
27 |
28 | /**
29 | * Unit test for the {@link InstallHomebrewTask}
30 | */
31 | @Requires({ os.macOs })
32 | class InstallHomebrewTaskTest extends Specification {
33 |
34 | @Rule
35 | TemporaryFolder folder = new TemporaryFolder()
36 |
37 | File home
38 | SeuacLayout defaultLayout
39 | Project project
40 |
41 | void setup() {
42 | project = ProjectBuilder.builder().build()
43 |
44 | home = folder.newFolder()
45 | defaultLayout = defaultLayout(home)
46 |
47 | project.apply plugin: 'seuac-homebrew'
48 | project.dependencies.add('brew', ':maven3:')
49 |
50 | project.seuAsCode {
51 | seuHome = home
52 | projectName = 'Test SEU'
53 | layout = defaultLayout
54 | }
55 | }
56 |
57 | def "Install HomeBrew"() {
58 | setup:
59 | InstallHomebrewTask task = project.task("installHomebrewTask", type: InstallHomebrewTask) {
60 | homebrewBasePath = new File(home, 'homebrew')
61 | } as InstallHomebrewTask
62 | when:
63 | task.doInstall()
64 | then:
65 | assert new File(home, 'homebrew/bin/brew').exists()
66 | }
67 |
68 | def "Try to install but HomeBrew is already installed"() {
69 | setup:
70 | def homebrewPath = new File(home, 'homebrew')
71 | homebrewPath.mkdirs()
72 | InstallHomebrewTask task = project.task("installHomebrewTask", type: InstallHomebrewTask) {
73 | homebrewBasePath = homebrewPath
74 | } as InstallHomebrewTask
75 | when:
76 | task.doInstall()
77 | then:
78 | assert !new File(home, 'homebrew/bin/brew').exists()
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/CredentialsStorageFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | import de.qaware.seu.as.code.plugins.credentials.linux.SecretServiceAPICredentialsStorage;
19 | import de.qaware.seu.as.code.plugins.credentials.mac.KeychainCredentialsStorage;
20 | import de.qaware.seu.as.code.plugins.credentials.win.PropertyCredentialsStorage;
21 | import org.gradle.api.Project;
22 |
23 | /**
24 | * A factory method implementation to create {@link CredentialsStorage} instances.
25 | *
26 | * @author lreimer
27 | */
28 | interface CredentialsStorageFactory {
29 | /**
30 | * Create a configured CredentialsStorage instance for the given project.
31 | *
32 | * @return a CredentialsStorage instance
33 | */
34 | CredentialsStorage create();
35 |
36 | /**
37 | * The default storage implementation.
38 | */
39 | class Default implements CredentialsStorageFactory {
40 |
41 | private final Project project;
42 |
43 | /**
44 | * Initialize the factory with a Gradle project.
45 | *
46 | * @param project the project
47 | */
48 | Default(Project project) {
49 | this.project = project;
50 | }
51 |
52 | @Override
53 | public CredentialsStorage create() {
54 | CredentialsExtension extension = project.getExtensions().getByType(CredentialsExtension.class);
55 | project.getLogger().info("Using {}", extension);
56 |
57 | CredentialsStorage storage;
58 | if (OperatingSystem.isWindows()) {
59 | storage = new PropertyCredentialsStorage(project, extension);
60 | } else if (OperatingSystem.isMacOs()) {
61 | storage = new KeychainCredentialsStorage(extension);
62 | } else if (OperatingSystem.isLinux()) {
63 | storage = new SecretServiceAPICredentialsStorage();
64 | } else {
65 | project.getLogger().warn("Unsupported OS. All credential tasks will be disabled.");
66 | storage = new CredentialsStorage.None();
67 | }
68 | return storage;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/seuac-chocolatey-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/chocolatey/StoreChocolateySeuacDbTaskTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.chocolatey
17 |
18 | import de.qaware.seu.as.code.plugins.base.DatastoreProvider
19 | import de.qaware.seu.as.code.plugins.base.JdbcH2DatastoreProvider
20 | import de.qaware.seu.as.code.plugins.base.SeuacDatastore
21 | import org.gradle.api.Project
22 | import org.gradle.testfixtures.ProjectBuilder
23 | import org.junit.Rule
24 | import org.junit.rules.TemporaryFolder
25 | import spock.lang.Requires
26 | import spock.lang.Specification
27 |
28 | import static de.qaware.seu.as.code.plugins.base.SeuacDatastore.temporaryDatastore
29 |
30 | /**
31 | * Unit test for the {@link StoreChocolateySeuacDbTaskTest}.
32 | */
33 | @Requires({ os.windows })
34 | class StoreChocolateySeuacDbTaskTest extends Specification {
35 |
36 | @Rule
37 | TemporaryFolder folder = new TemporaryFolder()
38 |
39 | Project project
40 | SeuacDatastore defaultDatastore
41 | DatastoreProvider provider
42 | File home
43 |
44 | void setup() {
45 | project = ProjectBuilder.builder().build()
46 | home = folder.newFolder()
47 |
48 | def helmDir = new File(home, 'chocolatey/lib/kubernetes-helm/')
49 | helmDir.mkdirs()
50 | new File(helmDir, 'test').createNewFile()
51 |
52 | defaultDatastore = temporaryDatastore()
53 | provider = new JdbcH2DatastoreProvider(defaultDatastore)
54 | }
55 |
56 | def StoreChocolateySeuacDb() {
57 | setup: "the plugin, apply it and configure the convention"
58 | project.apply plugin: 'seuac-chocolatey'
59 | project.dependencies.add('choco', ':kubernetes-helm:')
60 |
61 | StoreChocolateySeuacDbTask task = project.task("storeChocoSeuacDb", type: StoreChocolateySeuacDbTask) {
62 | chocolateyBasePath = new File(home, 'chocolatey')
63 | datastore = defaultDatastore
64 | } as StoreChocolateySeuacDbTask
65 | when: "we evaluate the task"
66 | task.storeSeuacDb()
67 |
68 | then: "the DB should contain all files for all configurations"
69 | notThrown(Exception)
70 |
71 | provider.findAllFiles(['null:kubernetes-helm:null'] as Set, 'choco').size() == 1
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/homebrew/HomebrewPluginTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.homebrew
17 |
18 | import de.qaware.seu.as.code.plugins.base.SeuacExtension
19 | import de.qaware.seu.as.code.plugins.base.SeuacLayout
20 | import org.gradle.api.Project
21 | import org.gradle.testfixtures.ProjectBuilder
22 | import org.junit.Rule
23 | import org.junit.rules.TemporaryFolder
24 | import spock.lang.Requires
25 | import spock.lang.Specification
26 |
27 | import static de.qaware.seu.as.code.plugins.base.SeuacLayout.defaultLayout
28 | import static org.hamcrest.Matchers.hasItem
29 | import static org.hamcrest.Matchers.notNullValue
30 | import static spock.util.matcher.HamcrestSupport.expect
31 |
32 | /**
33 | * Unit test for the {@link HomebrewPlugin}.
34 | */
35 | @Requires({ os.macOs })
36 | class HomebrewPluginTest extends Specification {
37 |
38 | @Rule
39 | TemporaryFolder folder = new TemporaryFolder()
40 |
41 | File home
42 | SeuacLayout defaultLayout
43 | Project project
44 |
45 | void setup() {
46 | project = ProjectBuilder.builder().build()
47 |
48 | home = folder.newFolder()
49 | defaultLayout = defaultLayout(home)
50 | }
51 |
52 | def "Apply SeuacHomeBrewPlugin and check tasks"() {
53 | setup: "the plugin, apply it and configure the convention"
54 | project.apply plugin: 'seuac-homebrew'
55 |
56 | project.dependencies.add('brew', ':maven3:')
57 |
58 | project.seuAsCode {
59 | seuHome = home
60 | projectName = 'Test SEU'
61 | layout = defaultLayout
62 | }
63 | when: "we evaluate the project"
64 | project.evaluate()
65 |
66 | then: "the extentions and all tasks are registered"
67 | expect project.extensions.findByName(SeuacExtension.NAME), notNullValue()
68 |
69 | expect project.tasks.applySoftware, notNullValue()
70 | expect project.tasks.storeSeuacDb, notNullValue()
71 |
72 | expect project.tasks.installBrew, notNullValue()
73 | expect project.tasks.bootstrapSeu.dependsOn, hasItem(project.tasks.installBrew)
74 | expect project.tasks.applyBrewSoftware, notNullValue()
75 | expect project.tasks.storeBrewSeuacDb, notNullValue()
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/git/GitStatusTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.gradle.api.GradleException
19 | import org.gradle.api.Project
20 | import org.gradle.testfixtures.ProjectBuilder
21 | import org.junit.Rule
22 | import org.junit.rules.TemporaryFolder
23 | import spock.lang.Specification
24 |
25 | import static org.hamcrest.Matchers.*
26 | import static spock.util.matcher.HamcrestSupport.expect
27 | import static spock.util.matcher.HamcrestSupport.that
28 |
29 | /**
30 | * Basic test specification for the GitStatusTask.
31 | *
32 | * @author lreimer
33 | */
34 | class GitStatusTaskSpec extends Specification {
35 | static final String TEST_GIT_STATUS = 'testGitStatus'
36 |
37 | @Rule
38 | TemporaryFolder folder = new TemporaryFolder()
39 |
40 | Project project
41 | File directory
42 |
43 | def setup() {
44 | project = ProjectBuilder.builder().build()
45 | directory = folder.newFolder()
46 | }
47 |
48 | def "Define GitStatusTask"() {
49 | expect: "the status task to be undefined"
50 | that project.tasks.findByName(TEST_GIT_STATUS), is(nullValue())
51 |
52 | when: "we define and configure the task on the project"
53 | project.task(TEST_GIT_STATUS, type: GitStatusTask) {
54 | directory = this.directory
55 | }
56 |
57 | then: "we expect to find the task correctly configured"
58 | GitStatusTask task = project.tasks.findByName(TEST_GIT_STATUS) as GitStatusTask
59 | expect task, notNullValue()
60 | expect task.group, equalTo('Version Control')
61 | expect task.directory, notNullValue()
62 | }
63 |
64 | def "Invoke doStatus"() {
65 | expect: "the status task to be undefined"
66 | that project.tasks.findByName(TEST_GIT_STATUS), is(nullValue())
67 |
68 | when: "we define and invoke the status task"
69 | GitStatusTask task = project.task(TEST_GIT_STATUS, type: GitStatusTask) {
70 | directory = this.directory
71 | } as GitStatusTask
72 | task.doStatus()
73 |
74 | then: "the task is defined by threw an exception"
75 | expect project.tasks.testGitStatus, notNullValue()
76 | thrown(GradleException)
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/base/ApplyConfigurationTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.testfixtures.ProjectBuilder
20 | import org.junit.Rule
21 | import org.junit.rules.TemporaryFolder
22 | import spock.lang.Specification
23 |
24 | import static de.qaware.seu.as.code.plugins.base.SeuacDatastore.temporaryDatastore
25 |
26 | /**
27 | * Test specification for the ApplyConfigurationTask functionality.
28 | *
29 | * @author lreimer
30 | */
31 | class ApplyConfigurationTaskSpec extends Specification {
32 |
33 | Project project
34 | File seuHome
35 | SeuacDatastore defaultDatastore
36 | File repo
37 | DatastoreProvider provider
38 |
39 | @Rule
40 | TemporaryFolder folder = new TemporaryFolder()
41 |
42 | def setup() {
43 | project = ProjectBuilder.builder().build()
44 | project.configurations.create('software')
45 |
46 | repo = new File(ApplyConfigurationTaskSpec.getResource("/").toURI())
47 | project.repositories.flatDir {
48 | dirs repo
49 | }
50 | project.dependencies.add('software', ':seuac-test:1.0.0@zip')
51 |
52 | seuHome = folder.newFolder()
53 |
54 | defaultDatastore = temporaryDatastore()
55 |
56 | provider = new JdbcH2DatastoreProvider(defaultDatastore)
57 | provider.reset()
58 | }
59 |
60 | def "Define ApplyConfigurationTask and doApply"() {
61 | given: "a configured ApplyConfigurationTask"
62 | ApplyConfigurationTask task = project.task("applySoftware", type: ApplyConfigurationTask) {
63 | source = project.configurations.software
64 | target = seuHome
65 | datastore = defaultDatastore
66 | withEmptyDirs = false
67 | } as ApplyConfigurationTask
68 |
69 | when: "we apply the software configuration"
70 | task.doApply()
71 |
72 | then: "we expect that the following files exist"
73 | notThrown(Exception)
74 | fileExists('ascii-art.txt')
75 | fileExists('set-env.cmd')
76 | fileExists('start-console.bat')
77 | }
78 |
79 | private boolean fileExists(String filename) {
80 | return new File(seuHome, filename).exists()
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/seuac-svn-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/svn/AbstractSvnTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.svn
17 |
18 | import org.gradle.api.DefaultTask
19 | import org.gradle.api.GradleException
20 | import org.gradle.api.tasks.Input
21 | import org.gradle.api.tasks.OutputDirectory
22 | import org.tmatesoft.svn.core.SVNException
23 | import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager
24 | import org.tmatesoft.svn.core.wc.ISVNOptions
25 | import org.tmatesoft.svn.core.wc.SVNClientManager
26 | import org.tmatesoft.svn.core.wc.SVNUpdateClient
27 | import org.tmatesoft.svn.core.wc.SVNWCUtil
28 |
29 | /**
30 | * Base class for all concrete SVN tasks.
31 | *
32 | * @author lreimer
33 | */
34 | abstract class AbstractSvnTask extends DefaultTask {
35 |
36 | /**
37 | * Initialize task with group.
38 | */
39 | AbstractSvnTask() {
40 | group = 'Version Control'
41 | }
42 |
43 | @OutputDirectory
44 | File directory
45 |
46 | @Input
47 | String password
48 |
49 | @Input
50 | String username
51 |
52 | @Input
53 | String revision
54 |
55 | /**
56 | * Factory method to create a new SVN update client instance. If username and password
57 | * are provided they will be used for authentication.
58 | *
59 | * @param username the SVN username, default is empty
60 | * @param password the SVN password, default is empty
61 | * @return a new SVNUpdateClient instance
62 | */
63 | protected def SVNUpdateClient createSvnUpdateClient(def username = '', def password = '') {
64 | ISVNOptions options = SVNWCUtil.createDefaultOptions(true)
65 | ISVNAuthenticationManager authManager = null
66 | if (username) {
67 | authManager = SVNWCUtil.createDefaultAuthenticationManager(username, password)
68 | }
69 |
70 | SVNClientManager clientManager = SVNClientManager.newInstance(options, authManager)
71 | SVNUpdateClient updateClient = clientManager.updateClient;
72 | updateClient.ignoreExternals = false
73 |
74 | updateClient
75 | }
76 |
77 | protected def withExceptionHandling(Closure c) {
78 | try {
79 | c()
80 | } catch (SVNException e) {
81 | throw new GradleException(e.message, e)
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/Credentials.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | import java.util.regex.Matcher;
19 | import java.util.regex.Pattern;
20 |
21 | /**
22 | * A simple credentials POJO that contains username and password.
23 | *
24 | * @author reimer
25 | */
26 | public final class Credentials {
27 | /**
28 | * An empty credentials instance with no username and no password.
29 | */
30 | public static final Credentials EMPTY = new Credentials("", "");
31 |
32 | private final String username;
33 | private final String password;
34 |
35 | /**
36 | * Initialize the instance with a username and password value.
37 | *
38 | * @param username the username
39 | * @param password the password
40 | */
41 | public Credentials(String username, String password) {
42 | this.username = username;
43 | this.password = password;
44 | }
45 |
46 | public String getUsername() {
47 | return username;
48 | }
49 |
50 | public String getPassword() {
51 | return password;
52 | }
53 |
54 | /**
55 | * Special method to get a Credential representation to be used as secret when
56 | * securely storing the data.
57 | *
58 | * @return the secret representation
59 | */
60 | public String toSecret() {
61 | final StringBuilder sb = new StringBuilder("{");
62 | sb.append("\"username\":\"").append(username).append("\"");
63 | sb.append(',');
64 | sb.append("\"password\":\"").append(password).append("\"");
65 | sb.append('}');
66 | return sb.toString();
67 | }
68 |
69 | /**
70 | * Factory method to create Credentials from their secret representation.
71 | *
72 | * @param secret the secret representation
73 | * @return the Credential
74 | */
75 | public static Credentials fromSecret(String secret) {
76 | Pattern pattern = Pattern.compile("\\{\"username\":\"(.*)\",\"password\":\"(.*)\"\\}");
77 | Matcher matcher = pattern.matcher(secret);
78 |
79 | if (matcher.matches()) {
80 | return new Credentials(matcher.group(1), matcher.group(2));
81 | } else {
82 | throw new CredentialsException("No valid secret representation.");
83 | }
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/credentials/CredentialsPropertySpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials
17 |
18 | import spock.lang.Specification
19 |
20 | /**
21 | * Basic test spec to check the extension property to access the credentials.
22 | *
23 | * @author lreimer
24 | */
25 | class CredentialsPropertySpec extends Specification {
26 |
27 | CredentialsStorageFactory storageFactory = Mock(CredentialsStorageFactory)
28 | CredentialsStorage storage = Mock(CredentialsStorage)
29 |
30 | def "Get Credentials via typed get method"() {
31 | setup:
32 | storageFactory.create() >> storage
33 | storage.findCredentials('nexus') >> new Credentials('Max', 'Mustermann')
34 | def extension = new CredentialsProperty(storageFactory)
35 |
36 | when:
37 | def credentials = extension.get('nexus')
38 |
39 | then:
40 | credentials?.username == 'Max'
41 | credentials?.password == 'Mustermann'
42 | }
43 |
44 | def "Get Credentials via index operator"() {
45 | setup:
46 | storageFactory.create() >> storage
47 | storage.findCredentials('nexus') >> new Credentials('Max', 'Mustermann')
48 | def extension = new CredentialsProperty(storageFactory)
49 |
50 | when:
51 | def credentials = extension['nexus']
52 |
53 | then:
54 | credentials?.username == 'Max'
55 | credentials?.password == 'Mustermann'
56 | }
57 |
58 | def "Get Credentials using GString replacement"() {
59 | setup:
60 | storageFactory.create() >> storage
61 | storage.findCredentials('nexus') >> new Credentials('Max', 'Mustermann')
62 | def extension = new CredentialsProperty(storageFactory)
63 |
64 | when:
65 | def credentials = "${extension['nexus'].username} ${extension['nexus'].password}"
66 |
67 | then:
68 | credentials == "Max Mustermann"
69 | }
70 |
71 | def "Get unknown empty Credentials"() {
72 | setup:
73 | storageFactory.create() >> storage
74 | storage.findCredentials('nexus') >> null
75 | def extension = new CredentialsProperty(storageFactory)
76 |
77 | when:
78 | def credentials = extension.get('nexus')
79 |
80 | then:
81 | credentials == Credentials.EMPTY
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/git/GitInitTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.gradle.api.GradleException
19 | import org.gradle.api.Project
20 | import org.gradle.testfixtures.ProjectBuilder
21 | import org.junit.Rule
22 | import org.junit.rules.TemporaryFolder
23 | import spock.lang.Specification
24 |
25 | import static org.hamcrest.Matchers.*
26 | import static spock.util.matcher.HamcrestSupport.expect
27 | import static spock.util.matcher.HamcrestSupport.that
28 |
29 | /**
30 | * Basic test specification for the GitInitTask.
31 | *
32 | * @author lreimer
33 | */
34 | class GitInitTaskSpec extends Specification {
35 | static final String TEST_GIT_INIT = 'testGitInit'
36 |
37 | @Rule
38 | TemporaryFolder folder = new TemporaryFolder()
39 |
40 | Project project
41 | File directory
42 |
43 | def setup() {
44 | project = ProjectBuilder.builder().build()
45 | directory = folder.newFolder()
46 | }
47 |
48 | def "Define GitInitTask"() {
49 | expect: "the init task to be undefined"
50 | that project.tasks.findByName(TEST_GIT_INIT), is(nullValue())
51 |
52 | when: "we defined and configure the init task"
53 | project.task(TEST_GIT_INIT, type: GitInitTask) {
54 | directory = this.directory
55 | }
56 |
57 | then: "we expect to find the task correctly configured"
58 | GitInitTask task = project.tasks.findByName(TEST_GIT_INIT) as GitInitTask
59 | expect task, notNullValue()
60 | expect task.group, equalTo('Version Control')
61 | expect task.directory, notNullValue()
62 | }
63 |
64 | def "Invoke doInit"() {
65 | expect: "the init task to be undefined"
66 | that project.tasks.findByName(TEST_GIT_INIT), is(nullValue())
67 |
68 | when: "we create and invoke the init task"
69 | project.configurations.create('jgit')
70 | GitInitTask task = project.task(TEST_GIT_INIT, type: GitInitTask) {
71 | directory = this.directory
72 | } as GitInitTask
73 | task.doInit()
74 |
75 | then: "the task is defined and a new repo has been initialized"
76 | expect project.tasks.testGitInit, notNullValue()
77 | notThrown(GradleException)
78 | expect new File(directory, ".git").exists(), is(true)
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitPushTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.eclipse.jgit.api.Git
19 | import org.eclipse.jgit.api.PushCommand
20 | import org.eclipse.jgit.lib.Constants
21 | import org.gradle.api.tasks.Input
22 | import org.gradle.api.tasks.options.Option
23 | import org.gradle.api.tasks.TaskAction
24 |
25 | /**
26 | * The task implementation to perform a Git push operation.
27 | *
28 | * @author lreimer
29 | */
30 | class GitPushTask extends AbstractGitTask {
31 |
32 | @Input
33 | String remote = Constants.DEFAULT_REMOTE_NAME
34 |
35 | @Option(option = "dry-run", description = "Set if push operation should be a dry run.")
36 | @Input
37 | boolean dryRun = false
38 |
39 | @Option(option = "all", description = "Push all branches.")
40 | @Input
41 | boolean pushAll = false
42 |
43 | @Option(option = "tags", description = "Push all tags.")
44 | @Input
45 | boolean pushTags = false
46 |
47 | @Option(option = "force", description = "Set force for push operations.")
48 | @Input
49 | boolean force
50 |
51 | @TaskAction
52 | def doPush() {
53 | Git gitRepo = null
54 | withExceptionHandling('Could not push to remote Git repository.') {
55 | gitRepo = Git.open(directory)
56 |
57 | PushCommand push = gitRepo.push()
58 | push.setDryRun(dryRun).setRemote(remote).setOutputStream(System.out)
59 | push.setCredentialsProvider(createCredentialsProvider())
60 | if (pushAll) {
61 | push.setPushAll()
62 | }
63 | if (pushTags) {
64 | push.setPushTags()
65 | }
66 | push.setTimeout(gitTimeout)
67 | push.setForce(force)
68 |
69 | push.call()
70 | } always {
71 | if (gitRepo) {
72 | gitRepo.close()
73 | }
74 | }
75 | }
76 |
77 | /**
78 | * Apply the task specific options to this instance.
79 | *
80 | * @param options the task options
81 | */
82 | void applyOptions(GitPushOptions options) {
83 | this.dryRun = options.dryRun
84 | this.pushAll = options.pushAll
85 | this.pushTags = options.pushTags
86 | this.gitTimeout = options.timeout
87 | this.force = options.force
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/seuac-chocolatey-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/chocolatey/ChocolateyPluginTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.chocolatey
17 |
18 | import de.qaware.seu.as.code.plugins.base.SeuacExtension
19 | import de.qaware.seu.as.code.plugins.base.SeuacLayout
20 | import org.gradle.api.Project
21 | import org.gradle.testfixtures.ProjectBuilder
22 | import org.junit.Rule
23 | import org.junit.rules.TemporaryFolder
24 | import spock.lang.Requires
25 | import spock.lang.Specification
26 |
27 | import static org.hamcrest.Matchers.hasItem
28 | import static org.hamcrest.Matchers.notNullValue
29 | import static spock.util.matcher.HamcrestSupport.expect
30 |
31 | /**
32 | * Unit test for the {@link ChocolateyPlugin}.
33 | */
34 | @Requires({ os.windows })
35 | class ChocolateyPluginTest extends Specification {
36 |
37 | @Rule
38 | TemporaryFolder folder = new TemporaryFolder()
39 |
40 | File home
41 | SeuacLayout defaultLayout
42 | Project project
43 |
44 | void setup() {
45 | project = ProjectBuilder.builder().build()
46 |
47 | home = folder.newFolder()
48 | defaultLayout = SeuacLayout.defaultLayout(home)
49 | }
50 |
51 | def "Apply SeuacChocolateyPlugin and check tasks"() {
52 | setup: "the plugin, apply it and configure the convention"
53 | project.apply plugin: 'seuac-chocolatey'
54 |
55 | project.dependencies.add('choco', ':kubernetes-helm:')
56 |
57 | project.seuAsCode {
58 | seuHome = home
59 | projectName = 'Test SEU'
60 | layout = defaultLayout
61 | }
62 | when: "we evaluate the project"
63 | project.evaluate()
64 |
65 | then: "the extentions and all tasks are registered"
66 | expect project.extensions.findByName(SeuacExtension.NAME), notNullValue()
67 |
68 | expect project.tasks.applySoftware, notNullValue()
69 | expect project.tasks.storeSeuacDb, notNullValue()
70 |
71 | expect project.tasks.installNetFrameworkIfMissing, notNullValue()
72 | expect project.tasks.installChoco, notNullValue()
73 | expect project.tasks.installChoco.dependsOn, hasItem(project.tasks.installNetFrameworkIfMissing)
74 | expect project.tasks.bootstrapSeu.dependsOn, hasItem(project.tasks.installChoco)
75 | expect project.tasks.applyChocoSoftware, notNullValue()
76 | expect project.tasks.storeChocoSeuacDb, notNullValue()
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitCloneTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.eclipse.jgit.api.CloneCommand
19 | import org.eclipse.jgit.api.Git
20 | import org.eclipse.jgit.lib.Repository
21 | import org.gradle.api.tasks.options.Option
22 | import org.gradle.api.tasks.Input
23 | import org.gradle.api.tasks.TaskAction
24 |
25 | /**
26 | * The task implementation to perform a Git clone.
27 | *
28 | * @author lreimer
29 | */
30 | class GitCloneTask extends AbstractGitTask {
31 | @Input
32 | String url
33 | @Input
34 | String branch
35 | @Input
36 | boolean singleBranch
37 |
38 | @Input
39 | boolean cloneAllBranches
40 | @Input
41 | boolean cloneSubmodules
42 |
43 | @Option(option = "no-checkout", description = "Do not checkout branch after clone.")
44 | @Input
45 | boolean noCheckout
46 |
47 | @TaskAction
48 | def doClone() {
49 | CloneCommand clone = null
50 | Repository repository = null
51 |
52 | withExceptionHandling('Could not clone Git repository.') {
53 | clone = Git.cloneRepository()
54 |
55 | clone.setURI(url).setDirectory(directory).setBranch(branch).setBare(false)
56 | clone.setCredentialsProvider(createCredentialsProvider())
57 |
58 | if (singleBranch && branch.startsWith("refs/")) {
59 | clone.cloneAllBranches = false
60 | clone.branchesToClone = [branch]
61 | } else {
62 | clone.setCloneAllBranches(cloneAllBranches)
63 | }
64 |
65 | // set the additional options
66 | clone.setNoCheckout(noCheckout)
67 | clone.setCloneSubmodules(cloneSubmodules)
68 | clone.setTimeout(gitTimeout)
69 |
70 | repository = clone.call().getRepository()
71 | } always {
72 | if (repository) {
73 | repository.close()
74 | }
75 | }
76 | }
77 |
78 | /**
79 | * Apply the task specific options to this instance.
80 | *
81 | * @param options the task options
82 | */
83 | void applyOptions(GitCloneOptions options) {
84 | this.singleBranch = options.singleBranch
85 | this.noCheckout = options.noCheckout
86 | this.gitTimeout = options.timeout
87 | this.cloneAllBranches = options.cloneAllBranches
88 | this.cloneSubmodules = options.cloneSubmodules
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/SystemConsole.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | import java.io.BufferedReader;
19 | import java.io.Console;
20 | import java.io.IOException;
21 | import java.io.InputStreamReader;
22 |
23 | /**
24 | * Supports I/O opperations.
25 | */
26 | public class SystemConsole {
27 |
28 | /**
29 | * Reads a line from the console.
30 | *
31 | * @param prompt the command line prompt
32 | * @param args any arguments for the prompt
33 | * @return the line read from the console
34 | */
35 | public String readLine(String prompt, Object... args) {
36 | Console console = System.console();
37 | if (console != null) {
38 | return console.readLine(prompt, args);
39 | } else {
40 | System.out.format(prompt, args);
41 | try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
42 | return br.readLine();
43 | } catch (IOException e) {
44 | throw new CredentialsException("Unable to read line from System.in", e);
45 | }
46 | }
47 | }
48 |
49 | /**
50 | * Reads a password from the console.
51 | *
52 | * @param prompt the command line prompt
53 | * @return the password read from the console
54 | */
55 | public char[] readPassword(String prompt) {
56 | Console console = System.console();
57 | if (console != null) {
58 | return console.readPassword(prompt);
59 | } else {
60 | System.out.format(prompt);
61 | try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
62 | return br.readLine().toCharArray();
63 | } catch (IOException e) {
64 | throw new CredentialsException("Unable to read password from System.in", e);
65 | }
66 | }
67 | }
68 |
69 | /**
70 | * Output the given format string to the current system console. In case
71 | * not console is attached (Gradle daemon) then SYSTEM_OUT is used.
72 | *
73 | * @param fmt the format string to output
74 | * @param args any message arguments
75 | */
76 | public void format(String fmt, Object... args) {
77 | Console console = System.console();
78 | if (console != null) {
79 | console.format(fmt, args);
80 | } else {
81 | System.out.format(fmt, args);
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/OperatingSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | /**
19 | * Enum to represent the supported operating systems. Gradle has an internal API we
20 | * could have used but we didn' want to so we implemented it ourselves.
21 | *
22 | * @author lreimer
23 | */
24 | public enum OperatingSystem {
25 | LINUX, WINDOWS, MAC_OS;
26 |
27 | /**
28 | * Returns the current operating system we are running on.
29 | *
30 | * @return the current Operating system
31 | */
32 | public static OperatingSystem current() {
33 | return forOsName(System.getProperty("os.name"));
34 | }
35 |
36 | /**
37 | * Get the matching {@link OperatingSystem} instance for the given name.
38 | * If the name is not supported than this method returns NULL.
39 | *
40 | * @param name the OS name
41 | * @return the OperatingSystem or NULL
42 | */
43 | public static OperatingSystem forOsName(final String name) {
44 | String osName = name.toLowerCase();
45 | if (osName.contains("windows")) {
46 | return WINDOWS;
47 | } else if (osName.contains("mac os x") || osName.contains("darwin") || osName.contains("osx")) {
48 | return MAC_OS;
49 | } else if (osName.equals("linux")) {
50 | return LINUX;
51 | } else {
52 | return null;
53 | }
54 | }
55 |
56 | /**
57 | * Convenience method to check of we are on MacOS.
58 | *
59 | * @return true if on MacOS, otherwise false
60 | */
61 | public static boolean isMacOs() {
62 | return OperatingSystem.current() == MAC_OS;
63 | }
64 |
65 | /**
66 | * Convenience method to check if we are on Windows.
67 | *
68 | * @return true if on Windows, otherwise false
69 | */
70 | public static boolean isWindows() {
71 | return OperatingSystem.current() == WINDOWS;
72 | }
73 |
74 | /**
75 | * Convenience method to check if we are on Linux.
76 | *
77 | * @return true if on Linux, otherwise false
78 | */
79 | public static boolean isLinux() {
80 | return OperatingSystem.current() == LINUX;
81 | }
82 |
83 |
84 | /**
85 | * Convenience method to check if the OS is supported.
86 | *
87 | * @return true if on Windows, MacOS or Linux, otherwise false
88 | */
89 | public static boolean isSupported() {
90 | return OperatingSystem.current() != null;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/git/GitRepositorySpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import spock.lang.Specification
19 |
20 | /**
21 | * The simple Spock spec for the GitRepository.
22 | *
23 | * @author lreimer
24 | */
25 | class GitRepositorySpec extends Specification {
26 |
27 | GitRepository repository
28 |
29 | def setup() {
30 | repository = new GitRepository('test')
31 | }
32 |
33 | def "Initialize URL by setter and method"() {
34 | when: "we set the URL"
35 | repository.url = "http://localhost"
36 | then: "we expect the value"
37 | repository.url == "http://localhost"
38 |
39 | when: "we assign the URL"
40 | repository.url "http://localhost"
41 | then: "we expect the value"
42 | repository.url == "http://localhost"
43 | }
44 |
45 | def "Initialize the branch by setter and method"() {
46 | when: "we set the branch"
47 | repository.branch = 'HEAD'
48 | then: "we expect the value"
49 | repository.branch == 'HEAD'
50 |
51 | when: "we assign the branch"
52 | repository.branch 'HEAD'
53 | then: "we expect the value"
54 | repository.branch == 'HEAD'
55 | }
56 |
57 | def "Initialize the directory by setter and method"() {
58 | when: "we set the directory"
59 | repository.directory = new File('build')
60 | then: "we expect the value"
61 | repository.directory == new File('build')
62 |
63 | when: "we assign the directory"
64 | repository.directory new File('build')
65 | then: "we expect the value"
66 | repository.directory == new File('build')
67 | }
68 |
69 | def "Initialize the username by setter and method"() {
70 | when: "we set the username"
71 | repository.username = 'test'
72 | then: "we expect the value"
73 | repository.username == 'test'
74 |
75 | when: "we set the username"
76 | repository.username 'test'
77 | then: "we expect the value"
78 | repository.username == 'test'
79 | }
80 |
81 | def "Initialize the password by setter and method"() {
82 | when: "we set the password"
83 | repository.password = 'test'
84 | then: "we expect the value"
85 | repository.password == 'test'
86 |
87 | when: "we set the password"
88 | repository.password 'test'
89 | then: "we expect the value"
90 | repository.password == 'test'
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/git/GitCommitTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.eclipse.jgit.api.CommitCommand
19 | import org.eclipse.jgit.api.Git
20 | import org.gradle.api.tasks.Input
21 | import org.gradle.api.tasks.Nested
22 | import org.gradle.api.tasks.options.Option
23 | import org.gradle.api.tasks.TaskAction
24 |
25 | /**
26 | * The task implementation to perform a Git commit.
27 | *
28 | * @author lreimer
29 | */
30 | class GitCommitTask extends AbstractGitTask {
31 |
32 | @Option(option = "message", description = "The commit message.")
33 | @Input
34 | String message = ''
35 |
36 | @Option(option = "all", description = "Automatically stage files that have been modified and deleted.")
37 | @Input
38 | boolean all = true
39 |
40 | @Option(option = "no-verify", description = "Bypasses the pre-commit and commit-msg hooks.")
41 | @Input
42 | boolean noVerify
43 |
44 | @Option(option = "amend", description = "Replace the tip of the current branch by creating a new commit.")
45 | @Input
46 | boolean amend
47 |
48 | @Nested
49 | GitUser committer
50 | @Nested
51 | GitUser author
52 |
53 | @TaskAction
54 | def doCommit() {
55 | Git gitRepo = null
56 | withExceptionHandling('Could not commit changes to Git repository.') {
57 | gitRepo = Git.open(directory)
58 |
59 | CommitCommand commit = gitRepo.commit()
60 | commit.setMessage(message)
61 |
62 | // set committer and author if set
63 | if (committer != null) {
64 | commit.setCommitter(committer.username, committer.email)
65 | }
66 | if (author != null) {
67 | commit.setAuthor(author.username, author.email)
68 | }
69 |
70 | // set the options
71 | commit.setAll(all).setAmend(amend).setNoVerify(noVerify)
72 |
73 | commit.call()
74 | } always {
75 | if (gitRepo) {
76 | gitRepo.close()
77 | }
78 | }
79 | }
80 |
81 | /**
82 | * Apply the task specific options to this instance.
83 | *
84 | * @param options the task options
85 | */
86 | void applyOptions(GitCommitOptions options) {
87 | this.message = options.message
88 | this.all = options.all
89 | this.noVerify = options.noVerify
90 | this.amend = options.amend
91 | this.committer = options.committer
92 | this.author = options.author
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/base/ApplyConfigurationTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import org.gradle.api.DefaultTask
19 | import org.gradle.api.artifacts.Configuration
20 | import org.gradle.api.artifacts.Dependency
21 | import org.gradle.api.tasks.Input
22 | import org.gradle.api.tasks.Nested
23 | import org.gradle.api.tasks.OutputDirectory
24 | import org.gradle.api.tasks.TaskAction
25 |
26 | /**
27 | * The main task to apply a software configuration it a SEU. This includes installing new
28 | * and removing old software.
29 | *
30 | * @author lreimer
31 | */
32 | class ApplyConfigurationTask extends DefaultTask {
33 |
34 | @Nested
35 | Configuration source
36 | @OutputDirectory
37 | File target
38 | @Input
39 | boolean withEmptyDirs = true
40 | @Nested
41 | SeuacDatastore datastore
42 |
43 | /**
44 | * Initialize the group for this task.
45 | */
46 | ApplyConfigurationTask() {
47 | group = 'SEU-as-code'
48 | description = 'Apply the given configuration to the SEU.'
49 | }
50 |
51 | /**
52 | * Apply the configuration source to the target directory. Checks with the datastore for any obsolete
53 | * dependencies, these will be removed. Then it finds all newly incoming deps and unpacks these to the
54 | * configured target directory.
55 | */
56 | @TaskAction
57 | void doApply() {
58 | DatastoreProvider provider = DatastoreProviderFactory.instance.get(datastore)
59 | provider.init()
60 |
61 | // first we find all obsolete dependencies and remove associated files
62 | Set obsoleteDeps = provider.findAllObsoleteDeps(source.dependencies, source.name)
63 | Set obsoleteFiles = provider.findAllFiles(obsoleteDeps, source.name)
64 | deleteObsoleteFile(obsoleteFiles)
65 |
66 | Set incomingDeps = provider.findAllIncomingDeps(source.dependencies, source.name)
67 | copyIncomingDeps(incomingDeps)
68 | }
69 |
70 | private void copyIncomingDeps(Set incomingDeps) {
71 | project.copy {
72 | from {
73 | source.copy {
74 | incomingDeps.contains(it)
75 | }.collect {
76 | project.zipTree(it)
77 | }
78 | }
79 | into target
80 | includeEmptyDirs = withEmptyDirs
81 | }
82 | }
83 |
84 | private void deleteObsoleteFile(Set obsoleteFiles) {
85 | obsoleteFiles.each { project.delete "$target/$it" }
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/seu-as-code/seu-as-code.plugins)
2 | [](https://coveralls.io/github/seu-as-code/seu-as-code.plugins?branch=master)
3 | [ ](https://bintray.com/seu-as-code/gradle-plugins/seuac-homebrew-plugin/_latestVersion)
4 | [](https://javadocio-badges.herokuapp.com/de.qaware.seu.as.code/seuac-homebrew-plugin)
5 | [](https://waffle.io/seu-as-code/seu-as-code.plugins)
6 | [](https://waffle.io/seu-as-code/seu-as-code.plugins)
7 | [](https://github.com/seu-as-code/seu-as-code.plugins/blob/master/LICENSE)
8 |
9 | # SEU-as-code HomeBrew Plugin
10 |
11 | A grade plugin for handling home brew packages inside a seu-as-code. Provides basic tasks to apply the current `brew`
12 | configuation to the seu.
13 |
14 | ## Usage
15 |
16 | Build script snippet for use in all Gradle versions, using the Bintray Maven repository:
17 | ```groovy
18 | buildscript {
19 | repositories {
20 | mavenCentral()
21 | maven {
22 | url 'https://dl.bintray.com/seu-as-code/gradle-plugins'
23 | }
24 | }
25 | dependencies {
26 | classpath 'de.qaware.seu.as.code:seuac-homebrew-plugin:1.3.0'
27 | }
28 | }
29 |
30 | apply plugin: 'de.qaware.seu.as.code.homebrew'
31 | ```
32 |
33 | Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
34 | ```groovy
35 | plugins {
36 | id 'de.qaware.seu.as.code.homebrew' version '1.3.0'
37 | }
38 | ```
39 | ## Tasks
40 |
41 | The plugin defines the following tasks:
42 |
43 | Task name | Depends on | Type | Description
44 | --- | --- | --- | ---
45 | `installBrew` | - | `InstallHomebrewTask` | Installs the homebrew environment into the seu
46 | `applyBrewSoftware` | `applySoftware` | `ApplyBrewSoftwareTask` | Applies the current brew configuration. This will remove, update and install all brew dependencies.
47 | `storeBrewSeuacDb` | `storeSeuacDb` | `StoreBrewSeuacDbTask` | Store the current HomeBrew SEU software package configuration.
48 |
49 | ## Example
50 | This short example will install Git SCM, Apache Maven and Apache Subversion into the seu using home brew.
51 | ```groovy
52 | plugins {
53 | id 'de.qaware.seu.as.code.homebrew' version '1.3.0'
54 | }
55 |
56 | dependencies {
57 | // Install via brew
58 | brew ':git:'
59 | brew ':maven:'
60 | brew ':subversion:'
61 |
62 | // Install via brew as cask
63 | cask ':minishift:'
64 | }
65 | ```
66 | ## Maintainer
67 |
68 | - Christian Fritz (@chrfritz)
69 | - M.-Leander Reimer (@lreimer)
70 |
71 | ## License
72 |
73 | This software is provided under the Apache License, Version 2.0 license. See the `LICENSE` file for details.
74 |
--------------------------------------------------------------------------------
/seuac-svn-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/svn/SvnCheckoutTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.svn
17 |
18 | import org.gradle.api.GradleException
19 | import org.gradle.api.Project
20 | import org.gradle.testfixtures.ProjectBuilder
21 | import spock.lang.Specification
22 |
23 | import static org.hamcrest.Matchers.*
24 | import static spock.util.matcher.HamcrestSupport.expect
25 | import static spock.util.matcher.HamcrestSupport.that
26 |
27 | /**
28 | * Test specification to check the basic SvnCheckoutTask behaviour.
29 | *
30 | * @author lreimer
31 | */
32 | class SvnCheckoutTaskSpec extends Specification {
33 | static final String TEST_SVN_CHECKOUT = 'testSvnCheckout'
34 | Project project
35 |
36 | def setup() {
37 | project = ProjectBuilder.builder().build()
38 | }
39 |
40 | def "Define SvnCheckoutTask"() {
41 | expect: "the SVN checkout task to be undefined"
42 | that project.tasks.findByName(TEST_SVN_CHECKOUT), is(nullValue())
43 |
44 | when: "we defined the tasks with dummy parameters"
45 | project.task(TEST_SVN_CHECKOUT, type: SvnCheckoutTask) {
46 | url = 'http://www.qaware.de/development'
47 | directory = new File("build")
48 | username = 'user'
49 | password = 'pwd'
50 | revision = 'rev'
51 | }
52 |
53 | then: "we find the taks and the parameters have been set correctly"
54 | SvnCheckoutTask task = project.tasks.findByName(TEST_SVN_CHECKOUT)
55 | expect task, notNullValue()
56 | expect task.group, equalTo('Version Control')
57 | expect task.url, equalTo('http://www.qaware.de/development')
58 | expect task.directory, notNullValue()
59 | expect task.username, equalTo('user')
60 | expect task.password, equalTo('pwd')
61 | expect task.revision, equalTo('rev')
62 | }
63 |
64 | def "Execute SvnCheckoutTask with wrong URL"() {
65 | expect: "the SVN checkout task to be undefined"
66 | that project.tasks.findByName(TEST_SVN_CHECKOUT), is(nullValue())
67 |
68 | when: "we defined the tasks with a wrong URL"
69 | SvnCheckoutTask task = project.task(TEST_SVN_CHECKOUT, type: SvnCheckoutTask) {
70 | url = 'wrongUrl'
71 | directory = new File("build")
72 | username = 'user'
73 | password = 'pwd'
74 | }
75 |
76 | and: "we perform a SVN checkout"
77 | task.doCheckout()
78 |
79 | then: "the task is defined but we receive a GradleException"
80 | expect project.tasks.findByName(TEST_SVN_CHECKOUT), notNullValue()
81 | thrown(GradleException)
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/git/GitPullTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.gradle.api.GradleException
19 | import org.gradle.api.Project
20 | import org.gradle.testfixtures.ProjectBuilder
21 | import org.junit.Rule
22 | import org.junit.rules.TemporaryFolder
23 | import spock.lang.Specification
24 |
25 | import static org.hamcrest.Matchers.*
26 | import static spock.util.matcher.HamcrestSupport.expect
27 | import static spock.util.matcher.HamcrestSupport.that
28 |
29 | /**
30 | * Basic test specification for the GitPullTask.
31 | *
32 | * @author lreimer
33 | */
34 | class GitPullTaskSpec extends Specification {
35 | static final String TEST_GIT_PULL = 'testGitPull'
36 |
37 | @Rule
38 | TemporaryFolder folder = new TemporaryFolder()
39 |
40 | Project project
41 | File directory
42 |
43 | def setup() {
44 | project = ProjectBuilder.builder().build()
45 | directory = folder.newFolder()
46 | }
47 |
48 | def "Define GitPullTask"() {
49 | given:
50 | def options = new GitPullOptions()
51 |
52 | expect: "the pull task to be undefined"
53 | that project.tasks.findByName(TEST_GIT_PULL), is(nullValue())
54 |
55 | when: "we we defined and configure the task"
56 | def task = (GitPullTask) project.task(TEST_GIT_PULL, type: GitPullTask) {
57 | directory = this.directory
58 | username = 'user'
59 | password = 'secret'
60 | remote = 'test'
61 | }
62 | task.applyOptions(options)
63 | task = (GitPullTask) project.tasks.findByName(TEST_GIT_PULL)
64 |
65 | then: "we expect to find the task correctly configured"
66 |
67 | expect task, notNullValue()
68 | expect task.group, equalTo('Version Control')
69 | expect task.remote, equalTo('test')
70 | expect task.username, equalTo('user')
71 | expect task.password, equalTo('secret')
72 | expect task.directory, notNullValue()
73 |
74 | task.rebase == options.rebase
75 | task.gitTimeout == options.timeout
76 | }
77 |
78 | def "Invoke doPull"() {
79 | expect: "the pull task to be undefined"
80 | that project.tasks.findByName(TEST_GIT_PULL), is(nullValue())
81 |
82 | when: "we defined and invoke the pull task"
83 | GitPullTask task = project.task(TEST_GIT_PULL, type: GitPullTask) {
84 | directory = this.directory
85 | } as GitPullTask
86 | task.doPull()
87 |
88 | then: "the task is defined but threw an exception"
89 | expect project.tasks.testGitPull, notNullValue()
90 | thrown(GradleException)
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/seuac-credentials-plugin/src/main/java/de/qaware/seu/as/code/plugins/credentials/CredentialsStorage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.credentials;
17 |
18 | import java.nio.charset.Charset;
19 |
20 | /**
21 | * This is the main interface to store and handle credentials. Platform specific implementations
22 | * that do the heavy lifting of securely storing the credentials.
23 | *
24 | * @author lreimer
25 | */
26 | public interface CredentialsStorage {
27 | /**
28 | * The default charset to use for credential storage.
29 | */
30 | Charset UTF_8 = Charset.forName("UTF-8");
31 |
32 | /**
33 | * Find the credentials for the given service name.
34 | *
35 | * @param service the service name
36 | * @return the stored Credentials or NULL if not present
37 | * @throws CredentialsException error finding the credentials
38 | */
39 | Credentials findCredentials(String service) throws CredentialsException;
40 |
41 | /**
42 | * Set the given username and password as credential for the specified service.
43 | *
44 | * @param service the service name
45 | * @param username the username to set
46 | * @param password the password to set
47 | * @throws CredentialsException error storing the credentials
48 | */
49 | void setCredentials(String service, String username, char[] password) throws CredentialsException;
50 |
51 | /**
52 | * Set the given credentials object for the specified service.
53 | *
54 | * @param service the service name
55 | * @param credentials the credentials object
56 | * @throws CredentialsException error storing the credentials
57 | */
58 | void setCredentials(String service, Credentials credentials) throws CredentialsException;
59 |
60 | /**
61 | * Clear the stored credentials for the given service name.
62 | *
63 | * @param service the service name
64 | * @throws CredentialsException error clearing the credentials
65 | */
66 | void clearCredentials(String service) throws CredentialsException;
67 |
68 | /**
69 | * NoOp implementation of a credential storage. Does not store anything.
70 | */
71 | class None implements CredentialsStorage {
72 |
73 | @Override
74 | public Credentials findCredentials(String service) {
75 | return null;
76 | }
77 |
78 | @Override
79 | public void setCredentials(String service, String username, char[] password) {
80 |
81 | }
82 |
83 | @Override
84 | public void setCredentials(String service, Credentials credentials) {
85 |
86 | }
87 |
88 | @Override
89 | public void clearCredentials(String service) {
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/seuac-base-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/base/RunHooksTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.base
17 |
18 | import groovy.io.FileType
19 | import org.gradle.api.DefaultTask
20 | import org.gradle.api.tasks.Input
21 | import org.gradle.api.tasks.InputDirectory
22 | import org.gradle.api.tasks.Nested
23 | import org.gradle.api.tasks.TaskAction
24 |
25 | /**
26 | * This task will run all provided hooks that might be available after
27 | * installing software packages.
28 | *
29 | * @author lreimer
30 | */
31 | class RunHooksTask extends DefaultTask {
32 | @Input
33 | String seuHome
34 |
35 | @Input
36 | String projectName
37 |
38 | @Nested
39 | SeuacLayout seuLayout
40 |
41 | @InputDirectory
42 | File target
43 |
44 | @Input
45 | boolean deleteHooks = true
46 |
47 | /**
48 | * Initialize the group and description for this task.
49 | */
50 | RunHooksTask() {
51 | group = 'SEU-as-code'
52 | description = 'Run hooks for installed software packages.'
53 | }
54 |
55 | /**
56 | * Run all software hooks found in the target directory. If configured, the hooks directory
57 | * will be removed afterwards.
58 | */
59 | @TaskAction
60 | void runHooks() {
61 | File hooks = new File(target, 'META-INF/hooks/')
62 | if (hooks.exists()) {
63 | Binding binding = new Binding();
64 |
65 | binding.setVariable('seuHome', seuHome)
66 | binding.setVariable('seuLayout', seuLayout)
67 | binding.setVariable('projectName', projectName)
68 | binding.setVariable('directory', target)
69 | binding.setVariable('logger', logger)
70 |
71 | binding.setVariable('platform', Platform.current())
72 | binding.setVariable('shortcut', Shortcut.for(seuHome, seuLayout))
73 | binding.setVariable('ext', project.extensions.extraProperties)
74 | binding.setVariable('project', project)
75 |
76 | def shell = new GroovyShell(getClass().classLoader, binding)
77 | hooks.eachFileMatch(FileType.FILES, ~/.*\.groovy/) {
78 | logger.debug "Running software hook $it"
79 | try {
80 | shell.evaluate(it)
81 | } catch (Throwable any) {
82 | logger.warn("Error running software hook $it", any)
83 | }
84 | }
85 |
86 | // IDEA: use GradleBuild task here to execute Gradle Build files
87 | // this may be used for self downloading packages
88 | }
89 |
90 | // delete the whole META-INF/ directory
91 | if (deleteHooks) {
92 | hooks.getParentFile().deleteDir()
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/seuac-svn-plugin/src/main/groovy/de/qaware/seu/as/code/plugins/svn/SvnPlugin.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.svn
17 |
18 | import org.gradle.api.NamedDomainObjectContainer
19 | import org.gradle.api.Plugin
20 | import org.gradle.api.Project
21 |
22 | /**
23 | * The SEU-as-code subversion plugin. Registers the subversion extension and creates checkout and
24 | * update tasks for all defined repos.
25 | *
26 | * @author lreimer
27 | */
28 | class SvnPlugin implements Plugin {
29 |
30 | static final String EXTENSION_NAME = 'subversion'
31 |
32 | @Override
33 | void apply(Project project) {
34 | NamedDomainObjectContainer repos = project.container(SvnRepository)
35 | project.extensions.subversion = repos
36 |
37 | project.configurations.create('svnkit')
38 | project.dependencies.add('svnkit', 'org.tmatesoft.svnkit:svnkit:1.8.10')
39 |
40 | project.task('svnCheckoutAll', description: 'Checkout all SVN repositories', group: 'Version Control')
41 | project.task('svnUpdateAll', description: 'Update all SVN repositories', group: 'Version Control')
42 |
43 | NamedDomainObjectContainer extension = project.subversion
44 | configureSvnTasks(project, extension)
45 | }
46 |
47 | /**
48 | * Configures all SVN tasks for the given project and SCN repository container.
49 | *
50 | * @param project the project
51 | * @param repositories a name repository container
52 | */
53 | def void configureSvnTasks(Project project, NamedDomainObjectContainer repositories) {
54 | project.afterEvaluate {
55 | repositories.each { SvnRepository r ->
56 | def capitalized = r.name.capitalize()
57 |
58 | // we could use convention mapping as well, does work but not public
59 | def checkout = project.task("svnCheckout${capitalized}", type: SvnCheckoutTask) {
60 | description = "Checkout the ${capitalized} SVN repository"
61 | url = r.url
62 | directory = r.directory
63 | username = r.username
64 | password = r.password
65 | revision = r.revision
66 | }
67 | project.tasks.svnCheckoutAll.dependsOn checkout
68 |
69 | def update = project.task("svnUpdate${capitalized}", type: SvnUpdateTask) {
70 | description = "Update the ${capitalized} SVN repository"
71 | directory = r.directory
72 | username = r.username
73 | password = r.password
74 | revision = r.revision
75 | }
76 | project.tasks.svnUpdateAll.dependsOn update
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/git/GitCommitTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.gradle.api.GradleException
19 | import org.gradle.api.Project
20 | import org.gradle.testfixtures.ProjectBuilder
21 | import org.junit.Rule
22 | import org.junit.rules.TemporaryFolder
23 | import spock.lang.Specification
24 |
25 | import static org.hamcrest.Matchers.*
26 | import static spock.util.matcher.HamcrestSupport.expect
27 | import static spock.util.matcher.HamcrestSupport.that
28 |
29 | /**
30 | * Basic test specification for the GitCommitTask.
31 | *
32 | * @author lreimer
33 | */
34 | class GitCommitTaskSpec extends Specification {
35 | static final String TEST_GIT_COMMIT = 'testGitCommit'
36 |
37 | @Rule
38 | TemporaryFolder folder = new TemporaryFolder()
39 |
40 | Project project
41 | File directory
42 |
43 | def setup() {
44 | project = ProjectBuilder.builder().build()
45 | directory = folder.newFolder()
46 | }
47 |
48 | def "Define GitCommitTask"() {
49 | given:
50 | def options = new GitCommitOptions()
51 |
52 | expect: "the commit task to be undefined"
53 | that project.tasks.findByName(TEST_GIT_COMMIT), is(nullValue())
54 |
55 | when: "we define and configure the commit task"
56 | def task = (GitCommitTask) project.task(TEST_GIT_COMMIT, type: GitCommitTask) {
57 | directory = this.directory
58 | username = 'user'
59 | password = 'secret'
60 | }
61 | task.applyOptions(options)
62 | task = (GitCommitTask) project.tasks.findByName(TEST_GIT_COMMIT)
63 |
64 | then: "the we expect to find the task to be correctly configured"
65 |
66 | expect task, notNullValue()
67 | expect task.group, equalTo('Version Control')
68 | expect task.username, equalTo('user')
69 | expect task.password, equalTo('secret')
70 | expect task.directory, notNullValue()
71 |
72 | task.amend == options.amend
73 | task.message == options.message
74 | task.noVerify == options.noVerify
75 | task.all == options.all
76 | task.author == options.author
77 | task.committer == options.committer
78 | }
79 |
80 | def "Invoke doCommit"() {
81 | expect: "the commit task to be undefined"
82 | that project.tasks.findByName(TEST_GIT_COMMIT), is(nullValue())
83 |
84 | when: "we define and invoke the commit task"
85 | GitCommitTask task = project.task(TEST_GIT_COMMIT, type: GitCommitTask) {
86 | directory = this.directory
87 | } as GitCommitTask
88 | task.doCommit()
89 |
90 | then: "the task is defined but threw an exception"
91 | expect project.tasks.testGitCommit, notNullValue()
92 | thrown(GradleException)
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/seuac-git-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/git/GitPushTaskSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.git
17 |
18 | import org.gradle.api.GradleException
19 | import org.gradle.api.Project
20 | import org.gradle.testfixtures.ProjectBuilder
21 | import org.junit.Rule
22 | import org.junit.rules.TemporaryFolder
23 | import spock.lang.Specification
24 |
25 | import static org.hamcrest.Matchers.*
26 | import static spock.util.matcher.HamcrestSupport.expect
27 | import static spock.util.matcher.HamcrestSupport.that
28 |
29 | /**
30 | * Basic test specification for the GitPushTask.
31 | *
32 | * @author lreimer
33 | */
34 | class GitPushTaskSpec extends Specification {
35 | static final String TEST_GIT_PUSH = 'testGitPush'
36 |
37 | @Rule
38 | TemporaryFolder folder = new TemporaryFolder()
39 |
40 | Project project
41 | File directory
42 |
43 | def setup() {
44 | project = ProjectBuilder.builder().build()
45 | directory = folder.newFolder()
46 | }
47 |
48 | def "Define GitPushTask"() {
49 | given:
50 | def options = new GitPushOptions()
51 |
52 | expect: "the push task to be undefined"
53 | that project.tasks.findByName(TEST_GIT_PUSH), is(nullValue())
54 |
55 | when: "we define and configure the task for the project"
56 | def task = (GitPushTask) project.task(TEST_GIT_PUSH, type: GitPushTask) {
57 | directory = this.directory
58 | username = 'user'
59 | password = 'secret'
60 | remote = 'test'
61 | }
62 | task.applyOptions(options)
63 | task = (GitPushTask) project.tasks.findByName(TEST_GIT_PUSH)
64 |
65 | then: "we expect to find the task correctly configured"
66 |
67 | expect task, notNullValue()
68 | expect task.group, equalTo('Version Control')
69 | expect task.remote, equalTo('test')
70 | expect task.username, equalTo('user')
71 | expect task.password, equalTo('secret')
72 | expect task.directory, notNullValue()
73 |
74 | task.force == options.force
75 | task.dryRun == options.dryRun
76 | task.pushAll == options.pushAll
77 | task.pushTags == options.pushTags
78 | task.gitTimeout == options.timeout
79 | }
80 |
81 | def "Invoke doPush"() {
82 | expect: "the push task to be undefined"
83 | that project.tasks.findByName(TEST_GIT_PUSH), is(nullValue())
84 |
85 | when: "we define and invoke the task on the project"
86 | GitPushTask task = project.task(TEST_GIT_PUSH, type: GitPushTask) {
87 | directory = this.directory
88 | } as GitPushTask
89 | task.doPush()
90 |
91 | then: "the task is defined by threw an exception"
92 | expect project.tasks.testGitPush, notNullValue()
93 | thrown(GradleException)
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/seuac-homebrew-plugin/src/test/groovy/de/qaware/seu/as/code/plugins/homebrew/ApplyBrewSoftwareTaskTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 QAware GmbH
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package de.qaware.seu.as.code.plugins.homebrew
17 |
18 | import de.qaware.seu.as.code.plugins.base.DatastoreProvider
19 | import de.qaware.seu.as.code.plugins.base.JdbcH2DatastoreProvider
20 | import de.qaware.seu.as.code.plugins.base.SeuacDatastore
21 | import de.qaware.seu.as.code.plugins.base.SeuacLayout
22 | import org.gradle.api.Project
23 | import org.gradle.api.artifacts.Dependency
24 | import org.gradle.testfixtures.ProjectBuilder
25 | import org.junit.Rule
26 | import org.junit.rules.TemporaryFolder
27 | import spock.lang.Requires
28 | import spock.lang.Specification
29 |
30 | import static de.qaware.seu.as.code.plugins.base.SeuacDatastore.temporaryDatastore
31 | import static de.qaware.seu.as.code.plugins.base.SeuacLayout.defaultLayout
32 |
33 | /**
34 | * Unit test for the {@link ApplyBrewSoftwareTask}.
35 | */
36 | @Requires({ os.macOs })
37 | class ApplyBrewSoftwareTaskTest extends Specification {
38 |
39 | @Rule
40 | TemporaryFolder folder = new TemporaryFolder()
41 |
42 | Project project
43 | SeuacDatastore defaultDatastore
44 | DatastoreProvider provider
45 | SeuacLayout defaultLayout
46 | File home
47 | private Dependency xzDependency
48 |
49 |
50 | void setup() {
51 | project = ProjectBuilder.builder().build()
52 |
53 | home = folder.newFolder()
54 | defaultLayout = defaultLayout(home)
55 |
56 | project.apply plugin: 'seuac-homebrew'
57 | xzDependency = project.dependencies.add('brew', ':xz:')
58 |
59 | defaultDatastore = temporaryDatastore()
60 | provider = new JdbcH2DatastoreProvider(defaultDatastore)
61 |
62 | project.seuAsCode {
63 | seuHome = home
64 | projectName = 'Test SEU'
65 | layout = defaultLayout
66 | }
67 | project.task("installHomebrewTask", type: InstallHomebrewTask) {
68 | homebrewBasePath = new File(home, 'homebrew')
69 | }.doInstall()
70 | }
71 |
72 | def "Exec"() {
73 | setup:
74 | ApplyBrewSoftwareTask task = project.task("applyBrewSoftwareTask", type: ApplyBrewSoftwareTask) {
75 | homebrewBasePath = new File(home, 'homebrew')
76 | datastore = defaultDatastore
77 | brew = project.configurations.brew
78 | cask = project.configurations.cask
79 | } as ApplyBrewSoftwareTask
80 | when:
81 | task.exec()
82 | provider.storeDependency(xzDependency, [project.fileTree(new File("$home/homebrew/Cellar/xz/"))], 'brew')
83 |
84 | then:
85 | assert new File(home, 'homebrew/bin/xz').exists()
86 | when:
87 | project.configurations.brew.dependencies.remove(xzDependency)
88 | task.exec()
89 | then:
90 | assert !new File(home, 'homebrew/bin/xz').exists()
91 | }
92 | }
93 |
--------------------------------------------------------------------------------