@@ -118,7 +118,9 @@ Optional<byte[]> tryResolve(DependencyDetails dep,
118
118
* @param id the id of the dependency
119
119
* @param dep a DependencyDetail instance with the Maven coordinates of the artifact
120
120
* @param repository the repository to try to download from
121
- * @param filename the filename of the artifact
121
+ * @param fileUrl the remote filename of the artifact
122
+ * @param checkName whether to verify if the cached file name matches fileUrl or fileName
123
+ * @param fileName the local filename of the artifact (as specified in module file)
122
124
*
123
125
* @throws IOException error while reading the jar file
124
126
* @throws NoSuchAlgorithmException no provider for the SHA-512 algorithm
@@ -127,9 +129,9 @@ void tryResolveCached(Set<ResolvedArtifact> artifacts,
127
129
ModuleVersionIdentifier id ,
128
130
DependencyDetails dep ,
129
131
String repository ,
130
- String filename ,
132
+ String fileUrl ,
131
133
boolean checkName ,
132
- String altName )
134
+ String fileName )
133
135
throws IOException , NoSuchAlgorithmException , InterruptedException {
134
136
135
137
for (var artifact : artifacts ) {
@@ -138,12 +140,12 @@ void tryResolveCached(Set<ResolvedArtifact> artifacts,
138
140
139
141
// Check against filenames in the .module file
140
142
if (checkName )
141
- if (!(file .getName ().equals (filename ) ||
142
- file .getName ().equals (altName )))
143
+ if (!(file .getName ().equals (fileUrl ) ||
144
+ file .getName ().equals (fileName )))
143
145
continue ;
144
146
145
147
// Skip files that are already included in the output
146
- if (output .containsKey (dep .path () + "/" + (checkName ? filename : file .getName ())))
148
+ if (output .containsKey (dep .path () + "/" + (checkName ? fileUrl : file .getName ())))
147
149
continue ;
148
150
149
151
// Build the url and check if it exists
@@ -153,12 +155,21 @@ void tryResolveCached(Set<ResolvedArtifact> artifacts,
153
155
+ file .getName ();
154
156
var isValid = isValid (url );
155
157
156
- if ((!isValid ) && filename .contains ("SNAPSHOT" )) {
158
+ // Try the filename from the .module
159
+ if (!isValid ) {
160
+ url = repository
161
+ + dep .path ()
162
+ + "/"
163
+ + fileUrl ;
164
+ isValid = isValid (url );
165
+ }
166
+
167
+ if ((!isValid ) && fileUrl .contains ("SNAPSHOT" )) {
157
168
// Try again, but this time, replace SNAPSHOT with snapshot details
158
169
url = repository
159
170
+ dep .path ()
160
171
+ "/"
161
- + filename .replace ("SNAPSHOT" , dep .snapshotDetail ());
172
+ + fileUrl .replace ("SNAPSHOT" , dep .snapshotDetail ());
162
173
isValid = isValid (url );
163
174
}
164
175
@@ -175,7 +186,7 @@ void tryResolveCached(Set<ResolvedArtifact> artifacts,
175
186
url ,
176
187
sha512 ,
177
188
dep .path (),
178
- checkName ? filename : file .getName ()
189
+ checkName ? fileUrl : file .getName ()
179
190
);
180
191
}
181
192
}
0 commit comments