Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change location of .activator .sbt .ivy folders in Play 2.3?

I have just started learning Play Framework 2.3.0 and am trying to move

  • .activator
  • .sbt
  • .ivy

folders from %USERPROFILE% folder to a custom folder like C:/learning/playframework/ on my Windows 7 machine. I want them to be portable / not lost during a OS re install.

I modified the sbt.boot.properties and changed the user.home to the custom location and passed play.home to activator.bat as a parameter.

Although .sbt and .ivy folders are initially created in the custom folder, when I try to create a new application HelloWorld all these folders again get created in the user directory %USERPROFILE% and all the files are downloaded there. The .activator never gets created in the custom folder and is always created in the %USERPROFILE% folder.

I also made sure there were no spaces in the paths.

sbt.boot.properties:

[app]
  org: com.typesafe.activator
  name: activator-launcher
  version: ${activator.version-read(activator.version)[1.2.1]}
  class: activator.ActivatorLauncher
  cross-versioned: false
  components: xsbti

[repositories]
  local
  activator-local: file://${activator.local.repository-${activator.home-${play.home}/.activator}/repository}, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
  maven-central
  typesafe-releases: http://repo.typesafe.com/typesafe/releases
  typesafe-ivy-releasez: http://repo.typesafe.com/typesafe/ivy-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]

[boot]
 directory: ${sbt.boot.directory-${sbt.global.base-${play.home}/.sbt}/boot/}
 properties: ${activator.boot.properties-${play.home}/.activator/version-${activator.launcher.generation-0}.properties}

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

Please advise on configuring the Activator/Play Framework such that - the 3 directories and the repository get created in a custom directory, say C:/learning/playframework/.

like image 831
Jay Avatar asked Jun 12 '14 10:06

Jay


2 Answers

The .activator never gets created in the custom folder and is always created in the %USERPROFILE% folder.

My understanding is that ~/.activator is controlled by the startup script where you should be able to point to a custom directory.

For ~/.sbt you should really be using sbt.global.base property as I see it used in the sbt code itself.

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 171
Jacek Laskowski Avatar answered Nov 09 '22 22:11

Jacek Laskowski


Just add a activatorconfig.txt file %USERPROFILE%/.activator/ In this file, place the following content :

-Dactivator.local.repository=C:\learning\playframework\repository
-Dactivator.home=C:\learning\playframework\
-Dsbt.ivy.home=C:\learning\playframework\repository
-Duser.home=C:\learning\playframework\
-Divy-home=C:\learning\playframework\repository
like image 42
DrMabulle Avatar answered Nov 09 '22 23:11

DrMabulle