Skip to content

Commit

Permalink
Fix compiler error, fix broken tests, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
psxpaul committed Jan 9, 2019
1 parent ac5e0e9 commit f1d0afb
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 22 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ For running a standard executable:

```groovy
plugins {
id 'com.github.psxpaul.execfork' version '0.1.8'
id 'com.github.psxpaul.execfork' version '0.1.9'
}
task startDaemon(type: com.github.psxpaul.task.ExecFork) {
commandLine = './MainScript.sh'
executable = './MainScript.sh'
args = [ '-d', '/foo/bar/data', '-v', '-l', '3' ]
workingDir = "$projectDir/src/main/bash"
standardOutput = "$buildDir/daemon.log"
Expand All @@ -27,7 +27,7 @@ For running a java main class:

```groovy
plugins {
id 'com.github.psxpaul.execfork' version '0.1.8'
id 'com.github.psxpaul.execfork' version '0.1.9'
}
task startDaemon(type: com.github.psxpaul.task.JavaExecFork) {
Expand Down Expand Up @@ -58,7 +58,7 @@ waitForPort | Int | *Optional.* A port number to watch for to be open. Until ope
waitForOutput | String | *Optional.* A string to look for in standardOutput. The task will block until this pattern appeared or the timeout is reached. If not specified, the task will return immediately after launching the process.
timeout | Long | *Optional.* The maximum number of seconds associated with the waitForPort or waitForOutput task. Default: `60`
stopAfter | org.gradle.api.Task | *Optional.* A task that, when finished, will cause the process to stop. If none is specified, the process will stop at the very end of a build (whether successful or not).
commandLine | String | *Required.* The path to the executable.
executable | String | *Required.* The path to the executable.
environment | Two Strings OR one Map<String, String> | *Optional.* Environment variables to launch the executable with. You can either assign a Map with the '=' operator, or pass 2 Strings as key/value to the function. Note that multiple calls to this function are supported.


Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.8
0.1.9
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ tasks {


val javadocJar by tasks.creating(Jar::class) {
classifier = "javadoc"
archiveClassifier.set("javadoc")
from("javadoc")
}

val sourcesJar by tasks.creating(Jar::class) {
classifier = "sources"
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 3 additions & 1 deletion sample_projects/jacoco/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@ buildscript {
task workerTask(dependsOn: 'startDaemon') {
doLast {
sleep(1000)
assert file("$buildDir/daemon.log").text.contains("PING") == true
}
}

task startDaemon(type: com.github.psxpaul.task.JavaExecFork, dependsOn: 'classes') {
classpath = sourceSets.main.runtimeClasspath
main = 'com.github.psxpaul.example.Main'
standardOutput = "$buildDir/daemon.log"
waitForOutput = 'PING'
stopAfter = workerTask
jacoco.applyTo(it)
}

task daemonCodeCoverageReport(type: JacocoReport) {
executionData startDaemon.jacoco.destinationFile
classDirectories = sourceSets.main.runtimeClasspath
classDirectories.setFrom(sourceSets.main.runtimeClasspath)
sourceSets sourceSets.main
reports.xml.enabled = true
reports.html.enabled = false
Expand Down
7 changes: 6 additions & 1 deletion sample_projects/spring_boot_with_dependency/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
buildscript {
dependencies {
classpath "com.github.psxpaul:gradle-execfork-plugin:$pluginVersion"
}
}

plugins {
id 'org.springframework.boot' version '1.5.3.RELEASE'
id 'com.github.psxpaul.execfork' version '0.1.8'
}

repositories {
Expand Down
18 changes: 10 additions & 8 deletions src/main/kotlin/com/github/psxpaul/ExecForkPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.gradle.BuildResult
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.util.GradleVersion
import org.slf4j.Logger
import org.slf4j.LoggerFactory
Expand All @@ -27,21 +28,22 @@ class ExecForkPlugin : Plugin<Project> {

override fun apply(project: Project) {
if (GradleVersion.current() < GradleVersion.version("4.10")) {
throw GradleException("This version of the plugin is incompatible with gradle < 4.10! Use can use execfork version 0.1.8 for now.")
throw GradleException("This version of the plugin is incompatible with gradle < 4.10! Please use execfork version 0.1.8, or upgrade gradle.")
}

val forkTasks: ArrayList<AbstractExecFork> = ArrayList()
project.tasks.whenTaskAdded { task: Task ->
if (task is AbstractExecFork) {
val forkTask: AbstractExecFork = task
val joinTask: ExecJoin = project.tasks.create(createNameFor(forkTask), ExecJoin::class.java)
joinTask.forkTask = forkTask
forkTask.joinTask = joinTask

project.tasks.withType(AbstractExecFork::class.java).configureEach {
val forkTask = this
forkTask.joinTask = project.tasks.create(createNameFor(forkTask), ExecJoin::class.java) {
this.forkTask = forkTask
forkTasks.add(forkTask)
}

forkTasks.add(forkTask)
}

project.gradle.addBuildListener(object : BuildAdapter() {
project.gradle.addBuildListener(object: BuildAdapter() {
override fun buildFinished(result: BuildResult) {
for (forkTask: AbstractExecFork in forkTasks) {
try {
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/com/github/psxpaul/task/AbstractExecFork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ abstract class AbstractExecFork : DefaultTask(), ProcessForkOptions {
@Internal
var stopAfter: Task? = null
set(value: Task?) {
val joinTaskVal = joinTask
val joinTaskVal: ExecJoin? = joinTask
if (joinTaskVal != null) {
log.info("Adding '{}' as a finalizing task to '{}'", joinTaskVal.name, value?.name)
value?.finalizedBy(joinTask)
Expand All @@ -82,7 +82,7 @@ abstract class AbstractExecFork : DefaultTask(), ProcessForkOptions {
@Internal
var joinTask: ExecJoin? = null
set(value: ExecJoin?) {
val stopAfterVal = stopAfter
val stopAfterVal: Task? = stopAfter
if (stopAfterVal != null) {
log.info("Adding {} as a finalizing task to {}", value?.name, stopAfterVal.name)
stopAfterVal.finalizedBy(value)
Expand Down Expand Up @@ -136,11 +136,11 @@ abstract class AbstractExecFork : DefaultTask(), ProcessForkOptions {
project.file(standardOutput!!).parentFile.mkdirs()
FileOutputStream(standardOutput)
} else OutputStreamLogger(project.logger)
val outPipe = InputStreamPipe(process.inputStream, processOut, waitForOutput)
val outPipe: InputStreamPipe = InputStreamPipe(process.inputStream, processOut, waitForOutput)
if (errorOutput != null) {
project.file(errorOutput!!).parentFile.mkdirs()

val errPipe = InputStreamPipe(process.errorStream, FileOutputStream(errorOutput), waitForError)
val errPipe: InputStreamPipe = InputStreamPipe(process.errorStream, FileOutputStream(errorOutput), waitForError)
errPipe.waitForPattern(timeout, TimeUnit.SECONDS)
}
outPipe.waitForPattern(timeout, TimeUnit.SECONDS)
Expand Down

0 comments on commit f1d0afb

Please sign in to comment.