sbt 0.12.0 launcher problem with projectid with spaces in Build.scala

1,509 views
Skip to first unread message

Dave

unread,
Aug 5, 2012, 7:54:51 AM8/5/12
to simple-b...@googlegroups.com
With the sbt 0.11.3 launcher having spaces in the projectid in Build.scala and in the foldername was no problem.
e.g.
 
import sbt._
import Keys._
object General {
  val settings
= Defaults.defaultSettings ++ Seq (
    name
:= "ProjectId With Spaces",
    version
:= "0.1")
}
object TestBuild extends Build {
  lazy val main
= Project ("ProjectId With Spaces",
                           file
("."),
                           settings
= General.settings)
}

 
 
e.g. sbt starts
 
 
But with the sbt launcher 0.12.0 I get
 
C:\Users\Dave\ProjectId With Spaces>java -jar "c:\sbt\sbt-launch-0.12.0.jar"
[info] Loading global plugins from C:\Users\Dave\.sbt\plugins
[info] Loading project definition from C:\Users\Dave\ProjectId With Spaces\proje
ct
[error] Invalid project ID: Expected ID character
[error] ProjectId With Spaces
[error]          ^
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
 
 
Is this intended or a bug? The strange thing is that in build.sbt I don't have this problem with the sbt 0.12.0 launcher.
The problem stays even if you use the 0.12.0 launcher with
 
sbtVersion in update := "0.11.3"
 
so it is something launcher specific..
 
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? l
[info] Loading global plugins from C:\Users\Dave\.sbt\plugins
[debug] Running task... Cancelable: false, check cycles: false
[debug]
[debug] Initial source changes:
[debug]         removed:Set()
[debug]         added: Set()
[debug]         modified: Set()
[debug] Removed products: Set()
[debug] Modified external sources: Set()
[debug] Modified binary dependencies: Set()
[debug] Initial directly invalidated sources: Set()
[debug]
[debug] Sources indirectly invalidated by:
[debug]         product: Set()
[debug]         binary dep: Set()
[debug]         external source: Set()
[debug] Initially invalidated: Set()
[debug] Copy resource mappings:
[debug]
[debug] Other repositories:
[debug] Default repositories:
[debug]         Raw(ProjectResolver(inter-project, mapped: ))
[debug]         URLRepository(typesafe-ivy-releases,sbt.Patterns@800aa1)
[debug]         URLRepository(sbt-plugin-releases,sbt.Patterns@39da8a)
[debug]         FileRepository(local,FileConfiguration(true,None),sbt.Patterns@3
acc67)
[debug]         URLRepository(typesafe-ivy-releases,sbt.Patterns@800aa1)
[debug]         Sonatype OSS Releases:
https://oss.sonatype.org/content/reposito
ries/releases
[debug]         public:
http://repo1.maven.org/maven2/
[debug] Using inline dependencies specified in Scala.
[debug] post 1.3 ivy file: using exact as default matcher
[info] Loading project definition from C:\Users\Dave\ProjectId With Spaces\proje
ct
[debug] Running task... Cancelable: false, check cycles: false
[debug]
[debug] Initial source changes:
[debug]         removed:Set()
[debug]         added: Set()
[debug]         modified: Set()
[debug] Removed products: Set()
[debug] Modified external sources: Set()
[debug] Modified binary dependencies: Set()
[debug] Initial directly invalidated sources: Set()
[debug]
[debug] Sources indirectly invalidated by:
[debug]         product: Set()
[debug]         binary dep: Set()
[debug]         external source: Set()
[debug] Initially invalidated: Set()
[debug] Copy resource mappings:
[debug]
java.lang.RuntimeException: Invalid project ID: Expected ID character
ProjectId With Spaces
         ^
        at scala.sys.package$.error(package.scala:27)
        at scala.Predef$.error(Predef.scala:123)
        at sbt.Project$$anonfun$apply$2.apply(Project.scala:153)
        at sbt.Project$$anonfun$apply$2.apply(Project.scala:153)
        at scala.Either$LeftProjection.foreach(Either.scala:300)
        at sbt.Project$.apply(Project.scala:153)
        at TestBuild$.main(Build.scala:11)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at sbt.ReflectUtilities$$anonfun$allValsC$1$$anonfun$apply$2.apply(Refle
ctUtilities.scala:46)
        at sbt.ReflectUtilities$$anonfun$allValsC$1$$anonfun$apply$2.apply(Refle
ctUtilities.scala:44)
        at scala.Option$WithFilter.foreach(Option.scala:176)
        at sbt.ReflectUtilities$$anonfun$allValsC$1.apply(ReflectUtilities.scala
:44)
        at sbt.ReflectUtilities$$anonfun$allValsC$1.apply(ReflectUtilities.scala
:40)
        at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimize
d.scala:34)
        at scala.collection.mutable.ArrayOps.foreach(ArrayOps.scala:38)
        at sbt.ReflectUtilities$.allValsC(ReflectUtilities.scala:40)
        at sbt.ReflectUtilities$.allVals(ReflectUtilities.scala:55)
        at sbt.Build$class.projects(Build.scala:22)
        at TestBuild$.projects(Build.scala:10)
        at sbt.Build$class.projectDefinitions(Build.scala:21)
        at TestBuild$.projectDefinitions(Build.scala:10)
        at sbt.Load$$anonfun$projects$1.apply(Load.scala:379)
        at sbt.Load$$anonfun$projects$1.apply(Load.scala:379)
        at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(Traversable
Like.scala:239)
        at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(Traversable
Like.scala:239)
        at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.
scala:59)
        at scala.collection.immutable.List.foreach(List.scala:76)
        at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:
239)
        at scala.collection.immutable.List.flatMap(List.scala:76)
        at sbt.Load$.projects(Load.scala:379)
        at sbt.Load$.loaded(Load.scala:280)
        at sbt.Load$.loadAll(Load.scala:307)
        at sbt.Load$.loadURI(Load.scala:260)
        at sbt.Load$.load(Load.scala:256)
        at sbt.Load$.load(Load.scala:247)
        at sbt.Load$.apply(Load.scala:124)
        at sbt.Load$.defaultLoad(Load.scala:39)
        at sbt.BuiltinCommands$.doLoadProject(Main.scala:400)
        at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:394)
        at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:394)
        at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.sca
la:60)
        at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.sca
la:60)
        at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.sca
la:62)
        at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.sca
la:62)
        at sbt.Command$.process(Command.scala:90)
        at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(MainLoop.scala:71
)
        at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(MainLoop.scala:71
)
        at sbt.State$$anon$2.process(State.scala:170)
        at sbt.MainLoop$$anonfun$next$1.apply(MainLoop.scala:71)
        at sbt.MainLoop$$anonfun$next$1.apply(MainLoop.scala:71)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
        at sbt.MainLoop$.next(MainLoop.scala:71)
        at sbt.MainLoop$.run(MainLoop.scala:64)
        at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:53)
        at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:50)
        at sbt.Using.apply(Using.scala:25)
        at sbt.MainLoop$.runWithNewLog(MainLoop.scala:50)
        at sbt.MainLoop$.runAndClearLast(MainLoop.scala:33)
        at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:17)
        at sbt.MainLoop$.runLogged(MainLoop.scala:13)
        at sbt.xMain.run(Main.scala:26)
        at xsbt.boot.Launch$.run(Launch.scala:55)
        at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
        at xsbt.boot.Launch$.launch(Launch.scala:69)
        at xsbt.boot.Launch$.apply(Launch.scala:16)
        at xsbt.boot.Boot$.runImpl(Boot.scala:31)
        at xsbt.boot.Boot$.main(Boot.scala:20)
        at xsbt.boot.Boot.main(Boot.scala)
[error] Invalid project ID: Expected ID character
[error] ProjectId With Spaces
[error]          ^
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
 
 
 
 

Mark Harrah

unread,
Aug 7, 2012, 11:13:20 AM8/7/12
to simple-b...@googlegroups.com
On Sun, 5 Aug 2012 04:54:51 -0700 (PDT)
Dave <dave.mah...@hotmail.com> wrote:

> With the sbt 0.11.3 launcher having spaces in the projectid in Build.scala
> and in the foldername was no problem.

It isn't a problem in the name or in the directory name. It was always a problem in the ID, but perhaps it wasn't checked early enough before.

-Mark
> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/7-brx2Q2Hb0J.
> To post to this group, send email to simple-b...@googlegroups.com.
> To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
>

Dave

unread,
Aug 7, 2012, 11:38:25 AM8/7/12
to simple-b...@googlegroups.com
And are capitals also allowed in the projectid or should I use lowercases and dashes for the spaces? Capitals seem to be allowed in 0.12.0
e.g. "projectid-with-spaces" but "ProjectId-With-Spaces" works too
And what is the use of projectid since it isn't used in build.sbt?
 
{{{
import sbt._
import Keys._
object General {
val settings
= Defaults.defaultSettings ++ Seq (
name
:= "ProjectId With Spaces",
version
:= "0.1")
}
object TestBuild extends Build {

lazy val main
= Project ("projectid-with-spaces",

file
("."),
settings
= General.settings)
}

Mark Harrah

unread,
Aug 7, 2012, 12:15:29 PM8/7/12
to simple-b...@googlegroups.com
On Tue, 7 Aug 2012 08:38:25 -0700 (PDT)
Dave <dave.mah...@hotmail.com> wrote:

> And are capitals also allowed in the projectid or should I use lowercases
> and dashes for the spaces? Capitals seem to be allowed in 0.12.0
> e.g. "projectid-with-spaces" but "ProjectId-With-Spaces" works too

Yes. The error you saw originally was from a call to a method validID that checks whether a string is a valid ID. So, if you don't get an error, it is ok.

The allowed characters are letters, digits, '_', and '-' and it must start with a letter.

> And what is the use of projectid since it isn't used in build.sbt?

It is used as the unique identifier for a project. The 'project' and 'projects' commands current operates on IDs and keys operate on IDs. (Settings/tasks are scoped by project and the ID is used here. You don't often specify it explicitly because a default exists based on context.)

-Mark

> {{{
> import sbt._
> import Keys._
> object General {
> val settings = Defaults.defaultSettings ++ Seq (
> name := "ProjectId With Spaces",
> version := "0.1")
> }
> object TestBuild extends Build {
> lazy val main = Project ("projectid-with-spaces",
> file("."),
> settings = General.settings)
> }
>
>
>
>
>
> }}}
>
>
> On Tuesday, August 7, 2012 5:13:20 PM UTC+2, Mark Harrah wrote:
>
> > On Sun, 5 Aug 2012 04:54:51 -0700 (PDT)
> > Dave wrote:
> >
> > > With the sbt 0.11.3 launcher having spaces in the projectid in
> > Build.scala
> > > and in the foldername was no problem.
> >
> > It isn't a problem in the name or in the directory name. It was always a
> > problem in the ID, but perhaps it wasn't checked early enough before.
> >
> > -Mark
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/Dqaxxmja9CMJ.

Dave

unread,
Aug 7, 2012, 1:07:51 PM8/7/12
to simple-b...@googlegroups.com
Is it possible to derive the projectid (with some transformation) from the name?
I try to do this, but it doesn't work.
 
{{{
import sbt._
import Keys._
object General {
  val settings = Defaults.defaultSettings ++ Seq (
    name := "ProjectId With Spaces",
    version := "0.1")
}
object TestBuild extends Build {
  lazy val main = Project (General.settings(name).replace(" ","-").toLowerCase},

                           file("."),
                           settings = General.settings)
}

Dave

unread,
Aug 7, 2012, 3:57:52 PM8/7/12
to simple-b...@googlegroups.com
I found a workaround but it is strange that I cannot do it directly
There is no way to go from SettingKey[String] to String 
Once wrapped it cannot be unwrapped.
 
{{{
import sbt._
import Keys._
object General {
  val projectname = "ProjectId With Spaces"

  val settings = Defaults.defaultSettings ++ Seq (
    name := projectname,
    version := "0.1")
}
object TestBuild extends Build {
  lazy val main = Project (General.projectname.replace(" ","-").toLowerCase,

Mark Harrah

unread,
Aug 8, 2012, 8:41:33 AM8/8/12
to simple-b...@googlegroups.com
On Tue, 7 Aug 2012 12:57:52 -0700 (PDT)
Dave <dave.mah...@hotmail.com> wrote:

> I found a workaround but it is strange that I cannot do it directly
> There is no way to go from SettingKey[String] to String
> Once wrapped it cannot be unwrapped.

Correct. This is by design. The project ID needs to be known before settings are evaluated. You can use the StringUtilities.normalize method to transform the name into an ID. It isn't guaranteed to produce a valid ID, but it will work in typical cases.

-Mark

> {{{
> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/tBIfhZhOfyUJ.
Reply all
Reply to author
Forward
0 new messages