Commit 9d9be7bd authored by Christian Meyer's avatar Christian Meyer
Browse files

public server is used for zmt libraries

ZmtBasePlugin.groovy
    added public dochost maven repository
ZmtDochostPlugin.groovy
    added constants for hostname / path property names and default values
        for internal and public dochost
        loads default values properties if necessary
    added task 'setupDochostRemote'
    updated ZmtDeployPlugin, ZmtJavadocPlugin
ZmtPublishPlugin.groovy
    publishes to public dochost
parent 95dbe325
......@@ -11,9 +11,11 @@ class ZmtBasePlugin implements Plugin<Project> {
private static final def CONFIGURE = {
repositories {
jcenter()
// zmt maven repository - intranet only
maven {
url "http://dochost.intra.zmt/maven2/"
// zmt maven repository - public
url 'https://dochost.leibniz-zmt.de/'
// zmt maven repository - intranet only
url 'http://dochost.intra.zmt/maven2/'
}
}
......
......@@ -16,13 +16,13 @@ public class ZmtDeployPlugin implements Plugin<Project> {
task('deployZip') {
group = 'Upload'
description = 'Uploads zip distribution to dochost.'
dependsOn distZip, determineCredentials
dependsOn distZip, setupDochostRemote
doLast {
println "\nConnecting to ${remotes.dochost.host}..."
ssh.run {
session(remotes.dochost) {
def remoteTargetDir = determineCredentials.wwwPath + 'dist'
def remoteTargetDir = setupDochostRemote.deployPath + 'dist'
// create target directory on remote
execute "mkdir -p ${remoteTargetDir}"
......
......@@ -4,32 +4,39 @@ import org.gradle.api.*
import groovy.swing.*
/*
* Plugin for getting user / password for dochost server.
* Plugin for getting user / password and setting properties for
* internal and public servers' name and path.
* <p>
* With this plugin a task 'determineCredentials' is added to the project
* that asks the user to enter login credentials.
*/
class ZmtDochostPlugin implements Plugin<Project> {
private static final PROPERTY_PREFIX = ZmtDochostPlugin.class.getPackage().getName() + '.dochost.'
public static final def PUBLIC_HOST_PROPERTY_NAME = PROPERTY_PREFIX + 'publicHost'
public static final def PUBLIC_PATH_PROPERTY_NAME = PROPERTY_PREFIX + 'publicPath'
public static final def INTERNAL_HOST_PROPERTY_NAME = PROPERTY_PREFIX + 'internalHost'
public static final def INTERNAL_PATH_PROPERTY_NAME = PROPERTY_PREFIX + 'internalPath'
private static final def DEFAULT_PUBLIC_HOST = 'ecomod01'
private static final def DEFAULT_PUBLIC_PATH = '/projects/dochost/'
private static final def DEFAULT_INTERNAL_HOST = 'dochost'
private static final def DEFAULT_INTERNAL_PATH = '/var/www/dochost/'
private static final def CONFIGURE = {
apply plugin: 'nu.studer.credentials'
apply plugin: 'org.hidetake.ssh'
// setup properties
putIfAbsent(project, PUBLIC_HOST_PROPERTY_NAME, DEFAULT_PUBLIC_HOST)
putIfAbsent(project, PUBLIC_PATH_PROPERTY_NAME, DEFAULT_PUBLIC_PATH)
putIfAbsent(project, INTERNAL_HOST_PROPERTY_NAME, DEFAULT_INTERNAL_HOST)
putIfAbsent(project, INTERNAL_PATH_PROPERTY_NAME, DEFAULT_INTERNAL_PATH)
task('determineCredentials') {
tasks.create('determineCredentials') {
description = 'Ask user to enter credentials.'
ext.host = 'dochost'
ext.wwwPath = '/var/www/dochost/'
onlyIf { !credentials.dochostUser || !credentials.dochostPw }
}
remotes {
dochost {
host = determineCredentials.host
knownHosts = allowAnyHosts
user = credentials.dochostUser
password = credentials.dochostPw
}
}
determineCredentials.doLast {
def console = System.console()
// we can access console: ask for username / password
......@@ -71,6 +78,27 @@ class ZmtDochostPlugin implements Plugin<Project> {
println "Use task 'addCredentials' with keys 'dochostUser' and 'dochostPw' if you want to store credentials permanently."
}
tasks.create('setupDochostRemote') {
dependsOn('determineCredentials')
ext.deployPath = getProperty(INTERNAL_PATH_PROPERTY_NAME)
}
setupDochostRemote.doLast {
remotes {
dochost {
host = getProperty(INTERNAL_HOST_PROPERTY_NAME)
knownHosts = allowAnyHosts
user = credentials.dochostUser
password = credentials.dochostPw
}
}
}
}
private static void putIfAbsent(Project project, String propertyName, Object propertyValue) {
if (!project.ext.has(propertyName)) {
project.ext.set(propertyName, propertyValue)
}
}
@Override
......
......@@ -21,7 +21,7 @@ class ZmtJavadocPlugin implements Plugin<Project> {
}
task('deployJavadoc') {
dependsOn 'javadoc', 'determineCredentials'
dependsOn 'javadoc', 'setupDochostRemote'
group = 'Upload'
description = 'Uploads javadoc files to dochost.'
}
......@@ -30,7 +30,7 @@ class ZmtJavadocPlugin implements Plugin<Project> {
println "\nConnecting to ${remotes.dochost.host}..."
ssh.run {
session(remotes.dochost) {
def remoteTargetDir = determineCredentials.wwwPath + javadoc.targetPath
def remoteTargetDir = setupDochostRemote.deployPath + javadoc.targetPath
// create and clean target directory on remote
execute "mkdir -p ${remoteTargetDir}"
......
......@@ -46,7 +46,9 @@ class ZmtPublishPlugin implements Plugin<Project> {
}
repositories {
maven {
url "sftp://${determineCredentials.host}:22${determineCredentials.wwwPath}maven2"
def host = getProperty(ZmtDochostPlugin.PUBLIC_HOST_PROPERTY_NAME)
def path = getProperty(ZmtDochostPlugin.PUBLIC_PATH_PROPERTY_NAME)
url "sftp://${host}:22${path}maven2"
credentials {
username project.credentials.dochostUser
password project.credentials.dochostPw
......
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