19
19
import org .gradle .api .plugins .JavaPlugin ;
20
20
import org .gradle .api .provider .Property ;
21
21
import org .gradle .nativeplatform .plugins .NativeComponentPlugin ;
22
+ import org .gradle .tooling .BuildException ;
22
23
23
24
import com .google .gson .Gson ;
24
25
@@ -165,7 +166,11 @@ public void loadFrom(File directory) {
165
166
for (File f : vendorFiles (directory )) {
166
167
JsonDependency dep = parse (f );
167
168
if (dep != null ) {
168
- load (dep );
169
+ try {
170
+ load (dep );
171
+ } catch (Exception e ) {
172
+ throw new BuildException ("Failed to load dependency" , e );
173
+ }
169
174
}
170
175
}
171
176
}
@@ -182,7 +187,7 @@ private JsonDependency parse(File f) {
182
187
}
183
188
}
184
189
185
- private void load (JsonDependency dep ) {
190
+ private void load (JsonDependency dep ) throws VendorParsingException {
186
191
// Don"t double-add a dependency!
187
192
if (dependencySet .findByName (dep .uuid ) != null ) {
188
193
return ;
@@ -191,40 +196,56 @@ private void load(JsonDependency dep) {
191
196
NamedJsonDependency namedDep = new NamedJsonDependency (dep .uuid , dep );
192
197
dependencySet .add (namedDep );
193
198
194
- if (dep .mavenUrls != null ) {
195
- // Enumerate all group ids
196
- Set <String > groupIds = new HashSet <>();
197
- for (CppArtifact cpp : dep .cppDependencies ) {
198
- groupIds .add (cpp .groupId );
199
- }
200
- for (JniArtifact jni : dep .jniDependencies ) {
201
- groupIds .add (jni .groupId );
202
- }
203
- for (JavaArtifact java : dep .javaDependencies ) {
204
- groupIds .add (java .groupId );
205
- }
206
- if (dep .extraGroupIds != null ) {
207
- for (String groupId : dep .extraGroupIds ) {
208
- groupIds .add (groupId );
209
- }
199
+ if (dep .name == null ) {
200
+ throw new VendorParsingException (VendorParsingError .MissingName );
201
+ }
202
+ String filename = dep .name ;
203
+
204
+ if (dep .mavenUrls == null ) {
205
+ throw new VendorParsingException (filename , VendorParsingError .NoMavenUrl );
206
+ }
207
+
208
+ // Enumerate all group ids
209
+ Set <String > groupIds = new HashSet <>();
210
+ if (dep .cppDependencies == null ) {
211
+ throw new VendorParsingException (filename , VendorParsingError .MissingCppDeps );
212
+ }
213
+ for (CppArtifact cpp : dep .cppDependencies ) {
214
+ groupIds .add (cpp .groupId );
215
+ }
216
+ if (dep .jniDependencies == null ) {
217
+ throw new VendorParsingException (filename , VendorParsingError .MissingJniDeps );
218
+ }
219
+ for (JniArtifact jni : dep .jniDependencies ) {
220
+ groupIds .add (jni .groupId );
221
+ }
222
+ if (dep .javaDependencies == null ) {
223
+ throw new VendorParsingException (filename , VendorParsingError .MissingJavaDeps );
224
+ }
225
+ for (JavaArtifact java : dep .javaDependencies ) {
226
+ groupIds .add (java .groupId );
227
+ }
228
+ if (dep .extraGroupIds != null ) {
229
+ for (String groupId : dep .extraGroupIds ) {
230
+ groupIds .add (groupId );
210
231
}
232
+ }
211
233
212
- int i = 0 ;
213
- for (String url : dep .mavenUrls ) {
214
- boolean found = false ;
234
+ int i = 0 ;
235
+ for (String url : dep .mavenUrls ) {
236
+ boolean found = false ;
215
237
216
- for (VendorMavenRepo machingRepo : vendorRepos .matching (x -> x .getUrl ().equals (url ))) {
217
- found = true ;
218
- machingRepo .getAllowedGroupIds ().addAll (groupIds );
219
- }
238
+ for (VendorMavenRepo machingRepo : vendorRepos .matching (x -> x .getUrl ().equals (url ))) {
239
+ found = true ;
240
+ machingRepo .getAllowedGroupIds ().addAll (groupIds );
241
+ }
220
242
221
- // // Only add if the maven doesn"t yet exist.
222
- if (!found ) {
223
- String name = dep .uuid + "_" + i ++;
224
- log .info ("Registering vendor dep maven: " + name + " on project " + project .getPath ());
225
- VendorMavenRepo repo = project .getObjects ().newInstance (VendorMavenRepo .class , name , url , groupIds );
226
- vendorRepos .add (repo );
227
- }
243
+ // // Only add if the maven doesn"t yet exist.
244
+ if (!found ) {
245
+ String name = dep .uuid + "_" + i ++;
246
+ log .info ("Registering vendor dep maven: " + name + " on project " + project .getPath ());
247
+ VendorMavenRepo repo = project .getObjects ().newInstance (VendorMavenRepo .class , name , url , groupIds );
248
+ vendorRepos .add (repo );
228
249
}
229
250
}
230
251
}
0 commit comments