• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17apply plugin: 'com.android.library'
18
19def generatedResourceDir = project.file('generatedResource')
20def versionFile = new File(generatedResourceDir, 'androidsupportmultidexversion.txt')
21
22task makeVersionFile(type:Exec) {
23
24    doFirst {
25        versionFile.getParentFile().mkdirs()
26    }
27
28    outputs.files versionFile
29
30    commandLine 'sh', '-c', 'git log --format="%H" -n 1 || (echo git hash not available; exit 0)'
31    standardOutput = new ByteArrayOutputStream()
32
33    doLast {
34        versionFile.text = "git.version=" + standardOutput.toString()
35    }
36}
37
38android {
39    compileSdkVersion gradle.currentSdk
40
41    defaultConfig {
42        minSdkVersion 4
43    }
44
45    compileOptions {
46        sourceCompatibility JavaVersion.VERSION_1_7
47        targetCompatibility JavaVersion.VERSION_1_7
48    }
49
50    sourceSets {
51        main {
52            java.srcDirs         = ['src']
53            resources.srcDirs    = ['res', makeVersionFile.outputs]
54            res.srcDirs          = ['src']
55            manifest.srcFile 'AndroidManifest.xml'
56        }
57    }
58}
59
60android.libraryVariants.all { variant ->
61    variant.getJavaCompiler().dependsOn(makeVersionFile)
62
63    if (!name.equals(com.android.builder.core.BuilderConstants.RELEASE)) {
64        return // Skip non-release
65    }
66
67
68    def sourceJar = project.tasks.create(name: "sourceJarRelease", type: Jar) {
69        classifier = 'sources'
70        from android.sourceSets.main.java.srcDirs
71    }
72    artifacts.add("archives", sourceJar)
73}
74
75uploadArchives {
76    repositories {
77        mavenDeployer {
78            repository(url: uri(rootProject.ext.supportRepoOut)) {
79            }
80
81            pom.project {
82                name 'Android Multi-Dex Library'
83                description "Library for legacy multi-dex support"
84                url ''
85                inceptionYear '2013'
86
87                licenses {
88                    license {
89                        name 'The Apache Software License, Version 2.0'
90                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
91                        distribution 'repo'
92                    }
93                }
94
95                scm {
96                    url "http://source.android.com"
97                    connection "scm:git:https://android.googlesource.com/platform/frameworks/multidex"
98                }
99                developers {
100                    developer {
101                        name 'The Android Open Source Project'
102                    }
103                }
104            }
105        }
106    }
107}
108