26
26
import org .gradle .api .artifacts .result .ResolvedDependencyResult ;
27
27
import org .gradle .api .file .RegularFileProperty ;
28
28
import org .gradle .api .internal .GradleInternal ;
29
+ import org .gradle .api .logging .Logger ;
30
+ import org .gradle .api .logging .Logging ;
29
31
import org .gradle .api .provider .Property ;
30
32
import org .gradle .api .tasks .Input ;
31
33
import org .gradle .api .tasks .OutputFile ;
@@ -46,6 +48,8 @@ public abstract class FlatpakGradleGeneratorTask extends DefaultTask {
46
48
private static final String DEFAULT_DOWNLOAD_DIRECTORY = "offline-repository" ;
47
49
private static final String GRADLE_PLUGIN_PORTAL = "https://plugins.gradle.org/m2/" ;
48
50
51
+ private static final Logger LOGGER = Logging .getLogger (FlatpakGradleGeneratorTask .class );
52
+
49
53
/**
50
54
* Specifies where to write the resulting json file.
51
55
*
@@ -83,7 +87,11 @@ public void apply() throws NoSuchAlgorithmException, IOException {
83
87
Project project = getProject ();
84
88
85
89
// Buildscript classpath dependencies
86
- var buildScriptRepositories = listPluginRepositories (project );
90
+ var buildScriptRepositories = filterRepositories (listPluginRepositories (project ));
91
+ LOGGER .info (
92
+ "Resolving buildscript dependencies using repositories: {}" ,
93
+ buildScriptRepositories
94
+ );
87
95
for (var configuration : project .getBuildscript ().getConfigurations ()) {
88
96
if (configuration .isCanBeResolved ()) {
89
97
generateSourcesList (buildScriptRepositories , configuration );
@@ -94,9 +102,14 @@ public void apply() throws NoSuchAlgorithmException, IOException {
94
102
// repositories too
95
103
var repositories = listRepositories (project );
96
104
repositories .addAll (buildScriptRepositories );
105
+ repositories = filterRepositories (repositories );
97
106
98
107
// Loop through configurations and generate json blocks for the
99
108
// resolved dependencies
109
+ LOGGER .info (
110
+ "Resolving project dependencies using repositories: {}" ,
111
+ repositories
112
+ );
100
113
for (var configuration : project .getConfigurations ()) {
101
114
if (configuration .isCanBeResolved ()) {
102
115
generateSourcesList (repositories , configuration );
@@ -153,6 +166,15 @@ private List<String> listPluginRepositories(Project project) {
153
166
return urls ;
154
167
}
155
168
169
+ private List <String > filterRepositories (List <String > repositories ) {
170
+ // skip duplicates & local repositories
171
+ return repositories
172
+ .stream ()
173
+ .distinct ()
174
+ .filter (repository -> !repository .startsWith ("file:/" ))
175
+ .toList ();
176
+ }
177
+
156
178
/**
157
179
* Generate json blocks for all dependencies in the provided configuration.
158
180
*
@@ -165,7 +187,15 @@ private void generateSourcesList(List<String> repositories,
165
187
Configuration configuration )
166
188
throws IOException , NoSuchAlgorithmException {
167
189
168
- for (var dependency : listDependencies (configuration )) {
190
+ var dependencies = listDependencies (configuration );
191
+
192
+ LOGGER .info (
193
+ "Resolving configuration {} with {} dependencies" ,
194
+ configuration .getName (),
195
+ dependencies .size ()
196
+ );
197
+
198
+ for (var dependency : dependencies ) {
169
199
170
200
String id = dependency .getSelected ().getId ().getDisplayName ();
171
201
String variant = dependency .getResolvedVariant ().getDisplayName ();
@@ -177,12 +207,8 @@ private void generateSourcesList(List<String> repositories,
177
207
// Build simple helper object with the Maven coordinates of the artifact
178
208
var dep = DependencyDetails .of (id );
179
209
180
- // Loop through the repositories, skip duplicates
181
- for (var repository : repositories .stream ().distinct ().toList ()) {
182
-
183
- // Skip local repositories
184
- if (repository .startsWith ("file:/" ))
185
- continue ;
210
+ // Loop through the repositories
211
+ for (var repository : repositories ) {
186
212
187
213
// Check for a Gradle module artifact
188
214
var module = resolver .tryResolve (dep , repository , dep .filename ("module" ));
0 commit comments