Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Typesafe Activator not to use user home?

I'd like to configure Typesafe Activator and it's bundled tooling not to use my user home directory - I mean ~/.activator (configuration?), ~/.sbt (sbt configuration?) and especially ~/.ivy2, which I'd like to share between my two OSes. Typesafe "documentation" is of little help.

Need help for both Windows and Linux, please.

like image 418
enlait Avatar asked Jun 13 '14 07:06

enlait


1 Answers

From Command Line Options in the official documentation of sbt:

  • sbt.global.base - The directory containing global settings and plugins (default: ~/.sbt/0.13)
  • sbt.ivy.home - The directory containing the local Ivy repository and artifact cache (default: ~/.ivy2)

It appears that ~/.activator is set and used in the startup scripts and that's where I'd change the value.

It also appears (in sbt/sbt.boot.properties in activator-launch-1.2.1.jar) that the value of ivy-home is ${user.home}/.ivy2:

[ivy]
  ivy-home: ${user.home}/.ivy2
  checksums: ${sbt.checksums-sha1,md5}
  override-build-repos: ${sbt.override.build.repos-false}
  repository-config: ${sbt.repository.config-${sbt.global.base-${user.home}/.sbt}/repositories}

It means that without some development it's only possible to change sbt.global.base.

➜  minimal-scala  activator -Dsbt.global.base=./sbt -Dsbt.ivy.home=./ivy2 about
[info] Loading project definition from /Users/jacek/sandbox/sbt-launcher/minimal-scala/project
[info] Set current project to minimal-scala (in build file:/Users/jacek/sandbox/sbt-launcher/minimal-scala/)
[info] This is sbt 0.13.5
[info] The current project is {file:/Users/jacek/sandbox/sbt-launcher/minimal-scala/}minimal-scala 1.0
[info] The current project is built against Scala 2.11.1
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4

If you want to see under the hood, you could query for the current values of the home directories for sbt and Ivy with consoleProject command (it assumes you started activator with activator -Dsbt.global.base=./sbt -Dsbt.ivy.home=./ivy2):

> consoleProject
[info] Starting scala interpreter...
[info]
import sbt._
import Keys._
import _root_.sbt.plugins.IvyPlugin
import _root_.sbt.plugins.JvmPlugin
import _root_.sbt.plugins.CorePlugin
import _root_.sbt.plugins.JUnitXmlReportPlugin
import currentState._
import extracted._
import cpHelpers._
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_60).
Type in expressions to have them evaluated.
Type :help for more information.

scala> appConfiguration.eval.provider.scalaProvider.launcher.bootDirectory
res0: java.io.File = /Users/jacek/sandbox/sbt-launcher/minimal-scala/sbt/boot

scala> appConfiguration.eval.provider.scalaProvider.launcher.ivyHome
res1: java.io.File = /Users/jacek/.ivy2

Iff you're really into convincing Activator to use sbt.ivy.home, you have to change sbt/sbt.boot.properties in activator-launch-1.2.2.jar. Just follow the steps:

  1. Unpack sbt/sbt.boot.properties out of activator-launch-1.2.2.jar.

    jar -xvf activator-launch-1.2.2.jar sbt/sbt.boot.properties
    
  2. Edit sbt/sbt.boot.properties and replace ivy-home under [ivy].

    ivy-home: ${sbt.ivy.home-${user.home}/.ivy2}
    
  3. Add the changed sbt/sbt.boot.properties to activator-launch-1.2.2.jar.

    jar -uvf activator-launch-1.2.2.jar sbt/sbt.boot.properties
    

With the change, -Dsbt.ivy.home=./ivy2 works fine.

scala> appConfiguration.eval.provider.scalaProvider.launcher.bootDirectory
res0: java.io.File = /Users/jacek/sandbox/sbt-launcher/minimal-scala/sbt/boot

scala> appConfiguration.eval.provider.scalaProvider.launcher.ivyHome
res1: java.io.File = /Users/jacek/sandbox/sbt-launcher/minimal-scala/ivy2
like image 177
Jacek Laskowski Avatar answered Oct 31 '22 19:10

Jacek Laskowski