Skip to content

Commit e5d477b

Browse files
pdo-axelorpbe-axelor
authored andcommittedMay 20, 2022
Upgrade to Gradle 7.3.3
1 parent 9803151 commit e5d477b

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed
 

‎axelor-gradle/src/main/java/com/axelor/gradle/AxelorUtils.java

+26-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
*/
1818
package com.axelor.gradle;
1919

20+
import com.google.common.cache.CacheBuilder;
21+
import com.google.common.cache.CacheLoader;
22+
import com.google.common.cache.LoadingCache;
2023
import java.io.File;
2124
import java.io.IOException;
2225
import java.util.ArrayList;
@@ -38,18 +41,31 @@
3841

3942
public class AxelorUtils {
4043

44+
private AxelorUtils() {}
45+
46+
private static LoadingCache<Project, List<Project>> includedBuildRootsCache =
47+
CacheBuilder.newBuilder()
48+
.build(
49+
new CacheLoader<Project, List<Project>>() {
50+
@Override
51+
public List<Project> load(Project project) throws Exception {
52+
return project.getGradle().getIncludedBuilds().stream()
53+
.map(b -> ((IncludedBuildInternal) b).getTarget())
54+
.map(b -> b.getBuild().getRootProject())
55+
.collect(Collectors.toList());
56+
}
57+
});
58+
4159
public static String toRelativePath(Project project, File file) {
4260
return project.getProjectDir().toPath().relativize(file.toPath()).toString();
4361
}
4462

45-
private static Stream<Project> includedBuildRoots(Project project) {
46-
return project.getGradle().getIncludedBuilds().stream()
47-
.map(b -> ((IncludedBuildInternal) b).getTarget())
48-
.map(b -> b.getBuild().getRootProject());
63+
private static List<Project> includedBuildRoots(Project project) {
64+
return includedBuildRootsCache.getUnchecked(project);
4965
}
5066

5167
public static List<Project> findIncludedBuildProjects(Project project) {
52-
return includedBuildRoots(project)
68+
return includedBuildRoots(project).stream()
5369
.flatMap(root -> Stream.concat(Stream.of(root), root.getSubprojects().stream()))
5470
.collect(Collectors.toList());
5571
}
@@ -118,7 +134,11 @@ public static Project findProject(Project project, ResolvedArtifact artifact) {
118134
Project sub = project.findProject(path);
119135
// consider projects from included builds
120136
if (sub == null) {
121-
sub = includedBuildRoots(project).map(p -> p.findProject(path)).findFirst().orElse(null);
137+
sub =
138+
includedBuildRoots(project).stream()
139+
.map(p -> p.findProject(path))
140+
.findFirst()
141+
.orElse(null);
122142
}
123143
return sub;
124144
}

‎changelogs/unreleased/upgrade-gradle-7.2.yml

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: Upgrade to Gradle 7.3.3
3+
type: change
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)
Please sign in to comment.