Skip to content

Commit

Permalink
extension function for gradle commands
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Nov 17, 2020
1 parent b1b2ee2 commit 5f47755
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/kotlin/tech/stonks/kvizard/KVisionModuleBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import tech.stonks.kvizard.generator.KtorTreeGenerator
import tech.stonks.kvizard.generator.TreeGenerator
import tech.stonks.kvizard.step.library_choice.LibraryChoiceStep
import tech.stonks.kvizard.utils.backgroundTask
import tech.stonks.kvizard.utils.runGradle
import java.io.File

class KVisionModuleBuilder : ModuleBuilder() {
Expand Down Expand Up @@ -64,7 +65,7 @@ class KVisionModuleBuilder : ModuleBuilder() {
}

private fun runGradleTasks(project: Project) {
GradleExecuteTaskAction.runGradle(project, DefaultRunExecutor.getRunExecutorInstance(), project.basePath!!, "compileKotlinMetadata")
project.runGradle("compileKotlinMetadata")
}

private fun createGenerator(): TreeGenerator {
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/tech/stonks/kvizard/utils/file.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package tech.stonks.kvizard.utils

import com.intellij.execution.executors.DefaultRunExecutor
import com.intellij.ide.fileTemplates.FileTemplateManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.plugins.gradle.action.GradleExecuteTaskAction
import java.io.File

fun File.dir(name: String, body: File.() -> Unit = {}) {
Expand Down Expand Up @@ -45,6 +47,10 @@ private fun getTemplateData(templateName: String, attributes: Map<String, String
}
}

fun Project.runGradle(command: String) {
GradleExecuteTaskAction.runGradle(this, DefaultRunExecutor.getRunExecutorInstance(), this.basePath!!, command)
}

fun Project.getRootFile(): VirtualFile? {
return projectFile?.parent?.parent
}
Expand Down

0 comments on commit 5f47755

Please sign in to comment.