Alan Viverette | d2631a3 | 2017-03-13 13:04:44 -0400 | [diff] [blame] | 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 | */ |
Adam Metcalf | ca26d47 | 2013-07-19 11:42:47 -0700 | [diff] [blame] | 16 | |
Alan Viverette | 4230fe1 | 2016-06-02 14:15:00 -0400 | [diff] [blame] | 17 | import javax.tools.ToolProvider |
C. Sean Young | 4a42aef | 2015-06-10 10:43:26 -0500 | [diff] [blame] | 18 | |
Alan Viverette | d2631a3 | 2017-03-13 13:04:44 -0400 | [diff] [blame] | 19 | apply plugin: 'java' |
| 20 | apply plugin: 'maven' |
| 21 | |
| 22 | group = 'com.android' |
| 23 | version = '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 | */ |
| 32 | if (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 Viverette | 96c5352 | 2016-11-30 11:23:17 -0500 | [diff] [blame] | 44 | } |
| 45 | |
Alan Viverette | d2631a3 | 2017-03-13 13:04:44 -0400 | [diff] [blame] | 46 | /* |
| 47 | * If prebuilts are available, use them. Otherwise, attempt to compile against |
| 48 | * the full source trees. |
| 49 | */ |
| 50 | File m2repo = file('../../prebuilts/tools/common/m2/repository') |
| 51 | if (m2repo.exists()) { |
Nick Korostelev | 845d3ad | 2014-08-26 19:06:16 -0700 | [diff] [blame] | 52 | repositories { |
Alan Viverette | d2631a3 | 2017-03-13 13:04:44 -0400 | [diff] [blame] | 53 | maven { url m2repo.absolutePath } |
Nick Korostelev | 845d3ad | 2014-08-26 19:06:16 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | dependencies { |
Alan Viverette | 4230fe1 | 2016-06-02 14:15:00 -0400 | [diff] [blame] | 57 | compile 'org.antlr:antlr:3.5.2' |
Nick Korostelev | 845d3ad | 2014-08-26 19:06:16 -0700 | [diff] [blame] | 58 | compile 'com.google.jsilver:jsilver:1.0.0' |
Alan Viverette | 4230fe1 | 2016-06-02 14:15:00 -0400 | [diff] [blame] | 59 | compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1' |
Alan Viverette | d2631a3 | 2017-03-13 13:04:44 -0400 | [diff] [blame] | 60 | // Transitive dependency required by jsilver. |
Nick Korostelev | 845d3ad | 2014-08-26 19:06:16 -0700 | [diff] [blame] | 61 | compile 'com.google.guava:guava:15.0' |
Nick Korostelev | 845d3ad | 2014-08-26 19:06:16 -0700 | [diff] [blame] | 62 | } |
| 63 | } else { |
| 64 | dependencies { |
Nick Korostelev | 845d3ad | 2014-08-26 19:06:16 -0700 | [diff] [blame] | 65 | compile project(path: ':antlr', configuration: 'antlrRuntime') |
| 66 | compile project(':jsilver') |
| 67 | compile project(':tagsoup') |
| 68 | } |
| 69 | } |
Alan Viverette | d2631a3 | 2017-03-13 13:04:44 -0400 | [diff] [blame] | 70 | |
| 71 | |
| 72 | dependencies { |
| 73 | testCompile 'junit:junit:4.12' |
| 74 | |
| 75 | // tools.jar required for com.sun.javadoc |
| 76 | compile files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs()) |
| 77 | } |
| 78 | |
| 79 | sourceSets { |
| 80 | main { |
| 81 | java.srcDirs = ['src/'] |
| 82 | resources.srcDirs = ['res/'] |
| 83 | } |
| 84 | test { |
| 85 | java.srcDirs = ['test/'] |
| 86 | resources.srcDirs = ['test/api'] |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | uploadArchives { |
| 91 | repositories { |
| 92 | mavenDeployer { |
| 93 | repository(url: uri("${buildDir}/repo")) |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | task dist(type: Zip, dependsOn: uploadArchives) { |
| 99 | group = BasePlugin.BUILD_GROUP |
| 100 | description 'Builds distribution artifacts.' |
| 101 | |
| 102 | from uploadArchives.artifacts |
| 103 | destinationDir distDir |
| 104 | |
| 105 | doLast { |
| 106 | logger.lifecycle "Compressed maven artifacts to ${archivePath}" |
| 107 | } |
| 108 | } |