gradle-plugin, tests: Create directories in the 'createFile' method
This commit is contained in:
-3
@@ -119,7 +119,6 @@ class IncrementalSpecification extends BaseKonanSpecification {
|
|||||||
when:
|
when:
|
||||||
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
|
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
|
||||||
it.generateSrcFile('main.kt')
|
it.generateSrcFile('main.kt')
|
||||||
it.createSubDir('src', 'foo', 'kotlin')
|
|
||||||
it.generateSrcFile(["src", "foo", "kotlin"], 'bar.kt', """
|
it.generateSrcFile(["src", "foo", "kotlin"], 'bar.kt', """
|
||||||
fun main(args: Array<String>) { println("Hello!") }
|
fun main(args: Array<String>) { println("Hello!") }
|
||||||
""".stripIndent())
|
""".stripIndent())
|
||||||
@@ -137,7 +136,6 @@ class IncrementalSpecification extends BaseKonanSpecification {
|
|||||||
when:
|
when:
|
||||||
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
|
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
|
||||||
it.generateSrcFile('main.kt')
|
it.generateSrcFile('main.kt')
|
||||||
it.createSubDir('src', 'lib', 'kotlin')
|
|
||||||
it.generateSrcFile(["src", "lib", "kotlin"], "lib.kt", "fun bar() { println(\"Hello!\") }")
|
it.generateSrcFile(["src", "lib", "kotlin"], "lib.kt", "fun bar() { println(\"Hello!\") }")
|
||||||
it.buildFile.append("""
|
it.buildFile.append("""
|
||||||
konanArtifacts {
|
konanArtifacts {
|
||||||
@@ -254,7 +252,6 @@ class IncrementalSpecification extends BaseKonanSpecification {
|
|||||||
when:
|
when:
|
||||||
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
|
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
|
||||||
it.generateSrcFile('main.kt')
|
it.generateSrcFile('main.kt')
|
||||||
it.createSubDir('src', 'lib', 'kotlin')
|
|
||||||
it.generateSrcFile(["src", "lib", "kotlin"], 'lib.kt', 'fun foo() { println(42) }')
|
it.generateSrcFile(["src", "lib", "kotlin"], 'lib.kt', 'fun foo() { println(42) }')
|
||||||
it.buildFile.append("""
|
it.buildFile.append("""
|
||||||
konanArtifacts {
|
konanArtifacts {
|
||||||
|
|||||||
+5
-3
@@ -59,7 +59,9 @@ class KonanProject {
|
|||||||
|
|
||||||
/** Creates a file with the given content in project subdirectory specified by parentDirectory. */
|
/** Creates a file with the given content in project subdirectory specified by parentDirectory. */
|
||||||
File createFile(Path parentDirectory = projectPath, String fileName, String content) {
|
File createFile(Path parentDirectory = projectPath, String fileName, String content) {
|
||||||
def result = projectPath.resolve(parentDirectory).resolve(fileName).toFile()
|
def parent = projectPath.resolve(parentDirectory)
|
||||||
|
Files.createDirectories(parent)
|
||||||
|
def result = parent.resolve(fileName).toFile()
|
||||||
result.createNewFile()
|
result.createNewFile()
|
||||||
result.write(content)
|
result.write(content)
|
||||||
return result
|
return result
|
||||||
@@ -304,7 +306,7 @@ class KonanInteropProject extends KonanProject {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a project with the default build file and without any source or def files. */
|
/** Creates a project with the default build file, without any source and with an empty def file. */
|
||||||
static KonanInteropProject createEmpty(File projectDir) {
|
static KonanInteropProject createEmpty(File projectDir) {
|
||||||
def result = new KonanInteropProject(projectDir)
|
def result = new KonanInteropProject(projectDir)
|
||||||
result.with {
|
result.with {
|
||||||
@@ -316,7 +318,7 @@ class KonanInteropProject extends KonanProject {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a project with the default build file and without any source or def files. */
|
/** Creates a project with the default build file, without any source and with an empty def file. */
|
||||||
static KonanInteropProject createEmpty(File projectDir, Closure config) {
|
static KonanInteropProject createEmpty(File projectDir, Closure config) {
|
||||||
def result = createEmpty(projectDir)
|
def result = createEmpty(projectDir)
|
||||||
config(result)
|
config(result)
|
||||||
|
|||||||
Reference in New Issue
Block a user