blob: 106d916504428fb8f4d529f4d22de24424d4345f [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
25/*
26 * With the build server you are given two env variables:
27 * 1. The OUT_DIR is a temporary directory you can use to put things during the build.
28 * 2. The DIST_DIR is where you want to save things from the build.
29 *
30 * The build server will copy the contents of DIST_DIR to somewhere and make it available.
31 */
32if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
33 buildDir = file("${System.env.OUT_DIR}/gradle/external/jdiff/build").getCanonicalFile()
34 ext.distDir = file(System.env.DIST_DIR).getCanonicalFile()
35
36 // The distDir is conveniently named after the build ID.
37 version = "${version}.${ext.distDir.name}"
38} else {
39 buildDir = file('../../out/host/gradle/external/jdiff/build')
40 ext.distDir = file('../../out/dist')
41
42 // Local builds are not public release candidates.
43 version = "${version}-SNAPSHOT"
Alan Viverette96c53522016-11-30 11:23:17 -050044}
45
Alan Viveretted2631a32017-03-13 13:04:44 -040046/*
Aurimas Liutikasce9bbbe2018-01-19 10:49:56 -080047 * If prebuilts are available, use them. Else, if this is unbundled build use jcenter().
48 * Finally, if none of that is true, attempt to compile against the full source trees.
Alan Viveretted2631a32017-03-13 13:04:44 -040049 */
50File m2repo = file('../../prebuilts/tools/common/m2/repository')
Aurimas Liutikasce9bbbe2018-01-19 10:49:56 -080051boolean unbundleBuild = (new File("unbundled-build")).exists()
52
53if (m2repo.exists() || unbundleBuild) {
Nick Korostelev845d3ad2014-08-26 19:06:16 -070054 repositories {
Alan Viveretted2631a32017-03-13 13:04:44 -040055 maven { url m2repo.absolutePath }
Aurimas Liutikasce9bbbe2018-01-19 10:49:56 -080056 if (unbundleBuild) {
57 jcenter()
58 }
Nick Korostelev845d3ad2014-08-26 19:06:16 -070059 }
60
61 dependencies {
Alan Viverette4230fe12016-06-02 14:15:00 -040062 compile 'org.antlr:antlr:3.5.2'
Nick Korostelev845d3ad2014-08-26 19:06:16 -070063 compile 'com.google.jsilver:jsilver:1.0.0'
Alan Viverette4230fe12016-06-02 14:15:00 -040064 compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
Alan Viveretted2631a32017-03-13 13:04:44 -040065 // Transitive dependency required by jsilver.
Nick Korostelev845d3ad2014-08-26 19:06:16 -070066 compile 'com.google.guava:guava:15.0'
Nick Korostelev845d3ad2014-08-26 19:06:16 -070067 }
68} else {
69 dependencies {
Nick Korostelev845d3ad2014-08-26 19:06:16 -070070 compile project(path: ':antlr', configuration: 'antlrRuntime')
71 compile project(':jsilver')
72 compile project(':tagsoup')
73 }
74}
Alan Viveretted2631a32017-03-13 13:04:44 -040075
76
77dependencies {
78 testCompile 'junit:junit:4.12'
79
80 // tools.jar required for com.sun.javadoc
81 compile files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs())
82}
83
84sourceSets {
85 main {
86 java.srcDirs = ['src/']
87 resources.srcDirs = ['res/']
88 }
89 test {
90 java.srcDirs = ['test/']
91 resources.srcDirs = ['test/api']
92 }
93}
94
95uploadArchives {
96 repositories {
97 mavenDeployer {
98 repository(url: uri("${buildDir}/repo"))
99 }
100 }
101}
102
103task dist(type: Zip, dependsOn: uploadArchives) {
104 group = BasePlugin.BUILD_GROUP
105 description 'Builds distribution artifacts.'
106
107 from uploadArchives.artifacts
108 destinationDir distDir
109
110 doLast {
111 logger.lifecycle "Compressed maven artifacts to ${archivePath}"
112 }
113}