File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
modules/bcv-gradle-plugin/src/main/kotlin/tasks Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -34,17 +34,26 @@ constructor(
3434 " subproject '${project.path} '"
3535 }
3636
37+ init {
38+ outputs.cacheIf { task ->
39+ require(task is BCVApiDumpTask )
40+ task.validateApiDir()
41+ }
42+ }
43+
3744 @TaskAction
3845 fun action () {
39- validateApiDir()
46+ validateApiDir { msg -> error(msg) }
4047 updateDumpDir()
4148 }
4249
43- private fun validateApiDir () {
50+ private fun validateApiDir (ifInvalid : (msg: String ) -> Unit = {}): Boolean {
4451 val projectDir = layout.projectDirectory.asFile.toPath().toAbsolutePath().normalize()
4552 val apiDir = projectDir.resolve(apiDirectory.get().asFile.toPath()).normalize()
46- require(apiDir.startsWith(projectDir)) {
47- /* language=text */ """
53+ val valid = apiDir.startsWith(projectDir)
54+ if (! valid) {
55+ ifInvalid(
56+ /* language=text */ """
4857 |Error: Invalid output apiDirectory
4958 |
5059 |apiDirectory is set to a custom directory, outside of the current project directory.
@@ -55,7 +64,9 @@ constructor(
5564 |Project directory: ${projectDir.invariantSeparatorsPathString}
5665 |apiDirectory: ${apiDir.invariantSeparatorsPathString}
5766 """ .trimMargin()
67+ )
5868 }
69+ return valid
5970 }
6071
6172 private fun updateDumpDir () {
You can’t perform that action at this time.
0 commit comments