Skip to content

Commit

Permalink
BLADE-743 cli: ReleaseUtil: adjusts priority, and adds an option for …
Browse files Browse the repository at this point in the history
…an environment var
  • Loading branch information
drewbrokke committed Apr 4, 2024
1 parent d0f3b30 commit 670b2ef
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions cli/src/main/java/com/liferay/blade/cli/util/ReleaseUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ public static ReleaseEntry getReleaseEntry(String releaseKey) {
return _releaseUtil._releaseEntryMap.getOrDefault(releaseKey, _EMPTY_RELEASE_ENTRY);
}

public static void refreshReleases() {
System.out.println("Checking for new releases...");

_releaseUtil = new ReleaseUtil(0);
public static void populateReleases(int maxAge) {
_releaseUtil = new ReleaseUtil(maxAge);
}

public static Stream<ReleaseEntry> releaseEntriesStream() {
Expand Down Expand Up @@ -101,12 +99,13 @@ private ReleaseUtil(int maxAge) {
File releasesJsonFile = new File(_workspaceCacheDir, "releases.json");

_releaseEntries = ResourceUtil.readJson(
ReleaseEntries.class, ResourceUtil.getLocalFileResolver(releasesJsonFile, maxAge, ChronoUnit.DAYS),
ResourceUtil.getURLResolver(
_workspaceCacheDir, "https://releases.liferay.com/releases.json", "releases.json"),
ReleaseEntries.class, ResourceUtil.getLocalFileResolver(System.getenv("BLADE_LOCAL_RELEASES_JSON_FILE")),
ResourceUtil.getLocalFileResolver(releasesJsonFile, maxAge, ChronoUnit.DAYS),
ResourceUtil.getURLResolver(
_workspaceCacheDir, "https://releases-cdn.liferay.com/releases.json", "releases.json"),
ResourceUtil.getLocalFileResolver(releasesJsonFile), ResourceUtil.getClassLoaderResolver("/releases.json"));
ResourceUtil.getURLResolver(
_workspaceCacheDir, "https://releases.liferay.com/releases.json", "releases.json"),
ResourceUtil.getClassLoaderResolver("/releases.json"));

if (_releaseEntries == null) {
throw new RuntimeException("Could not find releases.json");
Expand All @@ -121,7 +120,7 @@ private ReleaseUtil(int maxAge) {

private static final ReleaseEntry _EMPTY_RELEASE_ENTRY = new ReleaseEntry();

private static ReleaseUtil _releaseUtil = new ReleaseUtil(7);
private static ReleaseUtil _releaseUtil;

private final ReleaseEntries _releaseEntries;
private final Map<String, ReleaseEntry> _releaseEntryMap = new HashMap<>();
Expand Down

0 comments on commit 670b2ef

Please sign in to comment.