mirror of
https://github.com/CarmJos/GithubReleases4J.git
synced 2024-09-19 21:55:45 +00:00
[v1.0.0] 添加下载DEBUG信息
This commit is contained in:
parent
c26250cf58
commit
0f029104a6
@ -7,9 +7,11 @@ import org.junit.Test;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GithubReleasesTest {
|
public class GithubReleasesTest {
|
||||||
|
|
||||||
|
public static boolean DOWNLOAD = true;
|
||||||
public static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
public static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -21,13 +23,7 @@ public class GithubReleasesTest {
|
|||||||
GithubRelease release = GithubReleases4J.getLatestRelease("CarmJos", "UltraDepository");
|
GithubRelease release = GithubReleases4J.getLatestRelease("CarmJos", "UltraDepository");
|
||||||
if (release != null) {
|
if (release != null) {
|
||||||
printInfo(release);
|
printInfo(release);
|
||||||
release.getAssets().stream().findFirst().ifPresent(githubAsset -> {
|
release.getAssets().stream().findFirst().ifPresent(GithubReleasesTest::downloadAssets);
|
||||||
try {
|
|
||||||
File file = githubAsset.download(null);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -37,8 +33,8 @@ public class GithubReleasesTest {
|
|||||||
if (release == null) System.out.println("# NULL");
|
if (release == null) System.out.println("# NULL");
|
||||||
else {
|
else {
|
||||||
System.out.println("# " + release.getName() + " [" + FORMAT.format(release.getCreateTime()) + "]");
|
System.out.println("# " + release.getName() + " [" + FORMAT.format(release.getCreateTime()) + "]");
|
||||||
// List<GithubAsset> assets = release.getAssets();
|
List<GithubAsset> assets = release.getAssets();
|
||||||
// assets.forEach(GithubReleasesTest::printAssets);
|
assets.forEach(GithubReleasesTest::printAssets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,5 +45,16 @@ public class GithubReleasesTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void downloadAssets(@Nullable GithubAsset assets) {
|
||||||
|
if (!DOWNLOAD) return;
|
||||||
|
if (assets == null) return;
|
||||||
|
try {
|
||||||
|
File file = assets.download(null);
|
||||||
|
System.out.println("- at " + file.getAbsolutePath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user