@@ -66,6 +66,7 @@ extension SwiftJava {
6666extension SwiftJava . WrapJavaCommand {
6767
6868 mutating func runSwiftJavaCommand( config: inout Configuration ) async throws {
69+ print ( " self.commonOptions.filterInclude = \( self . commonOptions. filterInclude) " )
6970 configure ( & config. filterInclude, append: self . commonOptions. filterInclude)
7071 configure ( & config. filterExclude, append: self . commonOptions. filterExclude)
7172
@@ -114,6 +115,7 @@ extension SwiftJava.WrapJavaCommand {
114115}
115116
116117extension SwiftJava . WrapJavaCommand {
118+
117119 mutating func generateWrappers(
118120 config: Configuration ,
119121 dependentConfigs: [ ( String , Configuration ) ] ,
@@ -148,21 +150,9 @@ extension SwiftJava.WrapJavaCommand {
148150 let classLoader = try ! JavaClass < ClassLoader > ( environment: environment)
149151 . getSystemClassLoader ( ) !
150152 var javaClasses : [ JavaClass < JavaObject > ] = [ ]
151- eachClass: for (javaClassName, _) in config. classes ?? [ : ] {
152-
153- // If we have an inclusive filter, import only types from it
154- for include in config. filterInclude ?? [ ] {
155- guard javaClassName. starts ( with: include) else {
156- log. info ( " Skip Java type: \( javaClassName) (does not match filter) " )
157- continue
158- }
159- }
160- // If we have an exclude filter, check for it as well
161- for exclude in config. filterExclude ?? [ ] {
162- if javaClassName. starts ( with: exclude) {
163- log. info ( " Skip Java type: \( javaClassName) (does match exclude filter: \( exclude) ) " )
164- continue eachClass
165- }
153+ for (javaClassName, _) in config. classes ?? [ : ] {
154+ guard shouldImportJavaClass ( javaClassName, config: config) else {
155+ continue
166156 }
167157
168158 log. info ( " Wrapping java type: \( javaClassName) " )
@@ -213,19 +203,8 @@ extension SwiftJava.WrapJavaCommand {
213203 return nil
214204 }
215205
216- // If we have an inclusive filter, import only types from it
217- for include in config. filterInclude ?? [ ] {
218- guard javaClassName. starts ( with: include) else {
219- log. info ( " Skip Java type: \( javaClassName) (does not match filter) " )
220- return nil
221- }
222- }
223- // If we have an exclude filter, check for it as well
224- for exclude in config. filterExclude ?? [ ] {
225- if javaClassName. starts ( with: exclude) {
226- log. info ( " Skip Java type: \( javaClassName) (does match exclude filter: \( exclude) ) " )
227- return nil
228- }
206+ guard shouldImportJavaClass ( javaClassName, config: config) else {
207+ return nil
229208 }
230209
231210 // If this class has been explicitly mentioned, we're done.
@@ -285,4 +264,24 @@ extension SwiftJava.WrapJavaCommand {
285264 )
286265 }
287266 }
267+
268+ private func shouldImportJavaClass( _ javaClassName: String , config: Configuration ) -> Bool {
269+ // If we have an inclusive filter, import only types from it
270+ for include in config. filterInclude ?? [ ] {
271+ guard javaClassName. starts ( with: include) else {
272+ log. info ( " Skip Java type: \( javaClassName) (does not match include filter: \( include) ) " )
273+ return false
274+ }
275+ }
276+ // If we have an exclude filter, check for it as well
277+ for exclude in config. filterExclude ?? [ ] {
278+ if javaClassName. starts ( with: exclude) {
279+ log. info ( " Skip Java type: \( javaClassName) (does match exclude filter: \( exclude) ) " )
280+ return false
281+ }
282+ }
283+
284+ // The class matches import filters, if any, and was not excluded.
285+ return true
286+ }
288287}
0 commit comments