Skip to content

add read jvmargs from ~/.gradle/gradle.properties. #1416

Closed
one-leaf wants to merge 4 commits intoapache:masterfrom
one-leaf:master
Closed

add read jvmargs from ~/.gradle/gradle.properties. #1416
one-leaf wants to merge 4 commits intoapache:masterfrom
one-leaf:master

Conversation

@one-leaf
Copy link
Copy Markdown

@one-leaf one-leaf commented Aug 9, 2019

You can limit memory by set org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=256m

…org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=256m
@junichi11 junichi11 requested a review from lkishalmi August 11, 2019 00:56
Copy link
Copy Markdown
Contributor

@lkishalmi lkishalmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a JIRA issue please.
Also make sure that this is actually required and the gradle launcher daes not take care of this one (as it probably should)
Also use the proper chain of property file reading.

String userHomeDir = System.getProperty("user.home");
File gradlePropertiesFile = Paths.get(userHomeDir, ".gradle", "gradle.properties").toFile();
if (gradlePropertiesFile.exists()){
Properties pps = new Properties();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably you would put this as a private method, as actually the priority of the jvm arg resolve is project gradle.properties, root project gradle.properties, then gradle user home gradle. propertties.
Also for the grade user home, please use the GradleSettings.getGradleUserHome()

if (gradlePropertiesFile.exists()){
Properties pps = new Properties();
InputStream in = null;
try {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try with resource?

in = new BufferedInputStream(new FileInputStream(gradlePropertiesFile));
pps.load(in);
if (pps.containsKey("org.gradle.jvmargs")){
String jvmargs_value = pps.getProperty("org.gradle.jvmargs");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constant declaration would be nice, tough a //NOI18N shall be added.

@one-leaf
Copy link
Copy Markdown
Author

I'm sure that this is actually required, Gradle Tooling API with Gradle Daemon can't auto add jvmargs from gradle.properties file. only run gradle command can add jvmargs from gradle.properties. If you have a better way to limit memory of gradle daemon in netbeans, please let me know.

@lkishalmi
Copy link
Copy Markdown
Contributor

Ok. Go ahead and do the requested changes. Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants