| import com.google.common.collect.ImmutableMap |
| |
| apply plugin: 'com.android.tools.java-library' |
| apply plugin: 'com.android.tools.publish' |
| apply plugin: 'sdk-java-lib' |
| |
| group = 'com.android.tools' |
| archivesBaseName = 'sdklib' |
| version = rootProject.ext.baseVersion |
| |
| dependencies { |
| implementation project(':base:layoutlib-api') |
| implementation project(':base:dvlib') |
| api project(':base:repository') |
| implementation project(':base:common') |
| |
| implementation libs.gson |
| implementation libs.jaxb_runtime |
| implementation libs.apache_compress |
| implementation libs.apache_httpmime |
| implementation libs.apache_httpcore |
| |
| testImplementation libs.junit |
| testImplementation libs.truth |
| testImplementation project(':base:testutils') |
| testImplementation testFixtures(project(":base:repository")) |
| } |
| |
| test { |
| testLogging { |
| showStandardStreams = true |
| showStackTraces = true |
| exceptionFormat = "full" |
| } |
| } |
| |
| sourceSets { |
| main.resources.srcDir 'src/main/java' |
| test.resources.srcDir 'src/test/java' |
| } |
| |
| task sdkManagerStartScripts(type: CreateStartScripts) { |
| classpath = project.getTasks().getAt(JavaPlugin.JAR_TASK_NAME).getOutputs().getFiles().plus( |
| project.getConfigurations().getByName("runtimeClasspath")) |
| outputDir new File(project.getBuildDir(), "scripts") |
| |
| description "Creates OS specific scripts to start the sdk manager CLI" |
| mainClassName = 'com.android.sdklib.tool.sdkmanager.SdkManagerCli' |
| applicationName = 'sdkmanager' |
| defaultJvmOpts = ["-Dcom.android.sdklib.toolsdir=MY_APP_HOME"] |
| |
| doLast { |
| unixScript.text = unixScript.text.replace('MY_APP_HOME', '\$APP_HOME') |
| windowsScript.text = windowsScript.text.replace('MY_APP_HOME', '%~dp0\\..') |
| } |
| } |
| |
| task avdManagerStartScripts(type: CreateStartScripts) { |
| classpath = project.getTasks().getAt(JavaPlugin.JAR_TASK_NAME).getOutputs().getFiles().plus( |
| project.getConfigurations().getByName('runtimeClasspath')) |
| outputDir new File(project.getBuildDir(), 'scripts') |
| |
| description 'Creates OS specific scripts to start avdmanager' |
| mainClassName = 'com.android.sdklib.tool.AvdManagerCli' |
| applicationName = 'avdmanager' |
| defaultJvmOpts = ["-Dcom.android.sdkmanager.toolsdir=MY_APP_HOME"] |
| |
| doLast { |
| unixScript.text = unixScript.text.replace('MY_APP_HOME', '\$APP_HOME') |
| windowsScript.text = windowsScript.text.replace('MY_APP_HOME', '%~dp0\\..') |
| } |
| } |
| |
| sdk { |
| common(mac, linux) { |
| item(new File(avdManagerStartScripts.outputDir, "avdmanager")) { |
| into "bin" |
| notice null |
| builtBy 'avdManagerStartScripts' |
| } |
| item(new File(sdkManagerStartScripts.outputDir, "sdkmanager")) { |
| into "bin" |
| notice null |
| builtBy 'sdkManagerStartScripts' |
| } |
| } |
| windows { |
| item(new File(avdManagerStartScripts.outputDir, "avdmanager.bat")) { |
| into "bin" |
| notice null |
| builtBy 'avdManagerStartScripts' |
| } |
| item(new File(sdkManagerStartScripts.outputDir, "sdkmanager.bat")) { |
| into "bin" |
| notice null |
| builtBy 'sdkManagerStartScripts' |
| } |
| } |
| } |
| |
| // Used for changes to remove components from initSdkForTests, so that continuous-build results |
| // (both pre- and post-submit) give good feedback and proper attribution in case of failure. |
| task removeSdkComponents(type: JavaExec) { |
| classpath = sourceSets.main.runtimeClasspath |
| main = "com.android.sdklib.tool.sdkmanager.SdkManagerCli" |
| args = [ |
| '--sdk_root=' + System.getenv("ANDROID_SDK_ROOT"), |
| '--verbose', |
| '--uninstall', |
| // Entries below are temporary and should always include dates. For example: |
| // 'extras;android;gapid;3', // added 2016-11-18 |
| 'extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta3', // added 2016-11-21 |
| 'extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta3', // added 2016-11-21 |
| 'extras;android;support', // added 2016-12-13 |
| ] |
| } |
| |
| task initSdkForTests(type: JavaExec, dependsOn: removeSdkComponents) { |
| standardInput = System.in |
| classpath = sourceSets.main.runtimeClasspath |
| main = "com.android.sdklib.tool.sdkmanager.SdkManagerCli" |
| |
| doFirst { |
| if (project.hasProperty('downloaderArgs')) { |
| args(downloaderArgs.split(',')) |
| } else { |
| def sdk_home = System.getenv("ANDROID_SDK_ROOT") |
| if (sdk_home == null) { |
| throw new GradleException('Required ANDROID_SDK_ROOT environment variable not set.') |
| } |
| args = ['--sdk_root=' + sdk_home, |
| '--channel=3', |
| '--verbose', |
| // When you remove an entry below, please add it to removeSdkComponents above. |
| 'tools', |
| 'platform-tools', |
| 'build-tools;25.0.0', |
| 'build-tools;24.0.3', |
| 'build-tools;24.0.2', |
| 'build-tools;24.0.1', |
| 'build-tools;24.0.0', |
| 'build-tools;23.0.2', |
| 'build-tools;23.0.1', |
| 'build-tools;23.0.0', |
| 'build-tools;22.0.1', |
| 'build-tools;22.0.0', |
| 'build-tools;21.1.2', |
| 'build-tools;21.1.1', |
| 'build-tools;21.1.0', |
| 'build-tools;21.0.0', |
| 'build-tools;20.0.0', |
| 'build-tools;19.1.0', |
| 'platforms;android-25', |
| 'platforms;android-24', |
| 'platforms;android-23', |
| 'platforms;android-22', |
| 'platforms;android-21', |
| 'platforms;android-20', |
| 'platforms;android-19', |
| 'platforms;android-18', |
| 'platforms;android-15', |
| 'add-ons;addon-google_apis-google-21', |
| 'add-ons;addon-google_apis-google-22', |
| 'add-ons;addon-google_apis-google-23', |
| 'add-ons;addon-google_apis-google-24', |
| 'extras;google;m2repository', |
| 'extras;android;m2repository', |
| 'cmake;3.6.3155560', |
| 'ndk-bundle', |
| ] |
| |
| println "Running SdkManagerCli with args " + args |
| } |
| } |
| } |
| |
| task initSdkForConnectedTestsStableChannel(type: JavaExec) { |
| standardInput = System.in |
| classpath = sourceSets.main.runtimeClasspath |
| main = "com.android.sdklib.tool.sdkmanager.SdkManagerCli" |
| |
| args = ['--sdk_root=' + System.getenv("ANDROID_SDK_ROOT"), |
| '--channel=0', |
| '--verbose', |
| 'system-images;android-26;google_apis;x86', |
| 'system-images;android-25;google_apis;x86', |
| 'system-images;android-19;default;x86', |
| 'tools', |
| 'platform-tools', |
| 'build-tools;30.0.2', |
| 'platforms;android-30', |
| 'platforms;android-27', |
| 'platforms;android-25', |
| 'platforms;android-24', |
| 'platforms;android-23', |
| 'platforms;android-22', |
| 'platforms;android-21', |
| 'platforms;android-20', |
| 'platforms;android-19', |
| 'platforms;android-18', |
| 'platforms;android-15', |
| 'add-ons;addon-google_apis-google-21', |
| 'add-ons;addon-google_apis-google-22', |
| 'add-ons;addon-google_apis-google-23', |
| 'add-ons;addon-google_apis-google-24', |
| 'extras;google;m2repository', |
| 'extras;google;instantapps', |
| 'extras;android;m2repository', |
| 'cmake;3.6.4111459', |
| 'ndk-bundle', |
| ] |
| } |
| |
| task initSdkForConnectedTestsUnstableChannel(type: JavaExec) { |
| standardInput = System.in |
| classpath = sourceSets.main.runtimeClasspath |
| main = "com.android.sdklib.tool.sdkmanager.SdkManagerCli" |
| |
| args = ['--sdk_root=' + System.getenv("ANDROID_SDK_ROOT"), |
| '--channel=2', |
| '--verbose', |
| 'platforms;android-30', |
| ] |
| } |
| |
| task initSdkForConnectedTests { |
| dependsOn initSdkForConnectedTestsStableChannel, initSdkForConnectedTestsUnstableChannel |
| } |
| |
| def offline_repo_files = ["extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2", |
| "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"] |
| |
| def offline_sdk_targets = [["macosx", "64", "darwin-x86_64"], |
| ["macosx", "32", "darwin-x86"], |
| ["windows", "64", "windows-x86_64"], |
| ["windows", "32", "windows"], |
| ["linux", "64", "linux-x86_64"], |
| ["linux", "32", "linux-x86"]] |
| |
| // Parent task to update the packages in prebuilts/tools/*/offline-sdk |
| // based on the values of offline_repo_files and offline_sdk_targets above. |
| task updateOfflineRepo {} |
| |
| offline_sdk_targets.each { config -> |
| def os = config[0] |
| def arch = config[1] |
| def dest = "$rootDir/../prebuilts/tools/" + config[2] + "/offline-sdk" |
| task "updateOfflineRepo$os$arch"(type: JavaExec) { |
| classpath = sourceSets.main.runtimeClasspath |
| main = "com.android.sdklib.tool.OfflineRepoCreator" |
| args = ["--dest", dest] + offline_repo_files |
| environment("REPO_OS_OVERRIDE", os) |
| systemProperties(ImmutableMap.of("os.arch", arch)) |
| } |
| updateOfflineRepo.dependsOn "updateOfflineRepo$os$arch" |
| } |
| |
| project.ext.pomName = 'Android Tools sdklib' |
| project.ext.pomDesc = 'A library to parse and download the Android SDK.' |