• Home
  • History
  • Annotate
  • 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
17import javax.tools.ToolProvider
18
19apply plugin: 'java'
20apply plugin: 'maven'
21
22group = 'com.android'
23version = '1.0.6'
24
25def currentJvmVersion = org.gradle.api.JavaVersion.current()
26if (currentJvmVersion.getMajorVersion() != "8") {
27  throw new Exception("Unsupported java version '" + currentJvmVersion.toString() + "'. Please install java 8.\n" +
28"\n" +
29"If you have already installed java 8, you can instruct Gradle to use it by setting the environment variable JAVA_HOME equal to its file path.")
30}
31
32/*
33 * With the build server you are given two env variables:
34 * 1. The OUT_DIR is a temporary directory you can use to put things during the build.
35 * 2. The DIST_DIR is where you want to save things from the build.
36 *
37 * The build server will copy the contents of DIST_DIR to somewhere and make it available.
38 */
39if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
40    buildDir = file("${System.env.OUT_DIR}/gradle/external/jdiff/build").getCanonicalFile()
41    ext.distDir = file(System.env.DIST_DIR).getCanonicalFile()
42
43    // The distDir is conveniently named after the build ID.
44    version = "${version}.${ext.distDir.name}"
45} else {
46    buildDir = file('../../out/host/gradle/external/jdiff/build')
47    ext.distDir = file('../../out/dist')
48
49    // Local builds are not public release candidates.
50    version = "${version}-SNAPSHOT"
51}
52
53/*
54 * If prebuilts are available, use them. Else, if this is unbundled build use jcenter().
55 * Finally, if none of that is true, attempt to compile against the full source trees.
56 */
57File m2repo = file('../../prebuilts/androidx/external')
58boolean unbundleBuild = (new File("unbundled-build")).exists()
59
60if (m2repo.exists() || unbundleBuild) {
61    repositories {
62        maven { url m2repo.absolutePath }
63        if (unbundleBuild) {
64            jcenter()
65        }
66    }
67
68    dependencies {
69        compile 'org.antlr:antlr:3.5.2'
70        compile 'com.google.jsilver:jsilver:1.0.0'
71        compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
72        // Transitive dependency required by jsilver.
73        compile 'com.google.guava:guava:15.0'
74    }
75} else {
76    dependencies {
77        compile project(path: ':antlr', configuration: 'antlrRuntime')
78        compile project(':jsilver')
79        compile project(':tagsoup')
80    }
81}
82
83
84dependencies {
85    testCompile 'junit:junit:4.12'
86
87    // tools.jar required for com.sun.javadoc
88    compile files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs())
89}
90
91sourceSets {
92    main {
93        java.srcDirs = ['src/']
94        resources.srcDirs = ['res/']
95    }
96    test {
97        java.srcDirs = ['test/']
98        resources.srcDirs = ['test/api']
99    }
100}
101
102uploadArchives {
103    repositories {
104        mavenDeployer {
105            repository(url: uri("${buildDir}/repo"))
106        }
107    }
108}
109
110task dist(type: Zip, dependsOn: uploadArchives)  {
111    group = BasePlugin.BUILD_GROUP
112    description 'Builds distribution artifacts.'
113
114    from uploadArchives.artifacts
115    destinationDir distDir
116
117    doLast {
118        logger.lifecycle "Compressed maven artifacts to ${archivePath}"
119    }
120}
121