1 /*
2  * Copyright 2017-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 
5 package kotlinx.atomicfu.plugin.gradle
6 
7 import org.gradle.internal.impldep.com.google.common.io.Files
8 import org.junit.After
9 import org.junit.Before
10 import java.io.File
11 
12 abstract class BaseKotlinGradleTest {
13     private lateinit var workingDir: File
14 
projectnull15     fun project(name: String, suffix: String = "", fn: Project.() -> Unit) {
16         workingDir = File("build${File.separator}test-$name$suffix").absoluteFile
17         workingDir.deleteRecursively()
18         workingDir.mkdirs()
19         val testResources = File("src/test/resources")
20         val originalProjectDir = testResources.resolve("projects/$name").apply { checkExists() }
21         val projectDir = workingDir.resolve(name).apply { mkdirs() }
22         originalProjectDir.listFiles().forEach { it.copyRecursively(projectDir.resolve(it.name)) }
23 
24         // Add an empty setting.gradle
25         projectDir.resolve("settings.gradle").writeText("// this file is intentionally left empty")
26 
27         Project(projectDir = projectDir).fn()
28     }
29 }