ZmtDeployPlugin.groovy 1.26 KB
Newer Older
1 2 3 4 5
package de.zmt.gradle;

import org.gradle.api.*

/*
6
 * Deploy plugin for simulations based on zmt.core
7
 * <p>
8 9
 * Adds 'deployZip' task for uploading to dochost. A CHANGES file is also
 * added containing git tags and their descriptions.
10
 */
11
public class ZmtDeployPlugin implements Plugin<Project> {
12
    private static final def CONFIGURE = {
13
        apply plugin: "org.hidetake.ssh"
14 15
        apply plugin: "distribution"
        
16
        task('deployZip') {
17 18 19
            group = 'Upload'
            description = 'Uploads zip distribution to dochost.'
            dependsOn distZip, determineCredentials
20 21 22 23 24 25 26 27 28 29 30 31
            
            doLast {
                println "\nConnecting to ${remotes.dochost.host}..."
                ssh.run {
                    session(remotes.dochost) {
                        def remoteTargetDir = determineCredentials.wwwPath + 'dist'
                        
                        // create target directory on remote
                        execute "mkdir -p ${remoteTargetDir}"
                        
                        put from: distZip.archivePath, into: remoteTargetDir
                    }
32 33 34 35 36 37 38 39 40 41
                }
            }
        }
    }
    
    @Override
    void apply(Project project) {
        project.configure(project, CONFIGURE)
    }
}