Commit 902fd7ff authored by Christian Meyer's avatar Christian Meyer
Browse files

CHANGES file from git tags is part of simulation distribution

ZmtDeployPlugin.groovy
    moved code for obtaining changes from git to CreateChanges
ZmtSimulationPlugin.groovy
    adds createChangesFile task and its output to the distribution
    updated test
parent 13cd2e07
......@@ -11,6 +11,7 @@ import org.gradle.api.*
public class ZmtDeployPlugin implements Plugin<Project> {
private static final def CONFIGURE = {
apply plugin: "org.hidetake.ssh"
apply plugin: "distribution"
remotes {
dochost {
......@@ -25,9 +26,8 @@ public class ZmtDeployPlugin implements Plugin<Project> {
group = 'Upload'
description = 'Uploads zip distribution to dochost.'
dependsOn distZip, determineCredentials
}
deployZip.doLast {
doLast {
println "\nConnecting to ${remotes.dochost.host}..."
ssh.run {
session(remotes.dochost) {
......@@ -37,27 +37,10 @@ public class ZmtDeployPlugin implements Plugin<Project> {
execute "mkdir -p ${remoteTargetDir}"
put from: distZip.archivePath, into: remoteTargetDir
// create CHANGES file from git version list
put text: obtainVersionListFromGit(project), into: remoteTargetDir + '/CHANGES'
}
}
}
}
private static String obtainVersionListFromGit(Project project) {
def output = new ByteArrayOutputStream()
try {
project.exec {
commandLine 'git', 'tag', '-n99'
standardOutput = output
}
}
catch (org.gradle.process.internal.ExecException e) {
println "git tag for ${project.name} failed. Cannot obtain version list."
return ''
}
return output.toString().trim()
}
@Override
......
package de.zmt.gradle;
import org.gradle.api.*
import de.zmt.gradle.task.*;
/*
* Meta plugin applying all necessary plugins for ZMT simulations
......@@ -16,6 +17,14 @@ public class ZmtSimulationPlugin implements Plugin<Project> {
apply(plugin: ZmtEclipsePlugin)
apply(plugin: ZmtLaunchConfigPlugin)
apply(plugin: ZmtShortcutPlugin)
task('createChangesFile', type: CreateChanges) {
description = 'Creates a CHANGES file from git tags.'
}
distributions.main.contents {
from (project.createChangesFile)
}
}
@Override
......
package de.zmt.gradle.task;
import org.gradle.api.*;
import org.gradle.api.tasks.*;
public class CreateChanges extends DefaultTask {
@OutputFile
File outputFile = project.file("$project.buildDir/tmp/CHANGES")
@TaskAction
public void createChangesFile() {
try {
project.exec {
commandLine 'git', 'tag', '-n99'
standardOutput = new FileOutputStream(outputFile)
}
}
catch (org.gradle.process.internal.ExecException e) {
println "git tag for ${project.name} failed. Cannot obtain version list."
}
}
}
......@@ -3,6 +3,7 @@ package de.zmt.gradle
import org.gradle.api.*
import org.junit.*
import org.gradle.testfixtures.ProjectBuilder
import de.zmt.gradle.task.*;
import static org.junit.Assert.*
......@@ -22,6 +23,7 @@ class ZmtSimulationPluginTest {
assertTrue(plugins.hasPlugin(ZmtEclipsePlugin.class))
assertTrue(plugins.hasPlugin(ZmtLaunchConfigPlugin.class))
assertTrue(plugins.hasPlugin(ZmtShortcutPlugin.class))
assertTrue(createChangesFile instanceof CreateChanges)
}
project.evaluate()
......
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