gradle-plugin: Delete user output dirs in the clean task
This commit is contained in:
+7
@@ -225,6 +225,10 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
|||||||
findByPath(name) ?: create(name, DefaultTask::class.java)
|
findByPath(name) ?: create(name, DefaultTask::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Project.cleanKonan() = project.konanArtifactsContainer.forEach {
|
||||||
|
project.delete(it.compilationTask.outputDir)
|
||||||
|
}
|
||||||
|
|
||||||
override fun apply(project: Project?) {
|
override fun apply(project: Project?) {
|
||||||
if (project == null) { return }
|
if (project == null) { return }
|
||||||
registry.register(KonanToolingModelBuilder)
|
registry.register(KonanToolingModelBuilder)
|
||||||
@@ -254,6 +258,9 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
|||||||
project.getTask("build").apply {
|
project.getTask("build").apply {
|
||||||
dependsOn(compileKonanTask)
|
dependsOn(compileKonanTask)
|
||||||
}
|
}
|
||||||
|
project.getTask("clean").apply {
|
||||||
|
doLast { project.cleanKonan() }
|
||||||
|
}
|
||||||
|
|
||||||
// Create task to run supported executables.
|
// Create task to run supported executables.
|
||||||
project.getOrCreateTask("run").apply {
|
project.getOrCreateTask("run").apply {
|
||||||
|
|||||||
+17
@@ -38,4 +38,21 @@ class PathSpecification extends BaseKonanSpecification {
|
|||||||
result.task(project.defaultInteropProcessingTask()).outcome == TaskOutcome.FAILED
|
result.task(project.defaultInteropProcessingTask()).outcome == TaskOutcome.FAILED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def 'Plugin should remove custom output directories'() {
|
||||||
|
when:
|
||||||
|
def customOutputDir = projectDirectory.toPath().resolve("foo").toFile()
|
||||||
|
def project = KonanInteropProject.create(projectDirectory) { KonanProject it ->
|
||||||
|
it.addCompilationSetting("outputDir", customOutputDir)
|
||||||
|
}
|
||||||
|
def res1 = project.createRunner().withArguments("build").build()
|
||||||
|
def customDirExistsAfterBuild = customOutputDir.exists()
|
||||||
|
def res2 = project.createRunner().withArguments("clean").build()
|
||||||
|
def customDirDoesntNotExistAfterClean = !customOutputDir.exists()
|
||||||
|
|
||||||
|
then:
|
||||||
|
res1.taskPaths(TaskOutcome.SUCCESS).containsAll(project.buildingTasks)
|
||||||
|
res2.taskPaths(TaskOutcome.SUCCESS).contains(":clean")
|
||||||
|
customDirExistsAfterBuild
|
||||||
|
customDirDoesntNotExistAfterClean
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user