@@ -290,6 +290,7 @@ static async Task DownloadArtifacts(MavenRepository maven, BindingConfig config,
290290 static List < BindingProjectModel > BuildProjectModels ( BindingConfig config , TemplateConfig template , Dictionary < string , Project > mavenProjects )
291291 {
292292 var projectModels = new List < BindingProjectModel > ( ) ;
293+ var exceptions = new List < Exception > ( ) ;
293294
294295 var baseMetadata = new Dictionary < string , string > ( ) ;
295296 MergeValues ( baseMetadata , config . Metadata ) ;
@@ -330,7 +331,6 @@ static List<BindingProjectModel> BuildProjectModels(BindingConfig config, Templa
330331 var artifactExtractDir = Path . Combine ( artifactDir , mavenArtifact . ArtifactId ) ;
331332
332333 var proguardFile = Path . Combine ( artifactExtractDir , "proguard.txt" ) ;
333- var exceptions = new List < Exception > ( ) ;
334334
335335 projectModel . MavenArtifacts . Add ( new MavenArtifactModel
336336 {
@@ -348,8 +348,7 @@ static List<BindingProjectModel> BuildProjectModels(BindingConfig config, Templa
348348 // Gather maven dependencies to try and map out nuget dependencies
349349 foreach ( var mavenDep in mavenProject . Dependencies )
350350 {
351- // We only really care about 'compile' scoped dependencies (also null/blank means compile)
352- if ( ! string . IsNullOrEmpty ( mavenDep . Scope ) && ! mavenDep . Scope . ToLowerInvariant ( ) . Equals ( "compile" ) )
351+ if ( ! ShouldIncludeDependency ( config , mavenArtifact , mavenDep , exceptions ) )
353352 continue ;
354353
355354 mavenDep . Version = FixVersion ( mavenDep . Version ) ;
@@ -360,6 +359,11 @@ static List<BindingProjectModel> BuildProjectModels(BindingConfig config, Templa
360359 && ma . ArtifactId == mavenDep . ArtifactId
361360 && mavenDep . Satisfies ( ma . Version ) ) ;
362361
362+ if ( depMapping is null && mavenDep . IsRuntimeDependency ( ) ) {
363+ exceptions . Add ( new Exception ( $ "Artifact '{ mavenArtifact . GroupAndArtifactId } ' has unknown 'Runtime' dependency '{ mavenDep . GroupAndArtifactId ( ) } '. Either fulfill or exclude this dependency.") ) ;
364+ continue ;
365+ }
366+
363367 if ( depMapping == null )
364368 {
365369 StringBuilder sb = new StringBuilder ( ) ;
@@ -411,17 +415,41 @@ static List<BindingProjectModel> BuildProjectModels(BindingConfig config, Templa
411415 }
412416 } ) ;
413417 }
414- if ( exceptions . Any ( ) )
415- {
416- throw new AggregateException ( exceptions . ToArray ( ) ) ;
417- }
418418
419419 }
420420
421+ if ( exceptions . Any ( ) )
422+ throw new AggregateException ( exceptions . ToArray ( ) ) ;
423+
421424
422425 return projectModels ;
423426 }
424427
428+ static bool ShouldIncludeDependency ( BindingConfig config , MavenArtifactConfig artifact , Dependency dependency , List < Exception > exceptions )
429+ {
430+ // We always care about 'compile' scoped dependencies
431+ if ( dependency . IsCompileDependency ( ) )
432+ return true ;
433+
434+ // If we're not processing Runtime dependencies then ignore the rest
435+ if ( ! config . StrictRuntimeDependencies )
436+ return false ;
437+
438+ // The only other thing we may care about is 'runtime', bail if this isn't 'runtime'
439+ if ( ! dependency . IsRuntimeDependency ( ) )
440+ return false ;
441+
442+ // Check 'artifact' list
443+ if ( artifact . ExcludedRuntimeDependencies . OrEmpty ( ) . Split ( ',' ) . Contains ( dependency . GroupAndArtifactId ( ) , StringComparer . OrdinalIgnoreCase ) )
444+ return false ;
445+
446+ // Check 'global' list
447+ if ( config . ExcludedRuntimeDependencies . OrEmpty ( ) . Split ( ',' ) . Contains ( dependency . GroupAndArtifactId ( ) , StringComparer . OrdinalIgnoreCase ) )
448+ return false ;
449+
450+ return true ;
451+ }
452+
425453 static string GetRelativePath ( string filespec , string folder )
426454 {
427455 Uri pathUri = new Uri ( filespec ) ;
0 commit comments