How can I create a new play project for a specific version?
using sbt new playframework/play-scala-seed.g8 it will always create a project pointing to the last version of Play (in this case 2.7).
The thing is that there isn't support for that version in gradle yet and I don't want to use sbt.
How can I specify version 2.6.6?
In your /project/plugins.sbt file you can specify which version of play you want to use.
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.6")
Reference : https://www.playframework.com/documentation/2.6.x/BuildOverview#Play-plugin-for-sbt-(/project/plugins.sbt)
Related
In a play application I found that "eclipse" command works by default without adding "sbt eclipse" plugin in the plugins.sbt file. However in case of Sbt this works only if this plugin definition is added.
I was just wondering if Play is a wrapper over SBT with additional features available by default?
Indeed, Play is an sbt plugin. You can read about it in the documentation: Create a new application without Activator
You can defined the eclipse plugin globally.
Settings can be placed here: ~/.sbt/0.13/eclipseSettings.sbt
EclipseKeys.eclipseOutput := Some(".target")
Plugins can be placed here: ~/.sbt/0.13/plugins/eclipse.sbt
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
Activator itself is also built upon sbt: Typesafe Activator, What is it?
I have written a Scala program with Eclipse Scala IDE that uses scala.util.parsing.JSON and I would like to transform it to support Scala 2.11 version. In Scala 2.11 I get an error:
error: object parsing is not a member of package util.
I have found out that the parsing library is not anymore in the util package by default, but has to be downloaded separately here.
I have downloaded that and tried to add it to my Eclipse project as a new source folder, but that didn't work out. The instructions are only for adding it to sbt, but I don't think that is relevant to me if I want to just use it in Eclipse.
Should I try to find a JAR file somewhere?
Should I try to find a JAR file somewhere?
Yes, you should. :)
And specifically, you should use this one (in SBT syntax):
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.2"
The above line should be all you need to add to build.sbt if you're using SBT. If you want to manually add it to your project by downloading it, you can find it on Maven Central.
The scala-parser-combinators library was removed in 2.11 so that people who don't use it don't have to pay a price for having it in the scala runtime library. Consequently, people who do want to use it have to now explicitly include it in their build. Note that the XML library was similarly removed in 2.11 to its own library.
Background
I am developing a Play 2.2.3 application; the Play build system uses sbt.
I am using Sonatype Nexus OSS to manage various libraries built and deployed by Maven. At the moment, I am deploying snapshot versions of those libraries. For instance:
<groupId>myGroup</groupId>
<artifactId>myArtifact</artifactId>
<version>0.1-SNAPSHOT</version>
The Play application depends on snapshot versions of those libraries.
Intention
In the Play project, I want to use a specific (thus, "timestamped") snapshot version of a dependency -- say 0.1-20140509.053703-1 -- instead of the latest one as specified by 0.1-SNAPSHOT.
Issue
While the latter works perfectly well, sbt seems to be unable to resolve the specific version. At least sbt constructs the URL pointing to that specific version faultily: The name of the directory that contains the artifact ends with the actual timestamp instead of string SNAPSHOT.
Example
I created a new Play application and added the following dependency in file build.sbt: libraryDependencies += "myGroup" % "myArtifact" % "0.1-20140509.053703-1"
When resolving that dependency, sbt constructs URLs ending with myGroup/myArtifact/0.1-20140509.053703-1/myArtifact-0.1-20140509.053703-1.pom.
Note that the 3rd path component is 0.1-20140509.053703-1. Thus, the directory containing artifact myArtifact incorrectly contains the timestamp as well.
The correct directory name would be 0.1-SNAPSHOT; thus, using SNAPSHOT instead of the actual timestamp. The complete correct URL would thus end with myGroup/myArtifact/0.1-SNAPSHOT/myArtifact-0.1-20140509.053703-1.pom.
Referring to the latest snapshot version instead by using dependency entry libraryDependencies += "myGroup" % "myArtifact" % "0.1-SNAPSHOT" works. The URLs end with 0.1-SNAPSHOT/myArtifact-0.1-SNAPSHOT.pom.
Question
How could I persuade sbt to download a specific snapshot version?
I have been trying to create a Play2 IntelliJ project file using the sbt-idea plugin.
I have added the line to my build.sbt file:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
However, since updating to the latest version of Play 2.2.1, I have been seeing the following error when trying to create project files:
[error] java.nio.charset.UnmappableCharacterException: Input length = 1
Has anyone else seen this error? It was working fine prior to updating my Play project to 2.2.1.
The latest version of IntelliJ IDEA 13 comes with "The new version of Scala plugin comes with built-in support for SBT" so you should be able to import the project without the plugin's help.
So after an hour or so of looking at colleague's codebases which WERE able to successfully generate the IntelliJ project files, I have updated the plugin details as follows to version 1.5.1 (rather than 1.5.2):
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1")
And now it works again as expected. Has anyone else seen this issue with Play 2.2.1 and the plugin https://github.com/mpeltonen/sbt-idea ? Is there a better solution, or some other incompatibility I need to resolve?
is any IDE supporting SBT in a proper way (like Maven for example)? Because I've found a lot of tools that generate IDE-related configuration files but I haven't found any plugins that give any support of SBT interaction form within IDE.
I want to make an IDE-agnostic project based on SBT, but also I want to be able to use full spectrum of features that IDE provide and not just use it as an editor and do all the other stuff from console.
Does Intellij fit the bill ? It has an SBT plugin (and a Scala plugin, obviously!)
I know this isn't exactly what you're looking for, but putting it here as a work-around for working with SBT in eclipse for whoever is interested.
SBT generates eclipse config files, but after you import it, it works fine from within eclipse. You just need to set up the project for the first time outside of Eclipse, run SBT to resolve dependencies, generate eclipse structure using the eclipse sbt plugin and import into Eclipse. After that, you can run the code directly from Eclipse and it works fine.
Here're the steps in detail:
Create the folder structure as follows:
Create a file called plugins.sbt in the project folder and add the following line to it:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")
Create build.sbt in the root directory i.e. ScalaSBTProject with content similar to the following. I'm using akka here, but add and remove libraries as you require:
name := "ScalaSBTProject"
version := "1.0"
scalaVersion := "2.10.0-RC2"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" % "akka-cluster-experimental_2.10.0-RC2" % "2.1.0-RC2"
Open command prompt and run sbt in the directory ScalaSBTProject. SBT will download and resolve whatever dependencies are required
Run the command eclipse at the SBT command line. This will generate all the eclipse related project files
Import ScalaSBTProject into Eclipse using File->Import->Existing Project to workspace, and make sure you check Import into workspace
EDIT: Just as a Post-Script, you can quite easily create a batch file to take the name of the project and generate the eclipse compatible project, just a way to speed up the process.