xref: /aosp_15_r20/frameworks/multidex/build.gradle (revision e237af2cd5334d6a4fb2b14f52d22d4e70eb89b3)
1*e237af2cSAndroid Build Coastguard Worker/*
2*e237af2cSAndroid Build Coastguard Worker * Copyright (C) 2017 The Android Open Source Project
3*e237af2cSAndroid Build Coastguard Worker *
4*e237af2cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*e237af2cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*e237af2cSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*e237af2cSAndroid Build Coastguard Worker *
8*e237af2cSAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*e237af2cSAndroid Build Coastguard Worker *
10*e237af2cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*e237af2cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*e237af2cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*e237af2cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*e237af2cSAndroid Build Coastguard Worker * limitations under the License.
15*e237af2cSAndroid Build Coastguard Worker */
16*e237af2cSAndroid Build Coastguard Worker
17*e237af2cSAndroid Build Coastguard Workerimport org.gradle.internal.os.OperatingSystem
18*e237af2cSAndroid Build Coastguard Worker
19*e237af2cSAndroid Build Coastguard Workerbuildscript {
20*e237af2cSAndroid Build Coastguard Worker    repositories {
21*e237af2cSAndroid Build Coastguard Worker        maven { url '../../prebuilts/gradle-plugin' }
22*e237af2cSAndroid Build Coastguard Worker    }
23*e237af2cSAndroid Build Coastguard Worker    dependencies {
24*e237af2cSAndroid Build Coastguard Worker        classpath 'com.android.tools.build:gradle:3.0.1'
25*e237af2cSAndroid Build Coastguard Worker    }
26*e237af2cSAndroid Build Coastguard Worker}
27*e237af2cSAndroid Build Coastguard Worker
28*e237af2cSAndroid Build Coastguard Workerapply from: 'version.gradle'
29*e237af2cSAndroid Build Coastguard Worker
30*e237af2cSAndroid Build Coastguard WorkerString platform = OperatingSystem.current().isMacOsX() ? 'darwin' : 'linux'
31*e237af2cSAndroid Build Coastguard WorkerFile fullSdkPath = file("${rootDir}/../../prebuilts/fullsdk-${platform}")
32*e237af2cSAndroid Build Coastguard Workerif (!fullSdkPath.exists()) {
33*e237af2cSAndroid Build Coastguard Worker    throw GradleException("missing fullsdk")
34*e237af2cSAndroid Build Coastguard Worker}
35*e237af2cSAndroid Build Coastguard Worker
36*e237af2cSAndroid Build Coastguard Workergradle.ext.currentSdk = 28
37*e237af2cSAndroid Build Coastguard Workerext.buildToolsVersion = '27.0.3'
38*e237af2cSAndroid Build Coastguard Workerproject.ext.fullSdkPath = fullSdkPath
39*e237af2cSAndroid Build Coastguard Workerproject.ext.androidJar = files("${fullSdkPath}/platforms/android-${gradle.currentSdk}/android.jar")
40*e237af2cSAndroid Build Coastguard Worker
41*e237af2cSAndroid Build Coastguard WorkerFile props = file("local.properties")
42*e237af2cSAndroid Build Coastguard Workerprops.write "sdk.dir=${fullSdkPath.getAbsolutePath()}"
43*e237af2cSAndroid Build Coastguard Worker
44*e237af2cSAndroid Build Coastguard Worker/*
45*e237af2cSAndroid Build Coastguard Worker * With the build server you are given two env variables.
46*e237af2cSAndroid Build Coastguard Worker * The OUT_DIR is a temporary directory you can use to put things during the build.
47*e237af2cSAndroid Build Coastguard Worker * The DIST_DIR is where you want to save things from the build.
48*e237af2cSAndroid Build Coastguard Worker *
49*e237af2cSAndroid Build Coastguard Worker * The build server will copy the contents of DIST_DIR to somewhere and make it available.
50*e237af2cSAndroid Build Coastguard Worker */
51*e237af2cSAndroid Build Coastguard Workerif (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
52*e237af2cSAndroid Build Coastguard Worker    buildDir = new File(System.env.OUT_DIR + '/gradle/frameworks/support/build').getCanonicalFile()
53*e237af2cSAndroid Build Coastguard Worker    project.ext.distDir = new File(System.env.DIST_DIR).getCanonicalFile()
54*e237af2cSAndroid Build Coastguard Worker} else {
55*e237af2cSAndroid Build Coastguard Worker    buildDir = file('../../out/host/gradle/frameworks/support/build')
56*e237af2cSAndroid Build Coastguard Worker    project.ext.distDir = file('../../out/dist')
57*e237af2cSAndroid Build Coastguard Worker}
58*e237af2cSAndroid Build Coastguard Worker
59*e237af2cSAndroid Build Coastguard Workerext.supportRepoOut = new File(buildDir, 'support_repo')
60*e237af2cSAndroid Build Coastguard Worker
61*e237af2cSAndroid Build Coastguard Worker// upload anchor for subprojects to upload their artifacts
62*e237af2cSAndroid Build Coastguard Worker// to the local repo.
63*e237af2cSAndroid Build Coastguard Workertask dist(type: Zip)  {
64*e237af2cSAndroid Build Coastguard Worker    group = BasePlugin.BUILD_GROUP
65*e237af2cSAndroid Build Coastguard Worker    description 'Builds distribution artifacts.'
66*e237af2cSAndroid Build Coastguard Worker
67*e237af2cSAndroid Build Coastguard Worker    from project.ext.supportRepoOut
68*e237af2cSAndroid Build Coastguard Worker    into 'm2repository'
69*e237af2cSAndroid Build Coastguard Worker    destinationDir project.ext.distDir
70*e237af2cSAndroid Build Coastguard Worker    baseName = String.format("top-of-tree-m2repository-%s", project.multidexVersion)
71*e237af2cSAndroid Build Coastguard Worker
72*e237af2cSAndroid Build Coastguard Worker    doLast {
73*e237af2cSAndroid Build Coastguard Worker        logger.warn "Compressed maven artifacts to ${archivePath}"
74*e237af2cSAndroid Build Coastguard Worker    }
75*e237af2cSAndroid Build Coastguard Worker}
76*e237af2cSAndroid Build Coastguard Worker
77*e237af2cSAndroid Build Coastguard Workersubprojects {
78*e237af2cSAndroid Build Coastguard Worker    // Change buildDir first so that all plugins pick up the new value.
79*e237af2cSAndroid Build Coastguard Worker    project.buildDir = project.file("${project.parent.buildDir}/../${project.name}/build")
80*e237af2cSAndroid Build Coastguard Worker
81*e237af2cSAndroid Build Coastguard Worker    apply plugin: 'maven'
82*e237af2cSAndroid Build Coastguard Worker
83*e237af2cSAndroid Build Coastguard Worker    version = rootProject.multidexVersion
84*e237af2cSAndroid Build Coastguard Worker    group = 'androidx.multidex'
85*e237af2cSAndroid Build Coastguard Worker
86*e237af2cSAndroid Build Coastguard Worker    dist.dependsOn project.tasks.uploadArchives
87*e237af2cSAndroid Build Coastguard Worker
88*e237af2cSAndroid Build Coastguard Worker    project.plugins.whenPluginAdded { plugin ->
89*e237af2cSAndroid Build Coastguard Worker        if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
90*e237af2cSAndroid Build Coastguard Worker            project.android.buildToolsVersion = rootProject.buildToolsVersion
91*e237af2cSAndroid Build Coastguard Worker        }
92*e237af2cSAndroid Build Coastguard Worker    }
93*e237af2cSAndroid Build Coastguard Worker}
94