Commit c4c88bb4 authored by Christian Meyer's avatar Christian Meyer
Browse files

credentials are always fetched from encrypted credentials container

build.gradle
    added gradle plugins repository
removed ZmtDeployPlugin.groovy
added ZmtDochostPlugin.groovy
ZmtDistributionPlugin.groovy
    moved ssh initialization from removed ZmtDeployPlugin
ZmtLibraryPlugin, ZmtSimulationPlugin.groovy
    replaced ZmtDeployPlugin with ZmtDochostPlugin
    updated tests
ZmtPublishPlugin.groovy
    gets repository host from determineCredentials task
    gets credentials from credentials container
ZmtExternalPlugin.groovy
    applies ZmtDochostPlugin
    fixed / updated test
parent 3e641655
......@@ -11,6 +11,9 @@ description = 'Gradle plugins for build ZMT libraries and simulations'
dependencies {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
compile gradleApi()
......
......@@ -14,9 +14,19 @@ import org.gradle.api.file.DuplicatesStrategy
public class ZmtDistributionPlugin implements Plugin<Project> {
private static final def CONFIGURE = {
apply plugin: 'application'
apply plugin: "org.hidetake.ssh"
mainClassName = "de.zmt.Main"
remotes {
dochost {
host = determineCredentials.host
knownHosts = allowAnyHosts
user = credentials.dochostUser
password = credentials.dochostPw
}
}
startScripts {
applicationName = 'launcher'
}
......
......@@ -4,31 +4,20 @@ import org.gradle.api.*
import groovy.swing.*
/*
* Plugin for deployment of zmt.core projects
* Plugin for getting user / password for dochost server.
* <p>
* With this plugin a task 'determineCredentials' is added to the project
* that asks the user to enter login credentials.
*/
class ZmtDeployPlugin implements Plugin<Project> {
class ZmtDochostPlugin implements Plugin<Project> {
private static final def CONFIGURE = {
// https://discuss.gradle.org/t/plugin-not-found-when-i-using-a-gradle-from-other-gradle-file/5628
apply plugin: org.hidetake.gradle.ssh.plugin.SshPlugin
apply plugin: nu.studer.gradle.credentials.CredentialsPlugin
remotes {
dochost {
host = 'dochost'
knownHosts = allowAnyHosts
user = credentials.dochostUser
password = credentials.dochostPw
// webserver directory
}
}
apply plugin: 'nu.studer.credentials'
task('determineCredentials') {
description = 'Ask user to enter credentials.'
ext.host = 'dochost'
ext.wwwPath = '/var/www/dochost/'
onlyIf { !remotes.dochost.user || !remotes.dochost.password }
onlyIf { !credentials.dochostUser || !credentials.dochostPw }
}
determineCredentials.doLast {
......@@ -36,10 +25,10 @@ class ZmtDeployPlugin implements Plugin<Project> {
// we can access console: ask for username / password
if (console) {
console.printf("\nEnter username: ")
remotes.dochost.user = console.readLine()
credentials.dochostUser = console.readLine()
console.printf("\nEnter password: ")
// readPassword() returns char array, wrap it into string
remotes.dochost.password = new String(console.readPassword())
credentials.dochostPw = new String(console.readPassword())
}
// no console: create dialog and get it from there
else {
......@@ -61,8 +50,8 @@ class ZmtDeployPlugin implements Plugin<Project> {
label(text: "password: ")
pwInput = passwordField()
button(defaultButton: true, text: 'OK', actionPerformed: {
remotes.dochost.user = userInput.text
remotes.dochost.password = pwInput.text
credentials.dochostUser = userInput.text
credentials.dochostPw = pwInput.text
dispose() // Close dialog
})
}
......
......@@ -10,6 +10,7 @@ public class ZmtExternalPlugin implements Plugin<Project> {
private static final def CONFIGURE = {
apply(plugin: ZmtBasePlugin)
apply(plugin: ZmtJavaPlugin)
apply(plugin: ZmtDochostPlugin)
apply(plugin: ZmtPublishPlugin)
}
......
......@@ -10,7 +10,7 @@ public class ZmtLibraryPlugin implements Plugin<Project> {
apply(plugin: ZmtBasePlugin)
apply(plugin: ZmtJavaPlugin)
apply(plugin: ZmtJavadocPlugin)
apply(plugin: ZmtDeployPlugin)
apply(plugin: ZmtDochostPlugin)
apply(plugin: ZmtPublishPlugin)
}
......
......@@ -46,10 +46,10 @@ class ZmtPublishPlugin implements Plugin<Project> {
}
repositories {
maven {
url "sftp://${remotes.dochost.host}:22${determineCredentials.wwwPath}maven2"
url "sftp://${determineCredentials.host}:22${determineCredentials.wwwPath}maven2"
credentials {
username remotes.dochost.user
password remotes.dochost.password
username project.credentials.dochostUser
password project.credentials.dochostPw
}
}
}
......
......@@ -10,7 +10,7 @@ public class ZmtSimulationPlugin implements Plugin<Project> {
apply(plugin: ZmtBasePlugin)
apply(plugin: ZmtJavaPlugin)
apply(plugin: ZmtJavadocPlugin)
apply(plugin: ZmtDeployPlugin)
apply(plugin: ZmtDochostPlugin)
apply(plugin: ZmtDistributionPlugin)
apply(plugin: ZmtEclipsePlugin)
}
......
......@@ -10,11 +10,12 @@ class ZmtExternalPluginTest {
@Test
public void apply() {
Project project = ProjectBuilder.builder().build()
project.pluginManager.apply 'de.zmt.library'
project.pluginManager.apply 'de.zmt.external'
project.configure(project) {
assertTrue(plugins.hasPlugin(ZmtBasePlugin.class))
assertTrue(plugins.hasPlugin(ZmtJavaPlugin.class))
assertTrue(plugins.hasPlugin(ZmtDochostPlugin.class))
assertTrue(plugins.hasPlugin(ZmtPublishPlugin.class))
}
......
......@@ -16,7 +16,7 @@ class ZmtLibraryPluginTest {
assertTrue(plugins.hasPlugin(ZmtBasePlugin.class))
assertTrue(plugins.hasPlugin(ZmtJavaPlugin.class))
assertTrue(plugins.hasPlugin(ZmtJavadocPlugin.class))
assertTrue(plugins.hasPlugin(ZmtDeployPlugin.class))
assertTrue(plugins.hasPlugin(ZmtDochostPlugin.class))
assertTrue(plugins.hasPlugin(ZmtPublishPlugin.class))
}
......
......@@ -16,7 +16,7 @@ class ZmtSimulationPluginTest {
assertTrue(plugins.hasPlugin(ZmtBasePlugin.class))
assertTrue(plugins.hasPlugin(ZmtJavaPlugin.class))
assertTrue(plugins.hasPlugin(ZmtJavadocPlugin.class))
assertTrue(plugins.hasPlugin(ZmtDeployPlugin.class))
assertTrue(plugins.hasPlugin(ZmtDochostPlugin.class))
assertTrue(plugins.hasPlugin(ZmtDistributionPlugin.class))
assertTrue(plugins.hasPlugin(ZmtEclipsePlugin.class))
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment