
com.jakewharton.sdkmanager.internal.AndroidCommand.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugin Show documentation
Show all versions of gradle-plugin Show documentation
Gradle plugin which downloads and manages your Android SDK.
package com.jakewharton.sdkmanager.internal
import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import static com.android.SdkConstants.FD_TOOLS
import static com.android.SdkConstants.androidCmdName
interface AndroidCommand {
int update(String filter);
static final class Real implements AndroidCommand {
final Logger log = Logging.getLogger Real
final File androidExecutable
Real(File sdk) {
def toolsDir = new File(sdk, FD_TOOLS)
androidExecutable = new File(toolsDir, androidCmdName())
androidExecutable.setExecutable true, false
}
@Override int update(String filter) {
// -a == all
// -u == no UI
// -t == filter
def cmd = [androidExecutable.absolutePath, 'update', 'sdk', '-a', '-u', '-t', filter]
def process = cmd.execute()
// Press 'y' and then enter on the license prompt.
def output = new OutputStreamWriter(process.out)
output.write("y\n")
output.close()
// Pipe the command output to our log.
def input = new InputStreamReader(process.in)
def line
while ((line = input.readLine()) != null) {
log.debug line
}
return process.waitFor()
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy