'Not a valid key' error from sbt-release build command - scala

I installed the sbt-release plugin in my scala sbt project.
But when I run sbt release cross build or sbt release skip-tests, I get this error:
Not a valid key: cross (similar: crossPaths, crossTarget, cross-paths)

If you want to run release cross with-defaults or release skip-tests from the command line you need to quote it:
$ sbt 'release cross with-defaults'
$ sbt 'release skip-tests'

For some reason the release plugin doesn't play nice when you run it this way.
Try running sbt, then run release from within the console.

Related

compile/package multiple configurations from command line sbt scala

is there a way to build/compile all configurations at once? I have a project that has a Dev configuration in addition to the default Compile and Test configuration, and i am looking for a command or a setting in my build.sbt that would allow me to compile/package all 3 configurations at once.
Basically looking for a way to avoid having to do these 3 commands to build the entire source tree:
sbt compile
sbt dev:compile
sbt test:compile
When I use sbt from IntelliJ it is able to do this on building the project, but I am looking to do this from the command line.
First, you can run multiple tasks with a single sbt invocation:
sbt compile dev:compile test:compile
Second, you could define an alias in your build which does what you want:
addCommandAlias("compileAll", "; compile; dev:compile; test:compile")
Then, just run sbt compileAll.

Tasks stuck with sbt 1.0

Following the "https://www.coursera.org/learn/scala-spark-big-data/supplement/R7FJ9/eclipse-tutorial" course, I'm trying to create a eclipse project from sbt, by adding sbteclipse plugin.
sbt new scala/hello-world.g8
cd hello-world
echo 'addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")' > project/plugins.sbt
sbt> eclipse
It should last a minute and return several successful, but instead it stay still, it gets stuck. The message I've received is
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
I've installed sbt 1.0.2, it fails, then I'd install sbt 0.13.16 and still fails. Checking the sbt version it says it's 1.0.2 (although I'd uninstalled sbt 1.0.2 to install the older version).
checking https://github.com/typesafehub/sbteclipse/issues/346 it seen like this is a brand new issue, it's supose the gets fix by typing sbt.version=0.13.16 in project/build.properties, but even after that the problem persist. I don't know if problem persist because is a fix for Mac and I'm working on windows 10, or if the solution saids is for sbt.version=0.13.15 and I'm using sbt.version=0.13.16.
Checking the \scala hello world\hello-world\eclipse file it says:
[error] [C:\Users\israel.rodriguez\Documents\eclipse\scala hello world\hello-world\project\plugins.sbt]:1: unclosed character literal
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
Terminate batch job (Y/N)?
checking the \scala hello world\hello-world\project\plugins.sbt I found :
'addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")'
when removing the ' ' at the beginning and the end. the \scala hello world\hello-world\eclipse file saids :
[info] Loading project definition from
C:\Users\israel.rodriguez\Documents\eclipse\scala hello
world\hello-world\project
[info] Set current project to hello-world (in build file:/C:/Users/israel.rodriguez/Documents/eclipse/scala%20hello%20world/hello-world/)
and it remain there for eternity. with the same message on windows shell :
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option
MaxPermSize=256m; support was removed in 8.0
My question is, what's wrong over here? ,and how can I solve or work around this. Sorry for the rookie question, is my firt time with sbt, scala or spark.
I was in exact same scenario with the same problem as mentioned above. Here is how I overcame it.
Firstly there is no problem in steps that you follow everything is correct except:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")
Use latest version for the sbt plugin form, which is:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
The latest version handles the hanging console problem as described here, also there is no need to use '' at the beginning and the end.
Step: 1. Download and install sbt from here (windows sbt-1.0.4.msi)
Step 2. Go to cmd prompt and type sbt about, it will display something like this
C:\Users\rajnish.kumar>sbt about
"C:\Users\rajnish.kumar\.sbt\preloaded\org.scala-sbt\sbt\"1.0.4"\jars\sbt.jar"
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[warn] Executing in batch mode.
[warn] For better performance, hit [ENTER] to switch to interactive mode, or
[warn] consider launching sbt without any commands, or explicitly passing 'shell'
[info] Loading project definition from C:\Users\rajnish.kumar\project
[info] Set current project to rajnish-kumar (in build file:/C:/Users/rajnish.kumar/)
[info] This is sbt 0.13.15
[info] The current project is {file:/C:/Users/rajnish.kumar/}rajnish-kumar 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.6
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.6
I'm not sure why it says "This is sbt 0.13.15"; if anybody knows please answer it here.
Step 3. Go to your workspace form cmd prompt and type and hit sbt new sbt/scala-seed.g8, type project name as (e.g. hello) when asked.
Step 4. Now move to your project directory i.e cd hello
Step 5. Now type echo addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4") > project/plugins.sbt
Step 6. Make sure you are inside the hello project and then instead of calling sbt > eclipse (if you will do like this way then it will get stuck in the same infinite loop as you're getting) only call sbt and it will start the server on default port.
Step 7. Now type eclipse, now it will start downloading all dependency, eventually it will show Successfully created Eclipse project files for project(s):
Step 8. Import project (hello) to Eclipse as normal and it will work. Please not do not call sbt > eclipse in single go call them one by one first call sbt and when server is started then only call Eclipse.
I had the same issue when I start reading about scala.
Concerning the problem of [\plugins.sbt]:1: unclosed character literal] use :
echo addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0") > project/plugins.sbt
Remove the simple quote from the begining and the end of the echo first parameter
I had the very same issue as you describe. I use Windows 10 and wonder if it just occurs on that system.
It works if I use sbteclipse 5.2.4 and some other small modifications:
cd hello-world
echo 'addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")' > project/plugins.sbt
Next, I need to go to project/plugins.sbt and remove the ' at the beginning and end of the line.
Now, do NOT enter sbt > eclipse! This will just pipe the sbt console into a the newly created file and you won't execute eclipse. Instead, typ the following into the command line:
sbt eclipse

