Skip to content

Commit

Permalink
RRO-914 - Gradle version upgrade, C# compiler output in Gradle console
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogerboss committed May 17, 2021
1 parent c7d5fa6 commit 8be57e7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import java.io.File

open class CompileCSharpTask : DefaultTask() {

@OutputFile
lateinit var compilerLog: File
@OutputDirectory
lateinit var targetDirectory: File
@InputDirectory
Expand All @@ -20,9 +18,11 @@ open class CompileCSharpTask : DefaultTask() {
fun buildCSharpProject() {
val compileTask = ProcessBuilder(listOf("dotnet", "publish", projectName, "-r", "win-x64", "-o", "$targetDirectory", "-c", "release"))
.directory(solutionFolder)
.redirectOutput(ProcessBuilder.Redirect.to(compilerLog))
.redirectErrorStream(true)
val compilationResult = compileTask.start().waitFor() == 0
val process = compileTask.start()
val compilationResult = process.waitFor() == 0
//TODO: might be causing issues if there's too much output, but works fine for now
process.inputStream.reader().use { it.forEachLine { line -> println(line) }}
if (!compilationResult) throw GradleException("C# project failed to build!")
}
}
5 changes: 1 addition & 4 deletions components/mutagen-reqtificator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@ plugins {
}

buildDir = file("./bin")
//TODO: handle cleanup in a nicer way than hardcoding project paths
val projectDirs = files("./Reqtificator", "./ReqtificatorTest")
val projectDirs = file(".").listFiles().filter { it.isDirectory && it.listFiles().any { f -> f.extension == "csproj" } }
val objectDirs = files(projectDirs.map { "$it/obj" })
val compileDirs = files(projectDirs.map { "$it/bin" })


val outputDir by project.extra(file("$buildDir/Reqtificator-SSE"))


val compileCSharp by tasks.registering(CompileCSharpTask::class) {
description = "Compiles the SSE Reqtificator based on Mutagen"
group = "build"

compilerLog = file("$buildDir/buildlog.txt")
solutionFolder = file(".")
projectName = "Reqtificator"
targetDirectory = file("$outputDir/app")
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-6.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 8be57e7

Please sign in to comment.