xref: /aosp_15_r20/frameworks/multidex/library/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 Workerapply plugin: 'com.android.library'
18*e237af2cSAndroid Build Coastguard Worker
19*e237af2cSAndroid Build Coastguard Workerdef generatedResourceDir = project.file('generatedResource')
20*e237af2cSAndroid Build Coastguard Workerdef versionFile = new File(generatedResourceDir, 'androidsupportmultidexversion.txt')
21*e237af2cSAndroid Build Coastguard Worker
22*e237af2cSAndroid Build Coastguard Workertask makeVersionFile(type:Exec) {
23*e237af2cSAndroid Build Coastguard Worker
24*e237af2cSAndroid Build Coastguard Worker    doFirst {
25*e237af2cSAndroid Build Coastguard Worker        versionFile.getParentFile().mkdirs()
26*e237af2cSAndroid Build Coastguard Worker    }
27*e237af2cSAndroid Build Coastguard Worker
28*e237af2cSAndroid Build Coastguard Worker    outputs.files versionFile
29*e237af2cSAndroid Build Coastguard Worker
30*e237af2cSAndroid Build Coastguard Worker    commandLine 'sh', '-c', 'git log --format="%H" -n 1 || (echo git hash not available; exit 0)'
31*e237af2cSAndroid Build Coastguard Worker    standardOutput = new ByteArrayOutputStream()
32*e237af2cSAndroid Build Coastguard Worker
33*e237af2cSAndroid Build Coastguard Worker    doLast {
34*e237af2cSAndroid Build Coastguard Worker        versionFile.text = "git.version=" + standardOutput.toString()
35*e237af2cSAndroid Build Coastguard Worker    }
36*e237af2cSAndroid Build Coastguard Worker}
37*e237af2cSAndroid Build Coastguard Worker
38*e237af2cSAndroid Build Coastguard Workerandroid {
39*e237af2cSAndroid Build Coastguard Worker    compileSdkVersion gradle.currentSdk
40*e237af2cSAndroid Build Coastguard Worker
41*e237af2cSAndroid Build Coastguard Worker    defaultConfig {
42*e237af2cSAndroid Build Coastguard Worker        minSdkVersion 4
43*e237af2cSAndroid Build Coastguard Worker    }
44*e237af2cSAndroid Build Coastguard Worker
45*e237af2cSAndroid Build Coastguard Worker    compileOptions {
46*e237af2cSAndroid Build Coastguard Worker        sourceCompatibility JavaVersion.VERSION_1_7
47*e237af2cSAndroid Build Coastguard Worker        targetCompatibility JavaVersion.VERSION_1_7
48*e237af2cSAndroid Build Coastguard Worker    }
49*e237af2cSAndroid Build Coastguard Worker
50*e237af2cSAndroid Build Coastguard Worker    sourceSets {
51*e237af2cSAndroid Build Coastguard Worker        main {
52*e237af2cSAndroid Build Coastguard Worker            java.srcDirs         = ['src']
53*e237af2cSAndroid Build Coastguard Worker            resources.srcDirs    = ['res', makeVersionFile.outputs]
54*e237af2cSAndroid Build Coastguard Worker            res.srcDirs          = ['src']
55*e237af2cSAndroid Build Coastguard Worker            manifest.srcFile 'AndroidManifest.xml'
56*e237af2cSAndroid Build Coastguard Worker        }
57*e237af2cSAndroid Build Coastguard Worker    }
58*e237af2cSAndroid Build Coastguard Worker}
59*e237af2cSAndroid Build Coastguard Worker
60*e237af2cSAndroid Build Coastguard Workerandroid.libraryVariants.all { variant ->
61*e237af2cSAndroid Build Coastguard Worker    variant.getJavaCompiler().dependsOn(makeVersionFile)
62*e237af2cSAndroid Build Coastguard Worker
63*e237af2cSAndroid Build Coastguard Worker    if (!name.equals(com.android.builder.core.BuilderConstants.RELEASE)) {
64*e237af2cSAndroid Build Coastguard Worker        return // Skip non-release
65*e237af2cSAndroid Build Coastguard Worker    }
66*e237af2cSAndroid Build Coastguard Worker
67*e237af2cSAndroid Build Coastguard Worker
68*e237af2cSAndroid Build Coastguard Worker    def sourceJar = project.tasks.create(name: "sourceJarRelease", type: Jar) {
69*e237af2cSAndroid Build Coastguard Worker        classifier = 'sources'
70*e237af2cSAndroid Build Coastguard Worker        from android.sourceSets.main.java.srcDirs
71*e237af2cSAndroid Build Coastguard Worker    }
72*e237af2cSAndroid Build Coastguard Worker    artifacts.add("archives", sourceJar)
73*e237af2cSAndroid Build Coastguard Worker}
74*e237af2cSAndroid Build Coastguard Worker
75*e237af2cSAndroid Build Coastguard WorkeruploadArchives {
76*e237af2cSAndroid Build Coastguard Worker    repositories {
77*e237af2cSAndroid Build Coastguard Worker        mavenDeployer {
78*e237af2cSAndroid Build Coastguard Worker            repository(url: uri(rootProject.ext.supportRepoOut)) {
79*e237af2cSAndroid Build Coastguard Worker            }
80*e237af2cSAndroid Build Coastguard Worker
81*e237af2cSAndroid Build Coastguard Worker            pom.project {
82*e237af2cSAndroid Build Coastguard Worker                name 'Android Multi-Dex Library'
83*e237af2cSAndroid Build Coastguard Worker                description "Library for legacy multi-dex support"
84*e237af2cSAndroid Build Coastguard Worker                url ''
85*e237af2cSAndroid Build Coastguard Worker                inceptionYear '2013'
86*e237af2cSAndroid Build Coastguard Worker
87*e237af2cSAndroid Build Coastguard Worker                licenses {
88*e237af2cSAndroid Build Coastguard Worker                    license {
89*e237af2cSAndroid Build Coastguard Worker                        name 'The Apache Software License, Version 2.0'
90*e237af2cSAndroid Build Coastguard Worker                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
91*e237af2cSAndroid Build Coastguard Worker                        distribution 'repo'
92*e237af2cSAndroid Build Coastguard Worker                    }
93*e237af2cSAndroid Build Coastguard Worker                }
94*e237af2cSAndroid Build Coastguard Worker
95*e237af2cSAndroid Build Coastguard Worker                scm {
96*e237af2cSAndroid Build Coastguard Worker                    url "http://source.android.com"
97*e237af2cSAndroid Build Coastguard Worker                    connection "scm:git:https://android.googlesource.com/platform/frameworks/multidex"
98*e237af2cSAndroid Build Coastguard Worker                }
99*e237af2cSAndroid Build Coastguard Worker                developers {
100*e237af2cSAndroid Build Coastguard Worker                    developer {
101*e237af2cSAndroid Build Coastguard Worker                        name 'The Android Open Source Project'
102*e237af2cSAndroid Build Coastguard Worker                    }
103*e237af2cSAndroid Build Coastguard Worker                }
104*e237af2cSAndroid Build Coastguard Worker            }
105*e237af2cSAndroid Build Coastguard Worker        }
106*e237af2cSAndroid Build Coastguard Worker    }
107*e237af2cSAndroid Build Coastguard Worker}
108