2
votes

I'm upgrading from Activator 2.3.x to 2.4.x (and eventually, to 2.5.x). As part of this migration, I can no longer use the activator eclipse command to generate an Eclipse project from the Play application.

I work on a team, some of which use IntelliJ. So, I cannot make these changes for each project, since it'd be unuseful for the IntelliJ users, and it'd be inappropriate to version with the project source.

I've been following these instructions. Here are the steps for migration that I've taken so far:

  1. Change project/plugins.sbt to use 2.4.6
  2. In project/application.conf, change evolutionplugin=disabled to play.evolutions.enabled=false
  3. In project/build.sbt, remove javaEbean from libraryDependencies
  4. Eclipse Users
    a. Download and install SBT: http://www.scala-sbt.org/
    - Extract to C:\dev\.sbt\0.13
    b. Create SBT_HOME environment variable - SBT_HOME=C:\dev\.sbt\0.13
    c. Add %SBT_HOME%\bin to PATH
    - PATH=...;%SBT_HOME%\bin;
    d. Create 'plugins' folder at %SBT_HOME%
    - C:\dev\.sbt\0.13\plugins
    e. Create plugins.sbt file in plugins directory
    - C:\dev\.sbt\0.13\plugins\plugins.sbt
    f. Add the following line to global plugins.sbt:
    - addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
    g. Edit %SBT_HOME%\conf\sbtopts to specify SBT plugins directory:
    - -sbt-dir C:/dev/.sbt/0.13/plugins
    h. Edit %SBT_HOME%\conf\sbtopts to specify SBT boot directory:
    - -sbt-boot C:/dev/.sbt/0.13/plugins/boot
    i. Create sbteclipse.sbt file at %SBT_HOME%

At this point, I should be able to create an Eclipse project, but it cannot resolve sbteclipse:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.typesafe.sbteclipse#sbteclipse-plugin;4.0.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]          com.typesafe.sbteclipse:sbteclipse-plugin:4.0.0 (scalaVersion=2.11, sbtVersion=0.13)
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]          com.typesafe.sbteclipse:sbteclipse-plugin:4.0.0 (scalaVersion=2.11, sbtVersion=0.13) (C:\dev\.sbt\0.13\plugins\plugins.sbt#L2-3)
[warn]            +- gateway-api:gateway-api_2.11:1.0-SNAPSHOT
sbt.ResolveException: unresolved dependency: com.typesafe.sbteclipse#sbteclipse-plugin;4.0.0: not found
        at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
        at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
        at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
        at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
        at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
        at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:133)
        at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
        at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
        at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
        at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
        at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
        at xsbt.boot.Using$.withResource(Using.scala:10)
        at xsbt.boot.Using$.apply(Using.scala:9)
        at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
        at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
        at xsbt.boot.Locks$.apply0(Locks.scala:31)
        at xsbt.boot.Locks$.apply(Locks.scala:28)
        at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
        at sbt.IvySbt.withIvy(Ivy.scala:128)
        at sbt.IvySbt.withIvy(Ivy.scala:125)
        at sbt.IvySbt$Module.withModule(Ivy.scala:156)
        at sbt.IvyActions$.updateEither(IvyActions.scala:168)
        at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1439)
        at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1435)
        at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1470)
        at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1468)
        at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
        at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1473)
        at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1467)
        at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
        at sbt.Classpaths$.cachedUpdate(Defaults.scala:1490)
        at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1417)
        at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1369)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
        at sbt.std.Transform$$anon$4.work(System.scala:63)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
        at sbt.Execute.work(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.sbteclipse#sbteclipse-plugin;4.0.0: not found
[error] Could not create Eclipse project files:
[error] Error evaluating task 'scalacOptions': error
[error] Error evaluating task 'externalDependencyClasspath': error

So, you can see from the steps outlined above, I'm trying to allow for us Eclipse users to create projects from the Play services. I downloaded SBT, extracted it to my dev folder, and started making global changes there.

Contents of C:\dev\.sbt\0.13\plugins\plugins.sbt:

// Support Play in Eclipse
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

Contents of C:\dev\.sbt\0.13\sbteclipse.sbt:

import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys

// Download Source and Javadocs with binaries
EclipseKeys.withSource := true
EclipseKeys.withJavadoc := true

// Compile the project before generating Eclipse files, so that generated .scala or .class files for views and routes are present
EclipseKeys.preTasks := Seq(compile in Compile)

// Java project. Don't expect Scala IDE
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java           

// Use .class files instead of generated .scala files for views and routes
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)  

Contents of C:\dev\.sbt\0.13\conf\sbtopts:

# ------------------------------------------------ #
#  The SBT Configuration file.                     #
# ------------------------------------------------ #


# Disable ANSI color codes
#
#-no-colors

# Starts sbt even if the current directory contains no sbt project.
#
-sbt-create

# Path to global settings/plugins directory (default: ~/.sbt)
#
#-sbt-dir   /etc/sbt
-sbt-dir    C:/dev/.sbt/0.13/plugins

# Path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
#
-sbt-boot   C:/dev/.sbt/0.13/plugins/boot

# Path to local Ivy repository (default: ~/.ivy2)
#
#-ivy ~/.ivy2

# set memory options
#
#-mem   <integer>  

# Use local caches for projects, no sharing.
#
#-no-share

# Put SBT in offline mode.
#
#-offline

# Sets the SBT version to use.
#-sbt-version  0.11.3

# Scala version (default: latest release)
#
#-scala-home <path>        
#-scala-version <version>

# java version (default: java from PATH, currently $(java -version |& grep version))
#
#-java-home <path>

Project exists at C:\dev\eclipse\workspaces\company\project. In Cygwin, I navigate to that location and execute sbt eclipse (or activator eclipse, which has the same outcome), which according to my understanding should work. But, like I said, I get an error, and it doesn't work.

Can someone help me get this set up correctly so that I can create Eclipse project files for a Play service, and continue on my happy lil migration journey?

I think the sbteclipse plugin is trying to be pulled in with my system's version of scala, instead of the version specified by the plugin and provided in the boot folder.

1

1 Answers

0
votes

I did recently migration from Play 2.4 to Play 2.5 and described the whole procedure in this post. In another post you can find how to "eclipcify" the project.

I did not pay attention, that your use the global sbt settings. For global sbt settings:

  1. Create c:\dev\.sbt\0.13\plugins\plugins.sbt with content:

    //Support Play in Eclipse
    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
    
  2. Create C:\dev\.sbt\sbteclipse.sbt with content:

    import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
    EclipseKeys.preTasks := Seq(compile in Compile)
    EclipseKeys.withSource := true
    EclipseKeys.withJavadoc := true
    
    // Java project. Don't expect Scala IDE
    EclipseKeys.projectFlavor := EclipseProjectFlavor.Java
    
    // Use .class files instead of generated .scala files for views and routes
    EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)  
    

    Note: In my case instead of dev is my user root directory.

  3. The project build.sbt:

    import NativePackagerHelper._
    name := """play-server-example"""
    
    version := "1.0-SNAPSHOT"
    
    lazy val root = (project in file(".")).enablePlugins(PlayJava)
    
    scalaVersion := "2.11.8"
    
    resolvers += "Local Maven Repository" at "file:///"+Path.userHome.absolutePath+"/.m2/repository"
    
    libraryDependencies ++= Seq(javaJdbc, cache, javaWs)
    

    Note: Originally I used scalaVersion := 2.11.7, since this was generated value, but for the test I put 2.11.8. This works with both of them.

  4. I do not have anything more: no sbt options, only sbt home in environment variables (just like it is in my post).

The bottom line: I did only items 1,2,3 to get the things working.