Created
February 27, 2020 14:06
-
-
Save arunkumar9t2/5ed548ef4f838fb191b74ef29d1603f8 to your computer and use it in GitHub Desktop.
A gradle task that blocks Android builds started from IDE and copies the command to clipboard to quickly start build from terminal. Works only on Max
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validateIdeBuilds = tasks.register("validateIdeBuilds") { | |
doLast { | |
if (project.hasProperty("android.injected.invoked.from.ide")) { | |
def buildCommand = "./gradlew " + gradle.startParameter.taskNames.join(" ") | |
exec { | |
commandLine("sh", "-c", "echo \"$buildCommand\" | pbcopy") | |
} | |
throw new RuntimeException( | |
"Please avoid building from IDE and use commandLine instead." + | |
"The command has been copied to your clipboard" | |
) | |
} | |
} | |
} | |
tasks.named("preBuild").configure { | |
dependsOn validateIdeBuilds | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment