Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#39793 closed enhancement (fixed)

Allow custom Java options to launch sbt

Reported by: luc-j-bourhis (Luc J. Bourhis) Owned by: blair (Blair Zajac)
Priority: Normal Milestone:
Component: ports Version:
Keywords: haspatch Cc: cooljeanius (Eric Gallager)
Port: sbt

Description

The default Java options in /opt/local/share/sbt/sbt may not suit every user. For example, I like to reduce the memory footprint for some projects by using -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC and then by tuning -Xms and -Xmx. Thus I propose the attached patch that lets user define their custom option in ~/.sbtconfig

Attachments (2)

sbt.diff (1006 bytes) - added by luc-j-bourhis (Luc J. Bourhis) 11 years ago.
sbt2.diff (1010 bytes) - added by luc-j-bourhis (Luc J. Bourhis) 11 years ago.

Download all attachments as: .zip

Change History (11)

Changed 11 years ago by luc-j-bourhis (Luc J. Bourhis)

Attachment: sbt.diff added

comment:1 Changed 11 years ago by mf2k (Frank Schima)

Keywords: haspatch added
Owner: changed from macports-tickets@… to blair@…
Type: requestenhancement
Version: 2.1.3

In the future, please Cc the port maintainer(s).

Changed 11 years ago by luc-j-bourhis (Luc J. Bourhis)

Attachment: sbt2.diff added

comment:2 Changed 11 years ago by luc-j-bourhis (Luc J. Bourhis)

Better patch (sbt2.diff) that is more compatible with current behaviour.

comment:3 Changed 11 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:4 Changed 11 years ago by blair (Blair Zajac)

Here's my new proposed patch which doesn't assume that ~/.sbtconfig sets SBT_JAVA_OPTS. Let me know if this works for you.

Index: sbt.sh
===================================================================
--- sbt.sh	(revision 108610)
+++ sbt.sh	(working copy)
@@ -17,9 +17,15 @@
 # Is the location of the SBT launcher JAR file.
 LAUNCHJAR="__SBT_LAUNCHER_PATH__"
 
-# Ensure enough heap space is created for sbt.  These settings are the
-# default settings from Typesafe's sbt wrapper.
+# Customization: this may define a variable SBT_JAVA_OPTS
+SBTCONF=~/.sbtconfig
+if [ -f "$SBTCONF" ]; then
+    . $SBTCONF
+    JAVA_OPTS="$SBT_JAVA_OPTS"
+fi
 if [ -z "$JAVA_OPTS" ]; then
+    # Ensure enough heap space is created for sbt.  These settings are
+    # the default settings from Typesafe's sbt wrapper.
     JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -Xms1536m -Xmx1536m -XX:MaxPermSize=384m -XX:ReservedCodeCacheSize=192m -Dfile.encoding=UTF8"
 fi

comment:5 in reply to:  4 Changed 11 years ago by luc-j-bourhis (Luc J. Bourhis)

Replying to blair@…:

Here's my new proposed patch which doesn't assume that ~/.sbtconfig sets SBT_JAVA_OPTS. Let me know if this works for you.

It works. But written in this way, shall we set JAVA_OPTS instead of SBT_JAVA_OPTS in ~/.sbtconfig then? This would make it more obvious, wouldn't it?

comment:6 Changed 11 years ago by blair (Blair Zajac)

Sure, we can do this:

Index: files/sbt.sh
===================================================================
--- files/sbt.sh	(revision 108610)
+++ files/sbt.sh	(working copy)
@@ -17,9 +17,14 @@
 # Is the location of the SBT launcher JAR file.
 LAUNCHJAR="__SBT_LAUNCHER_PATH__"
 
-# Ensure enough heap space is created for sbt.  These settings are the
-# default settings from Typesafe's sbt wrapper.
+# Customization: this may define JAVA_OPTS.
+SBTCONF=~/.sbtconfig
+if [ -f "$SBTCONF" ]; then
+    . $SBTCONF
+fi
 if [ -z "$JAVA_OPTS" ]; then
+    # Ensure enough heap space is created for sbt.  These settings are
+    # the default settings from Typesafe's sbt wrapper.
     JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -Xms1536m -Xmx1536m -XX:MaxPermSize=384m -XX:ReservedCodeCacheSize=192m -Dfile.encoding=UTF8"
 fi

comment:7 Changed 11 years ago by luc-j-bourhis (Luc J. Bourhis)

Yes, exactly, I think that's the better version.

comment:8 Changed 11 years ago by blair (Blair Zajac)

Resolution: fixed
Status: newclosed

Fixed in r108615. I changed ~ to $HOME also in the final commit.

comment:9 Changed 11 years ago by luc-j-bourhis (Luc J. Bourhis)

thanks a bunch

Note: See TracTickets for help on using tickets.