Skip to content

Commit c06cbd9

Browse files
WMS-29754 | introduce --gradle-memory flag for Gradle JVM and memory configuration
1 parent 5667fc3 commit c06cbd9

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ wm-reactnative build android <src_dir> [additional_arguments]
8181
|**\-\-aKeyPassword**|Key Password|
8282
|**\-\-buildType**|**DEFAULT:** development<br>development or production<br>Use ‘production’ with keystore specified.|
8383
|**\-\-architecture**|Specifies the target Application Binary Interfaces (ABIs) for the build.<br>**DEFAULT:** All <br>**CHOICES:** armeabi-v7a, arm64-v8a, x86, x86_64. <br>**Example for single ABI:** --architecture=armeabi-v7a <br>**Example for multiple ABIs:** --architecture=armeabi-v7a --architecture=arm64-v8a |
84+
|**\-\-gradle-memory**|**OPTIONAL:** Specify JVM arguments for Gradle daemon.<br>**Example:** --gradle-memory="-Xmx2048m -XX:MaxMetaspaceSize=512m"|
8485

8586

8687
### Example 1

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ const args = require('yargs')
7979
type: 'array',
8080
choices: ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'],
8181
})
82+
.option('gradle-memory', {
83+
alias: 'gm',
84+
describe: 'Specify JVM arguments for Gradle daemon (e.g., -Xmx2048m -XX:MaxMetaspaceSize=512m)',
85+
type: 'string'
86+
})
8287
}, args => {
8388
args.platform = 'android';
8489
if(args.interactive){

src/command.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ async function updatePackageJsonFile(path) {
152152
})
153153
}
154154

155+
if (args.gradleMemory && args.platform === 'android') {
156+
await readAndReplaceFileContent(`${config.src}/android/gradle.properties`, content => {
157+
if (content.match(/^org\.gradle\.jvmargs=.*$/m)) {
158+
return content.replace(/^org\.gradle\.jvmargs=.*$/m, `org.gradle.jvmargs=${args.gradleMemory}`);
159+
} else {
160+
return content + `\norg.gradle.jvmargs=${args.gradleMemory}`;
161+
}
162+
});
163+
}
164+
155165
config.outputDirectory = config.src + 'output/';
156166
config.logDirectory = config.outputDirectory + 'logs/';
157167
logger.info({

0 commit comments

Comments
 (0)