Skip to content

Commit

Permalink
revert parallel download of maven depedencies
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Dec 6, 2024
1 parent 742f8cb commit fb6d998
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions core/src/main/java/lucee/runtime/mvn/MavenUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public static List<POM> getDependencies(List<POMReader.Dependency> rawDependenci
List<POM> dependencies = new ArrayList<>();
List<POM> parentDendencyManagement = null;

ExecutorService executor = ThreadUtil.createExecutorService(Runtime.getRuntime().availableProcessors());

if (parent != null) {
parentDendencyManagement = current.getDependencyManagement();
List<POM> tmp = parent.getDependencies();
Expand All @@ -124,17 +126,13 @@ public static List<POM> getDependencies(List<POMReader.Dependency> rawDependenci
}
}
}
if (rawDependencies != null && rawDependencies.size() > 0) {

if (rawDependencies != null) {
List<Future<POM>> futures = new ArrayList<>();
final List<POM> pdm = parentDendencyManagement;
ExecutorService executor = ThreadUtil.createExecutorService(rawDependencies.size(), true);
for (POMReader.Dependency rd: rawDependencies) {
GAVSO gavso = getDependency(rd, parent, current, properties, parentDendencyManagement, management);
if (gavso == null) continue;

Future<POM> future = executor.submit(() -> {
GAVSO gavso = getDependency(rd, parent, current, properties, pdm, management);
if (gavso == null) {
return null; // Skip if no GAVSO is returned
}
POM p = POM.getInstance(localDirectory, current.getRepositories(), gavso.g, gavso.a, gavso.v, gavso.s, gavso.o, current.getDependencyScope(),
current.getDependencyScopeManagement(), log);
p.initXML();
Expand All @@ -144,17 +142,14 @@ public static List<POM> getDependencies(List<POMReader.Dependency> rawDependenci
}
try {
for (Future<POM> future: futures) {
POM dependency = future.get(); // Wait for init to complete
if (dependency != null) { // Only add non-null dependencies
dependencies.add(dependency);
}
dependencies.add(future.get()); // Wait for init to complete
}
}
catch (Exception e) {
throw ExceptionUtil.toIOException(e);
}
executor.shutdown();
}
executor.shutdown();
return dependencies;
}

Expand Down

0 comments on commit fb6d998

Please sign in to comment.