Skip to content

Commit

Permalink
Fix double resolve (#1553)
Browse files Browse the repository at this point in the history
* fix: don't resolve twice

When runing a previously built app jbang would sometimes resolve twice

* chore: minor cleanup

* chore: added a bit more logging info

Jbang now prints out which artifacts were out of date and why when
comparing dependencies against the cache,
  • Loading branch information
quintesse authored Feb 2, 2023
1 parent 47b43ca commit 7b978e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
11 changes: 11 additions & 0 deletions src/main/java/dev/jbang/dependencies/DependencyCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ public static List<ArtifactInfo> findDependenciesByHash(String depsHash) {
return cachedCP;
} else {
warnMsg("Detected missing or out-of-date dependencies in cache.");
if (Util.isVerbose()) {
cachedCP.stream().filter(ai -> !ai.isUpToDate()).forEach(ai -> {
if (Files.isReadable(ai.getFile())) {
Util.verboseMsg(" Artifact not found in local cache: " + ai.getFile());
} else {
Util.verboseMsg(
" Artifact out of date: " + ai.getFile() + " : " + ai.getTimestamp() + " != "
+ ai.getFile().toFile().lastModified());
}
});
}
}
}
return null;
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/dev/jbang/dependencies/DependencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ public class DependencyUtil {
private DependencyUtil() {
}

/**
*
* @param deps
* @param repos
* @param loggingEnabled
* @return string with resolved classpath
*/
public static ModularClassPath resolveDependencies(List<String> deps, List<MavenRepo> repos,
boolean offline, boolean updateCache, boolean loggingEnabled, boolean downloadSources) {

Expand Down Expand Up @@ -81,10 +74,6 @@ public static ModularClassPath resolveDependencies(List<String> deps, List<Maven
repos.stream().map(m -> m.toString()).collect(Collectors.joining(", "))));

String depsHash = String.join(CP_SEPARATOR, depIds);
// if (!transitivity) { // the cached key need to be different for
// non-transivity
// depsHash = "notransitivity-" + depsHash;
// }

List<ArtifactInfo> cachedDeps = null;
if (!updateCache) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/dev/jbang/source/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ private Path getTempPath(String extension) {
* be rebuilt
*/
public boolean isUpToDate() {
return getJarFile() != null && Files.exists(getJarFile())
&& updateDependencyResolver(new DependencyResolver()).resolve().isValid();
return getJarFile() != null && Files.exists(getJarFile()) && resolveClassPath().isValid();
}

/**
Expand Down

0 comments on commit 7b978e0

Please sign in to comment.