@@ -88,24 +88,13 @@ struct SwiftJavaBuildToolPlugin: SwiftJavaPluginProtocol, BuildToolPlugin {
8888 }
8989
9090 var arguments : [ String ] = [ ]
91- arguments += argumentsModuleName ( sourceModule: sourceModule)
91+ arguments += argumentsSwiftModuleDeprecated ( sourceModule: sourceModule)
9292 arguments += argumentsOutputDirectory ( context: context)
93-
94- arguments += dependentConfigFiles. flatMap { moduleAndConfigFile in
95- let ( moduleName, configFile) = moduleAndConfigFile
96- return [
97- " --depends-on " ,
98- " \( moduleName) = \( configFile. path ( percentEncoded: false ) ) "
99- ]
100- }
93+ arguments += argumentsDependedOnConfigs ( dependentConfigFiles)
10194 arguments. append ( configFile. path ( percentEncoded: false ) )
10295
103- // guard let classes = config.classes else {
104- // log("Config at \(configFile) did not have 'classes' configured, skipping java2swift step.")
105- // return []
106- // }
10796 let classes = config. classes ?? [ : ]
108- print ( " Classes to wrap: \( classes. map ( \. key) ) " )
97+ print ( " [swift-java-plugin] Classes to wrap ( \( classes . count ) ) : \( classes. map ( \. key) ) " )
10998
11099 /// Determine the set of Swift files that will be emitted by the Java2Swift tool.
111100 // TODO: this is not precise and won't work with more advanced Java files, e.g. lambdas etc.
@@ -165,12 +154,14 @@ struct SwiftJavaBuildToolPlugin: SwiftJavaPluginProtocol, BuildToolPlugin {
165154 . buildCommand(
166155 displayName: displayName,
167156 executable: executable,
168- arguments: [
169- // FIXME: change to 'resolve' subcommand
170- " --fetch " , configFile. path ( percentEncoded: false ) ,
171- " --swift-module " , sourceModule. name,
172- " --output-directory " , outputDirectory ( context: context, generated: false ) . path ( percentEncoded: false )
173- ] ,
157+ arguments: [ " resolve " ]
158+ + argumentsOutputDirectory( context: context, generated: false )
159+ + argumentsSwiftModule( sourceModule: sourceModule)
160+ // + [
161+ // // explicitly provide config path
162+ // configFile.path(percentEncoded: false)
163+ // ]
164+ ,
174165 environment: [ : ] ,
175166 inputFiles: [ configFile] ,
176167 outputFiles: fetchDependenciesOutputFiles
@@ -192,28 +183,49 @@ struct SwiftJavaBuildToolPlugin: SwiftJavaPluginProtocol, BuildToolPlugin {
192183 outputFiles: outputSwiftFiles
193184 )
194185 ]
195- } else {
196- log ( " No Swift output files, skip wrapping " )
186+ }
187+
188+ if commands. isEmpty {
189+ log ( " No swift-java commands for module ' \( sourceModule. name) ' " )
197190 }
198191
199192 return commands
200193 }
201194}
202195
203196extension SwiftJavaBuildToolPlugin {
204- func argumentsModuleName ( sourceModule: Target ) -> [ String ] {
197+ func argumentsSwiftModule ( sourceModule: Target ) -> [ String ] {
205198 return [
206199 " --swift-module " , sourceModule. name
207200 ]
208201 }
209-
202+
203+ // FIXME: remove this and the deprecated property inside SwiftJava, this is a workaround
204+ // since we cannot have the same option in common options and in the top level
205+ // command from which we get into sub commands. The top command will NOT have this option.
206+ func argumentsSwiftModuleDeprecated( sourceModule: Target ) -> [ String ] {
207+ return [
208+ " --swift-module-deprecated " , sourceModule. name
209+ ]
210+ }
211+
210212 func argumentsOutputDirectory( context: PluginContext , generated: Bool = true ) -> [ String ] {
211213 return [
212214 " --output-directory " ,
213215 outputDirectory ( context: context, generated: generated) . path ( percentEncoded: false )
214216 ]
215217 }
216-
218+
219+ func argumentsDependedOnConfigs( _ dependentConfigFiles: [ ( String , URL ) ] ) -> [ String ] {
220+ dependentConfigFiles. flatMap { moduleAndConfigFile in
221+ let ( moduleName, configFile) = moduleAndConfigFile
222+ return [
223+ " --depends-on " ,
224+ " \( moduleName) = \( configFile. path ( percentEncoded: false ) ) "
225+ ]
226+ }
227+ }
228+
217229 func outputDirectory( context: PluginContext , generated: Bool = true ) -> URL {
218230 let dir = context. pluginWorkDirectoryURL
219231 if generated {
0 commit comments