blob: 3096e0ee193011f1a15f91fbf2cd48ab44805e50 [file] [log] [blame]
Alan Viveretted2631a32017-03-13 13:04:44 -04001/*
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 */
Adam Metcalfca26d472013-07-19 11:42:47 -070016
Alan Viverette4230fe12016-06-02 14:15:00 -040017import javax.tools.ToolProvider
C. Sean Young4a42aef2015-06-10 10:43:26 -050018
Alan Viveretted2631a32017-03-13 13:04:44 -040019apply plugin: 'java'
20apply plugin: 'maven'
21
22group = 'com.android'
23version = '1.0.6'
24
Jeff Gaston0e1bc952018-06-22 13:08:12 -040025def 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
Alan Viveretted2631a32017-03-13 13:04:44 -040032/*
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"
Alan Viverette96c53522016-11-30 11:23:17 -050051}
52
Alan Viveretted2631a32017-03-13 13:04:44 -040053/*
Aurimas Liutikasce9bbbe2018-01-19 10:49:56 -080054 * 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.
Alan Viveretted2631a32017-03-13 13:04:44 -040056 */
Aurimas Liutikas1b9c8b92018-07-16 15:13:55 -070057File m2repo = file('../../prebuilts/androidx/external')
Aurimas Liutikasce9bbbe2018-01-19 10:49:56 -080058boolean unbundleBuild = (new File("unbundled-build")).exists()
59
60if (m2repo.exists() || unbundleBuild) {
Nick Korostelev845d3ad2014-08-26 19:06:16 -070061 repositories {
Alan Viveretted2631a32017-03-13 13:04:44 -040062 maven { url m2repo.absolutePath }
Aurimas Liutikasce9bbbe2018-01-19 10:49:56 -080063 if (unbundleBuild) {
64 jcenter()
65 }
Nick Korostelev845d3ad2014-08-26 19:06:16 -070066 }
67
68 dependencies {
Alan Viverette4230fe12016-06-02 14:15:00 -040069 compile 'org.antlr:antlr:3.5.2'
Nick Korostelev845d3ad2014-08-26 19:06:16 -070070 compile 'com.google.jsilver:jsilver:1.0.0'
Alan Viverette4230fe12016-06-02 14:15:00 -040071 compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
Alan Viveretted2631a32017-03-13 13:04:44 -040072 // Transitive dependency required by jsilver.
Nick Korostelev845d3ad2014-08-26 19:06:16 -070073 compile 'com.google.guava:guava:15.0'
Nick Korostelev845d3ad2014-08-26 19:06:16 -070074 }
75} else {
76 dependencies {
Nick Korostelev845d3ad2014-08-26 19:06:16 -070077 compile project(path: ':antlr', configuration: 'antlrRuntime')
78 compile project(':jsilver')
79 compile project(':tagsoup')
80 }
81}
Alan Viveretted2631a32017-03-13 13:04:44 -040082
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}