| author | Da Risk <da_risk@geekorum.com> |
| Sat, 09 May 2020 01:47:14 -0400 | |
| changeset 6 | 99ad8c14fec2 |
| parent 1 | 831cffa9c991 |
| child 20 | 5d8a0555733d |
| permissions | -rw-r--r-- |
|
6
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
1 |
/* |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
2 |
* Geekdroid is a utility library for development on the Android |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
3 |
* Platform. |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
4 |
* |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
5 |
* Copyright (C) 2017-2020 by Frederic-Charles Barthelery. |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
6 |
* |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
7 |
* This file is part of Geekdroid. |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
8 |
* |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
9 |
* Geekdroid is free software: you can redistribute it and/or modify |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
10 |
* it under the terms of the GNU General Public License as published by |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
11 |
* the Free Software Foundation, either version 3 of the License, or |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
12 |
* (at your option) any later version. |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
13 |
* |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
14 |
* Geekdroid is distributed in the hope that it will be useful, |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
17 |
* GNU General Public License for more details. |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
18 |
* |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
20 |
* along with Geekdroid. If not, see <http://www.gnu.org/licenses/>. |
|
99ad8c14fec2
Add missing source license headers
Da Risk <da_risk@geekorum.com>
parents:
1
diff
changeset
|
21 |
*/ |
| 1 | 22 |
task sourceArchive {
|
23 |
description "Get the source archive of the project" |
|
24 |
} |
|
25 |
||
26 |
sourceArchive.doLast {
|
|
27 |
makeSourceArchive(rootProject.name) |
|
28 |
} |
|
29 |
||
30 |
project.build.dependsOn sourceArchive |
|
31 |
||
32 |
def makeSourceArchive(String projectName) {
|
|
33 |
def git = new File(".git")
|
|
34 |
def hg = new File(".hg")
|
|
35 |
def tag |
|
36 |
if (git.exists()) {
|
|
37 |
tag = getGitSha1() |
|
38 |
println("Building source archive \"${projectName}-src-${tag}.zip\" from git")
|
|
39 |
exec {
|
|
40 |
workingDir project.rootDir |
|
41 |
commandLine "git", "archive", "--format=zip", "--prefix=${projectName}-src-${tag}/", "-o", "${projectName}-src-${tag}.zip", "HEAD"
|
|
42 |
} |
|
43 |
} else if (hg.exists()) {
|
|
44 |
tag = getHgSha1() |
|
45 |
println("Building source archive \"${projectName}-src-${tag}.zip\" from hg")
|
|
46 |
exec {
|
|
47 |
workingDir project.rootDir |
|
48 |
commandLine "hg", "archive", "-t", "zip", "-r", tag, "${projectName}-src-${tag}.zip"
|
|
49 |
} |
|
50 |
} |
|
51 |
} |
|
52 |
||
53 |
def getGitSha1() {
|
|
54 |
return 'git rev-parse HEAD'.execute().text.trim() |
|
55 |
} |
|
56 |
||
57 |
def getHgSha1() {
|
|
58 |
return 'hg id --debug -i -r .'.execute().text.trim() |
|
59 |
} |