@@ -226,7 +226,7 @@ func packagesConfig(t targetInfo) *packages.Config {
226
226
}
227
227
228
228
// getModuleVersions returns a module information at the directory src.
229
- func getModuleVersions (targetPlatform string , targetArch string , src string ) (* modfile.File , error ) {
229
+ func getModuleVersions (targetPlatform string , targetArch string , src string , dir string ) (* modfile.File , error ) {
230
230
cmd := exec .Command ("go" , "list" )
231
231
cmd .Env = append (os .Environ (), "GOOS=" + platformOS (targetPlatform ), "GOARCH=" + targetArch )
232
232
@@ -289,6 +289,17 @@ func getModuleVersions(targetPlatform string, targetArch string, src string) (*m
289
289
}
290
290
}
291
291
292
+ for _ , subdir := range []string {"Java" , "ObjC" } {
293
+ if _ , err := os .Stat (filepath .Join (dir , subdir )); err == nil {
294
+ if err := f .AddReplace (subdir , "" , filepath .Join (dir , subdir ), "" ); err != nil {
295
+ return nil , err
296
+ }
297
+ if err := os .WriteFile (filepath .Join (dir , subdir , "go.mod" ), []byte ("module " + subdir + "\n " ), 0644 ); err != nil {
298
+ return nil , err
299
+ }
300
+ }
301
+ }
302
+
292
303
v , err := ensureGoVersion ()
293
304
if err != nil {
294
305
return nil , err
@@ -316,7 +327,7 @@ func writeGoMod(dir, targetPlatform, targetArch string) error {
316
327
}
317
328
318
329
return writeFile (filepath .Join (dir , "go.mod" ), func (w io.Writer ) error {
319
- f , err := getModuleVersions (targetPlatform , targetArch , "." )
330
+ f , err := getModuleVersions (targetPlatform , targetArch , "." , dir )
320
331
if err != nil {
321
332
return err
322
333
}
0 commit comments