66
77import org.apache.tools.ant.taskdefs.condition.Os
88
9- afterEvaluate {
9+ interface InjectedExecOps {
10+ @Inject // @javax.inject.Inject
11+ ExecOperations getExecOps ()
12+ }
1013
14+ afterEvaluate {
1115 def androidExtension = extensions. findByName(" android" )
1216
1317 if (androidExtension == null || android. applicationVariants == null ) {
@@ -294,9 +298,11 @@ private def getReactConfig(File buildDir, variant) {
294298 def targetPath = variant. name
295299 reactConfig[' bundleTaskName' ] = " createBundle${ targetName} JsAndAssets"
296300 reactConfig[' bundleFileResolver' ] = getBundleFileResolver([
301+ " $buildDir /generated/assets/react/${ targetName.toLowerCase()} " , // RN 0.82+
297302 " $buildDir /ASSETS/createBundle${ targetName} JsAndAssets" , // Android Gradle Plugin 7.3
298303 " $buildDir /generated/assets/createBundle${ targetName} JsAndAssets" // Android Gradle Plugin 7.4 and up
299304 ] as String [], bundleAssetName)
305+
300306 reactConfig[' bundleAssetName' ] = bundleAssetName
301307 reactConfig[' targetPath' ] = targetPath
302308 reactConfig[' targetName' ] = targetName
@@ -339,7 +345,8 @@ private def runShellCommand(
339345 def errorStream = new ByteArrayOutputStream ()
340346
341347 try {
342- def result = exec {
348+ def injected = project. objects. newInstance(InjectedExecOps )
349+ def result = injected. execOps. exec {
343350 workingDir = workingDirectory
344351 standardOutput = outputStream
345352 errorOutput = errorStream
@@ -360,7 +367,7 @@ private def runShellCommand(
360367 def errorStreamContent = errorStream. toString(" UTF-8" )
361368 def standardStreamContent = outputStream. toString(" UTF-8" )
362369 logger. error(" Exception raised during command execution," +
363- " stderr=${ errorStreamContent} , stdout=${ standardStreamContent} " )
370+ " stderr=${ errorStreamContent} , stdout=${ standardStreamContent} , exception= ${ e } " )
364371 throw e
365372 }
366373}
0 commit comments