gradle-plugin: Fix tests according to plugin changes

This commit is contained in:
Ilya Matveev
2017-08-31 13:10:33 +07:00
committed by ilmat192
parent 7ec167b5ca
commit d0b3f46a77
3 changed files with 55 additions and 29 deletions
@@ -109,7 +109,7 @@ class KonanProject {
} }
""".stripIndent() """.stripIndent()
) )
compilationTasks = [":compileKonan${DEFAULT_ARTIFACT_NAME.capitalize()}".toString(), ":compileKonan", ":build"] compilationTasks = [defaultCompilationTask(), ":compileKonan", ":build"]
return result return result
} }
@@ -183,6 +183,16 @@ class KonanProject {
addSetting("konanArtifacts", artifactName, parameter, value) addSetting("konanArtifacts", artifactName, parameter, value)
} }
/** Returns the path of compileKonan... task for the default artifact. */
String defaultCompilationTask() {
return compilationTask(DEFAULT_ARTIFACT_NAME)
}
/** Returns the path of compileKonan... task for the artifact specified. */
String compilationTask(String artifactName) {
return ":compileKonan${artifactName.capitalize()}"
}
/** Creates a project with default build and source files. */ /** Creates a project with default build and source files. */
static KonanProject create(File projectDir) { static KonanProject create(File projectDir) {
return createEmpty(projectDir) { return createEmpty(projectDir) {
@@ -263,9 +273,8 @@ class KonanInteropProject extends KonanProject {
} }
""".stripIndent() """.stripIndent()
) )
interopTasks = [":gen${DEFAULT_INTEROP_NAME.capitalize()}InteropStubs".toString(), interopTasks = [defaultStubGenerationTask(), defaultStubCompilationTask()]
":compile${DEFAULT_INTEROP_NAME.capitalize()}InteropStubs".toString()] compilationTasks = [defaultCompilationTask(), ":compileKonan", ":build"]
compilationTasks = [":compileKonan${DEFAULT_ARTIFACT_NAME.capitalize()}".toString(), ":compileKonan", ":build"]
return result return result
} }
@@ -299,6 +308,22 @@ class KonanInteropProject extends KonanProject {
addSetting("konanInterop", interopName, parameter, value) addSetting("konanInterop", interopName, parameter, value)
} }
String defaultStubGenerationTask() {
return stubGenerationTask(DEFAULT_INTEROP_NAME)
}
String defaultStubCompilationTask() {
return stubCompilationTask(DEFAULT_INTEROP_NAME)
}
String stubGenerationTask(String interopName) {
return ":gen${interopName.capitalize()}InteropStubs"
}
String stubCompilationTask(String interopName) {
return ":compile${interopName.capitalize()}InteropStubs"
}
/** Creates a project with default build, source and def files. */ /** Creates a project with default build, source and def files. */
static KonanInteropProject create(File projectDir) { static KonanInteropProject create(File projectDir) {
return createEmpty(projectDir) { return createEmpty(projectDir) {
@@ -35,7 +35,7 @@ class PathSpecification extends BaseKonanSpecification {
def result = project.createRunner().withArguments('build').buildAndFail() def result = project.createRunner().withArguments('build').buildAndFail()
then: then:
result.task(project.downloadTask).outcome == TaskOutcome.FAILED result.task(project.defaultCompilationTask()).outcome == TaskOutcome.FAILED
} }
def 'Plugin should stop building if the stub generator classpath is empty'() { def 'Plugin should stop building if the stub generator classpath is empty'() {
@@ -45,7 +45,7 @@ class PathSpecification extends BaseKonanSpecification {
def result = project.createRunner().withArguments('build').buildAndFail() def result = project.createRunner().withArguments('build').buildAndFail()
then: then:
result.task(project.downloadTask).outcome == TaskOutcome.FAILED result.task(project.defaultStubGenerationTask()).outcome == TaskOutcome.FAILED
} }
} }
@@ -6,33 +6,34 @@ class RegressionSpecification extends BaseKonanSpecification {
def 'KT-19916'() { def 'KT-19916'() {
when: when:
def project = KonanProject.createEmpty(getProjectDirectory()) { KonanProject prj -> def project = KonanProject.createEmpty(getProjectDirectory()) { KonanProject prj ->
prj.generateSettingsFile("include ':subproject'") prj.generateSettingsFile("include ':subproject'")
def subprojectDir = prj.projectPath.resolve("subproject").toFile() def subprojectDir = prj.projectPath.resolve("subproject").toFile()
subprojectDir.mkdirs() subprojectDir.mkdirs()
subprojectDir.toPath().resolve("build.gradle").write(""" subprojectDir.toPath().resolve("build.gradle").write("""
dependencies { dependencies {
libs gradleApi() libs gradleApi()
} }
""".stripIndent()) """.stripIndent())
prj.buildFile.append(""" prj.buildFile.append("""
subprojects { subprojects {
apply plugin: 'konan' apply plugin: 'konan'
apply plugin: Foo apply plugin: Foo
}
class Foo implements Plugin<Project> {
void apply(Project project) {
project.configurations.maybeCreate("libs")
} }
}
class Foo implements Plugin<Project> { """.stripIndent())
void apply(Project project) { }
project.configurations.maybeCreate("libs")
} def result = project.createRunner().withArguments('tasks').build()
}
""".stripIndent())
}
def result = project.createRunner().withArguments('tasks').build()
then: then:
result.task(':tasks').outcome == TaskOutcome.SUCCESS result.task(':tasks').outcome == TaskOutcome.SUCCESS
} }
} }