sbt new not a valid command

I am going through a coursera course and as explained, I am trying to create a new sbt project using the below command:
sbt new scala/hello-world.g8
In a Windows machine. I have sbt 0.13.8 installed. When executing the command it is giving the below error.
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Set current project to workspaces (in build file:/D:/software%20materials%20workspaces/WorkSpaces/)
[error] Not a valid command: new (similar: set)
[error] Not a valid project ID: new
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: new (similar: name, run, runner)
[error] new
[error] ^
I am not able to understand what the problem is. Help me out in understanding and solving this problem
I agree with Seth. It looks like the first version to include new is 0.13.13. I just came across this in creating new apps with more recent versions of the Scala Play framework (ex: 2.5). The github templating command line, giter8, is called via sbt new like this:
sbt new scala/scala-seed.g8
On my Mac I ran into a similar issue and fixed it by updating brew (used to install) then updating sbt:
brew update
brew upgrade sbt
First step was needed so the latest sbt could install. If whatever package manager you are using is out of date, it may result in the same problem. Not sure what Windows needs to install but this may help with others landing on this question.

spark's example can not build in intellij

I follow someone's tutorial to compile spark 2.1.0 and run one of its example in intellij IDEA 2016.3.4(scala 2.11.8) ,here is my steps:
download spark 2.1.0 from git(win 10 64bit)
I build it using "$ build/mvn -T 4 -DskipTests clean package" in cygwin
open the project in intellij
mark spark-streaming-flume-sink_2.11's target directory as Sources,and also its sub directory \target\scala-2.11\src_managed\main\compiled_avro\org\apache\spark\streaming\flume\sink
add {spark dir}/spark/assembly/target/scala-2.11/jars/*.jars as spark-examples_2.11 's Dependencies
But when I build the spark project,here is error message:
Even I delete this test class SparkSinkSuite ,the similar error "object xx is not a member of package xx" happen in other class(I found all the problem class are in 'external' module)
I've tried restart the intellij even the computer ,it doesn't help.

Configure repo for SBT launcher in Travis build

Where can I override the repo URL that SBT uses to fetch its launcher when the SBT instance is provided by Travis-CI?
http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.8/sbt-launch.jar is currently giving 404s and, as a result, the builds are failing on Travis with:
$ sbt clean dependencyUpdates coverage test coverageReport
Detected sbt version 0.13.8
Downloading sbt launcher for 0.13.8:
From http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.8/sbt-launch.jar
To /home/travis/.sbt/launchers/0.13.8/sbt-launch.jar
Download failed. Obtain the jar manually and place it at /home/travis/.sbt/launchers/0.13.8/sbt-launch.jar
I ran into the same problem today, and logged an issue for travis-ci: https://github.com/travis-ci/travis-ci/issues/4527
As a workaround, you can download the sbt-launcher.jar by adding a before_script section to your .travis.yml
before_script:
- mkdir -p $HOME/.sbt/launchers/0.13.8/
- curl -L -o $HOME/.sbt/launchers/0.13.8/sbt-launch.jar http://dl.bintray.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.8/sbt-launch.jar
We just deployed the fix to production. SBT builds should be working now.
Sorry for the inconvenience.
https://github.com/travis-ci/travis-ci/issues/4527#issuecomment-124123880