Saturday, October 19, 2013

SBT application for Netbeans from scratch

  • mkdir NetbeansSBT
  • mkdir NetbeansSBT
  • Create a new file called build.sbt in the NetbeansSBT directory and add the following lines to it.

name := "netbeans-sbt-1"

version := "1.0"

scalaVersion := "2.10.2"

sbtVersion := "0.12.4"

  • Don't forget to seperate them with empty lines
  • Create a directory called project in the root project directory.
  • Create two files build.properties and plugins.sbt.
  • Open project/build.properties and add the following line

sbt.version=0.12.4

  • Open project/plugins.sbt and add the following line to it.

addSbtPlugin( "org.netbeans.nbsbt" % "nbsbt-plugin" % "1.0.2" )

Notice how the sbt version inside the build.sbt and build.properties match. This is needed.

  • Run the following command from the root directory.

mkdir -p src/main/scala src/main/resources src/test/scala src/test/resources

At this point you should have your project setup. You can now run the following command to compile the project.

sbt clean compile publish-local

We still have to generate netbeans project files so that it can be opened in Netbeans for editing. Use the following commands to do that.

  • Run sbt

    sbt

If you are able to run sbt command ok, you should see output similar to this.

[info] Loading global plugins from /home/venkat/.sbt/plugins

[info] Loading project definition from /home/venkat/Documents/Scala/Scalatra/scalatra-sbt-1/project

[info] Set current project to scalatra-sbt-1 (in build file:/home/venkat/Documents/Scala/Scalatra/scalatra-sbt-1/)`

  • From sbt prompt run the netbeans command. This should generate netbeans files.

> netbeans

[info] About to create NetBeans project files for your project(s).

[info] Successfully created NetBeans project files for project(s):

[info] scalatra-sbt-1

Bingo ! Open the project up in Netbeans. Rant and rave in the comment section.

No comments:

Post a Comment