com.github.mictaege.arete_gradle.AretePlugin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of arete-gradle Show documentation
Show all versions of arete-gradle Show documentation
This repository contains the Arete Gradle Plugin.
The newest version!
package com.github.mictaege.arete_gradle
import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.testing.Test
import java.util.*
class AretePlugin: Plugin{
companion object {
const val BUILD_DIR_PROPERTY = "io.github.mictaege.arete_gradle.buildDir"
const val TASK_NAME_PROPERTY = "io.github.mictaege.arete_gradle.taskName"
}
override fun apply(project: Project) {
val props = Properties()
props.load(javaClass.classLoader.getResourceAsStream("arete-gradle.properties"))
val version = props.getProperty("version")
project.dependencies.add("testRuntimeOnly", "io.github.mictaege:arete-gradle:${version}")
project.tasks.withType(Test::class.java, object : Action {
override fun execute(testTask: Test) {
testTask.doFirst(object : Action {
override fun execute(it: Task) {
testTask.systemProperties[BUILD_DIR_PROPERTY] = project.buildDir.absolutePath
testTask.systemProperties[TASK_NAME_PROPERTY] = testTask.name
}
})
}
})
}
}