3636
3737// This is for development, when we edit the Swift swift-java project, the outputs of the generated sources may change.
3838// Thus, we also need to watch and re-build the top level project.
39- def buildJExtractPlugin = tasks. register(" swiftBuildJExtractPlugin " , Exec ) {
39+ def compileSwiftJExtractPlugin = tasks. register(" compileSwiftJExtractPlugin " , Exec ) {
4040 description = " Rebuild the swift-java root project"
4141
4242 inputs. file(new File (rootDir, " Package.swift" ))
@@ -45,25 +45,41 @@ def buildJExtractPlugin = tasks.register("swiftBuildJExtractPlugin", Exec) {
4545
4646 workingDir = rootDir
4747 commandLine " swift"
48- args " build"
48+ args(" build" ,
49+ " --product" , " SwiftKitSwift" ,
50+ " --product" , " JExtractSwiftPlugin" ,
51+ " --product" , " JExtractSwiftCommandPlugin" )
52+ }
53+ def compileSwiftKitSwift = tasks. register(" compileSwiftKitSwift" , Exec ) {
54+ description = " Rebuild the swift-java root project"
55+
56+ inputs. file(new File (rootDir, " Package.swift" ))
57+ inputs. dir(new File (rootDir, " Sources" ))
58+ outputs. dir(new File (rootDir, " .build" ))
59+
60+ workingDir = rootDir
61+ commandLine " swift"
62+ args(" build" ,
63+ " --product" , " SwiftKitSwift" )
4964}
5065
51- def swiftClean = tasks. register(" swiftClean " , Exec ) {
66+ def cleanSwift = tasks. register(" cleanSwift " , Exec ) {
5267 workingDir = layout. projectDirectory
5368 commandLine " swift"
5469 args(" package" , " clean" )
5570}
5671
5772def jextract = tasks. register(" jextract" , Exec ) {
5873 description = " Builds swift sources, including swift-java source generation"
59- dependsOn buildJExtractPlugin
74+ dependsOn compileSwiftJExtractPlugin
75+ dependsOn compileSwiftKitSwift
6076
6177 // only because we depend on "live developing" the plugin while using this project to test it
6278 inputs. file(new File (rootDir, " Package.swift" ))
6379 inputs. dir(new File (rootDir, " Sources" ))
6480
65- inputs. file(layout . projectDirectory . file( " Package.swift" ))
66- inputs. dir(layout . projectDirectory . dir( " Sources" ))
81+ inputs. file(new File (projectDir, " Package.swift" ))
82+ inputs. dir(new File (projectDir, " Sources" ))
6783
6884 // TODO: we can use package describe --type json to figure out which targets depend on JExtractSwiftPlugin and will produce outputs
6985 // Avoid adding this directory, but create the expected one specifically for all targets
@@ -100,7 +116,7 @@ tasks.build {
100116}
101117
102118tasks. clean {
103- dependsOn(" swiftClean " )
119+ dependsOn(" cleanSwift " )
104120}
105121
106122dependencies {
0 commit comments