-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.dart
60 lines (56 loc) · 1.56 KB
/
sync.dart
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import 'dart:io';
import 'package:dio/dio.dart';
void main(List<String> arguments) async {
var file = File('m2');
var baseUrl = 'http://localhost:8081/repository/m2/';
var version = '3.9.0.5';
var actifact = 'pangle';
var fragment = 'io/github/nullptrx/$actifact';
var vfragment = fragment + '/' + version;
var dir = Directory(file.path + '/' + fragment);
var vdir = Directory(file.path + '/' + vfragment);
if (!dir.existsSync()) {
dir.createSync(recursive: true);
}
if (!vdir.existsSync()) {
dir.createSync(recursive: true);
}
var files = [
'maven-metadata.xml',
'maven-metadata.xml.md5',
'maven-metadata.xml.sha1',
'maven-metadata.xml.sha256',
'maven-metadata.xml.sha512',
];
var dio = Dio(BaseOptions(baseUrl: baseUrl));
files.forEach((element) async {
try {
var urlPath = fragment + '/' + element;
var savePath = dir.path + '/' + element;
dio.download(urlPath, savePath);
} catch (e) {
print(e);
}
});
var vfiles = [
'$actifact-$version.aar',
'$actifact-$version.aar.md5',
'$actifact-$version.aar.sha1',
'$actifact-$version.aar.sha256',
'$actifact-$version.aar.sha512',
'$actifact-$version.pom',
'$actifact-$version.pom.md5',
'$actifact-$version.pom.sha1',
'$actifact-$version.pom.sha256',
'$actifact-$version.pom.sha512',
];
vfiles.forEach((element) {
try {
var savePath = vdir.path + '/' + element;
var urlPath = vfragment + '/' + element;
dio.download(urlPath, savePath);
} catch (e) {
print(e);
}
});
}