forked from ProtocolSupport/ProtocolSupport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.gradle
38 lines (30 loc) · 937 Bytes
/
helper.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.text.MessageFormat
class UpdateLibrariesTask extends DefaultTask {
File directory
List<Map> libraries
@TaskAction
def update() {
Set<String> librariesNames = new HashSet<>()
libraries.each({
String url = it.get("url")
String libraryName = it.get("name")
librariesNames.add(libraryName)
File libraryFile = new File(directory, libraryName)
if (!libraryFile.exists()) {
logger.lifecycle(MessageFormat.format("Downloading library {0} from {1}", libraryName, url))
ant.get(src: url, dest: libraryFile)
} else {
logger.lifecycle(MessageFormat.format("Skipping download of library {0} because it already exists", libraryName))
}
})
directory.listFiles()
.findAll({
!librariesNames.contains(it.getName())
})
.each({
logger.lifecycle(MessageFormat.format("Deleting old library {0}", it.getName()))
it.delete()
})
}
}
ext.UpdateLibrariesTask = UpdateLibrariesTask