blob: d37603954707c562870fa2fcda8c609ebd9a0c42 [file] [log] [blame]
Yigit Boyar88c16ce2017-02-08 16:06:14 -08001/*
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 */
Aurimas Liutikas76542da2017-06-29 17:00:29 -070016// upload anchor for subprojects to upload their artifacts to the local repo.
Yigit Boyar88c16ce2017-02-08 16:06:14 -080017task(mainUpload)
18
Aurimas Liutikas76542da2017-06-29 17:00:29 -070019task createArchive(type : Zip) {
Yigit Boyar78e026c2017-03-06 16:19:15 -080020 description "Creates a maven repository that includes just the libraries compiled in this" +
21 " project, without any history from prebuilts."
Aurimas Liutikas279780d2017-08-09 14:03:59 -070022 from rootProject.ext.supportRepoOut
Yigit Boyar78e026c2017-03-06 16:19:15 -080023 destinationDir rootProject.ext.distDir
24 into 'm2repository'
25 baseName = String.format("top-of-tree-m2repository-%s", project.ext.buildNumber)
26 dependsOn mainUpload
27}
28
Yigit Boyara9ac19d2017-09-20 16:11:49 -070029task createDiffArchive(type : Zip) {
30 description "Creates a maven repository that includes just the libraries compiled in this" +
31 " project without any libraries that are already on maven.google.com. If you need " +
32 " a full repo, use createArchive task."
33 dependsOn mainUpload
34 /**
35 * building filters in a doFirst block so that we can query the output of other tasks and also
36 * not query maven.google unless task runs.
37 */
38 doFirst {
39 def includeFilters = subprojects.collect { it.tasks.withType(Upload) }.findResults {
40 def group = it.project.group[0]
41 def archiveName = it.project.name[0]
42 def version = it.project.version[0]
43 if (group == null || archiveName == null || version == null) {
44 logger.info "null artifact info for ${it.project.path}"
45 return null
46 }
47 def subFolder = group.replace('.', '/') + "/" + archiveName + "/" + version
48 def localFolder = new File(rootProject.ext.supportRepoOut, subFolder)
49 if (!localFolder.exists()) {
50 // no reason to check, not even built
51 logger.info "skipping $subFolder because it does not exist"
52 return null
53 }
54 // query maven.google to check if it is released.
55 if (rootProject.ext.versionChecker.isReleased(group, archiveName, version)) {
56 logger.info "looks like $subFolder is released, skipping"
57 return null
58 } else {
59 logger.info "adding $subFolder to partial maven zip because it cannot be found on" +
60 " maven.google.com"
61 }
62 return subFolder + "/**"
63 }
64 logger.info "include filters for diff maven zip ${includeFilters}"
65 includeFilters.forEach {
66 include it
67 }
Yigit Boyarf2505642017-10-27 13:56:02 -070068 if (includeFilters.isEmpty()) {
69 // not providing any include would mean include everything so we provide a dummy
70 // include constraint.
71 include "do-not-include-anything"
72 }
Yigit Boyara9ac19d2017-09-20 16:11:49 -070073 }
74 from rootProject.ext.supportRepoOut
75 destinationDir rootProject.ext.distDir
76 into 'm2repository'
77 baseName = String.format("gmaven-diff-top-of-tree-m2repository-%s", project.ext.buildNumber)
78 dependsOn mainUpload
79}
80
Aurimas Liutikas76542da2017-06-29 17:00:29 -070081// anchor for prepare repo. This is post unzip.
82task prepareRepo() {
Yigit Boyar78e026c2017-03-06 16:19:15 -080083 description "This task clears the repo folder to ensure that we run a fresh build every" +
84 " time we create arhives. Otherwise, snapshots will accumulate in the builds folder."
85 doFirst {
86 rootProject.ext.supportRepoOut.deleteDir()
87 rootProject.ext.supportRepoOut.mkdirs()
88 }
89}