Skip to content

Commit

Permalink
Changes for sbt 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiko Seeberger committed Jun 19, 2013
1 parent 8055490 commit c7e8560
Show file tree
Hide file tree
Showing 39 changed files with 159 additions and 80 deletions.
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# SBT
# sbt
.history
boot/
lib_managed/
target/
.history

# Eclipse
.cache
Expand All @@ -10,16 +11,19 @@ target/
.scala_dependencies
.settings
.target/
.worksheet/
*.sc

# IntelliJ
.idea/
out/
*.iml
*.ipr
*.iws
out/

# TextMate
*.tmproj
# ENSIME
.ensime
.ensime_lucene/

# Mac
.DS_Store
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
sbt-groll
=========

Plugin for [sbt](http://www.scala-sbt.org) to "roll" – view and navigate – the [Git](http://git-scm.com/) commit history. This turns out to be very useful for live coding and training sessions.

Installing sbt-groll
--------------------

sbt-groll is a plugin for sbt. In order to install sbt, please refer to the [sbt documentation](http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html). Please make sure that you are using a suitable version of sbt:

- sbt-groll 1.5 → sbt 0.12
- sbt-groll 1.6 → sbt 0.13

Additionally sbt-groll requires a local Git installation. In order to install Git, please check out the [Git downloads page](http://git-scm.com/download) or use a package manager like [Homebrew](http://mxcl.github.io/homebrew/) for Mac OS.

As sbt-groll is a plugin for sbt, it is installed like any other sbt plugin, that is by mere configuration: just add sbt-groll to your global or local plugin definition. Global plugins are defined in `~/.sbt/<SBT_VERSION>/plugins/plugins.sbt` and local plugins are defined in `project/plugins.sbt` in your project.

In order to add sbt-groll as a plugin, just add the below setting to the relevant plugin definition, paying attention to blank lines between settings:

```
addSbtPlugin("name.heikoseeberger" % "sbt-groll" % "1.6.0")
```

After adding the sbt-groll plugin like this, you should either start sbt or, if it was already started, reload the current session by executing the `reload` command. If everything worked, you should have the new `groll` command available.

Using sbt-groll
---------------

sbt-groll provides the `groll` command that provides various options to view and navigate the Git history. Of course this means, that you can only use sbt-groll for projects which are using Git as version control system.

If you are navigating through the Git history, i.e. moving to some commit, sbt-groll will reload the sbt session if the build definition changed.

In order to use sbt-groll, just execute `groll` in an sbt session, giving one of the options described below:

```
> groll show
[info] Current commit: 534ef78 Exercise: Add XML serialization to Time
> groll move=bc1ac93
[info] Moved to commit: bc1ac93
```

Settings
--------

sbt-groll can be configured by the following settings:

- `postCommands: Seq[String]`: The commands to be executed after "rolling". If not defined, the empty sequence is used, i.e. not other commands are executed.
- `revision: String`: The revision (branch or tag) used for the Git history. If not defined, "master" is used.

Options
-------

The `groll` command must be followed by one of the following options:

- `show`: Shows the current commit id and message, if current commit is in history
- `list`: Shows all commits
- `next`: Moves to the next commit, reloading the sbt session if the build definition has changed, if current commit is in history
- `prev`: Moves to the previous commit, reloading the sbt session if the build definition has changed, if current commit is in history
- `head`: Moves to the head of the commit history, reloading the sbt session if the build definition has changed
- `initial`: Moves to a commit with message "Initial state", reloading the sbt session if the build definition has changed
- `move`: Moves to the given commit, reloading the sbt session if the build definition has changed

Contribution policy
-------------------

Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.

License
-------

This code is open source software licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).
35 changes: 19 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@ organization := "com.typesafe.sbt"

name := "sbt-osgi"

// version is defined in version.sbt in order to support sbt-release

sbtPlugin := true
// TODO Move version to version.sbt in order to support sbt-release
version := "0.6.0-SNAPSHOT"

scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-Xlint",
"-language:_",
"-target:jvm-1.6",
"-encoding", "UTF-8"
)

libraryDependencies ++= Seq(
"biz.aQute" % "bndlib" % "1.50.0",
"org.specs2" %% "specs2" % "1.12.2" % "test",
"junit" % "junit" % "4.7" % "test"
"biz.aQute.bnd" % "bndlib" % "2.1.0",
"org.specs2" %% "specs2" % "1.14" % "test"
)

scalacOptions ++= Seq("-unchecked", "-deprecation")
sbtPlugin := true

publishTo <<= isSnapshot(if (_) Some(Classpaths.sbtPluginSnapshots) else Some(Classpaths.sbtPluginReleases))
publishTo := {
import Classpaths._
val repo = if (isSnapshot.value) sbtPluginSnapshots else sbtPluginReleases
Some(repo)
}

publishMavenStyle := false

releaseSettings

scalariformSettings

scriptedSettings

scriptedLaunchOpts += "-Xmx1024m"
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.12.2
sbt.version=0.13.0-Beta2
6 changes: 2 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.1.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.0.1")

libraryDependencies <+= (sbtVersion)("org.scala-sbt" % "scripted-plugin" % _)
libraryDependencies += ("org.scala-sbt" % "scripted-plugin" % sbtVersion.value)
5 changes: 5 additions & 0 deletions scalariform.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import scalariform.formatter.preferences.AlignSingleLineCaseStatements

scalariformSettings

ScalariformKeys.preferences <<= ScalariformKeys.preferences(_.setPreference(AlignSingleLineCaseStatements, true))
4 changes: 4 additions & 0 deletions scripted.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

scriptedSettings

scriptedLaunchOpts += "-Xmx1024m"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011 Typesafe Inc.
* Copyright 2011-2013 Typesafe Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,20 +14,17 @@
* limitations under the License.
*/

package com.typesafe.sbt
package com.typesafe.sbt.osgi

import aQute.lib.osgi.Builder
import aQute.bnd.osgi.Builder
import aQute.bnd.osgi.Constants._
import java.util.Properties
import sbt._
import sbt.Keys._
import aQute.lib.osgi.Constants

package object osgi {
private object Osgi {

def seqToStrOpt[A](seq: Seq[A])(f: A => String): Option[String] =
if (seq.isEmpty) None else Some(seq map f mkString ",")

private[osgi] def bundleTask(
def bundleTask(
headers: OsgiManifestHeaders,
additionalHeaders: Map[String, String],
fullClasspath: Seq[Attributed[File]],
Expand All @@ -39,10 +36,10 @@ package object osgi {
builder.setProperties(headersToProperties(headers, additionalHeaders))
//builder.setProperty(aQute.lib.osgi.Constants.INCLUDE_RESOURCE, "")
includeResourceProperty(resourceDirectories, embeddedJars) foreach (dirs =>
builder.setProperty(aQute.lib.osgi.Constants.INCLUDE_RESOURCE, dirs)
builder.setProperty(INCLUDE_RESOURCE, dirs)
)
bundleClasspathProperty(embeddedJars) foreach (jars =>
builder.setProperty(aQute.lib.osgi.Constants.BUNDLE_CLASSPATH, jars)
builder.setProperty(BUNDLE_CLASSPATH, jars)
)
val jar = builder.build
jar.write(artifactPath)
Expand All @@ -51,7 +48,6 @@ package object osgi {

def headersToProperties(headers: OsgiManifestHeaders, additionalHeaders: Map[String, String]): Properties = {
import headers._
import aQute.lib.osgi.Constants._
val properties = new Properties
properties.put(BUNDLE_SYMBOLICNAME, bundleSymbolicName)
properties.put(BUNDLE_VERSION, bundleVersion)
Expand All @@ -66,13 +62,16 @@ package object osgi {
properties
}

private[osgi] def includeResourceProperty(resourceDirectories: Seq[File], embeddedJars: Seq[File]) =
def seqToStrOpt[A](seq: Seq[A])(f: A => String): Option[String] =
if (seq.isEmpty) None else Some(seq map f mkString ",")

def includeResourceProperty(resourceDirectories: Seq[File], embeddedJars: Seq[File]) =
seqToStrOpt(resourceDirectories ++ embeddedJars)(_.getAbsolutePath)

private[osgi] def bundleClasspathProperty(embeddedJars: Seq[File]) =
def bundleClasspathProperty(embeddedJars: Seq[File]) =
seqToStrOpt(embeddedJars)(_.getName) map (".," + _)

private[osgi] def defaultBundleSymbolicName(organization: String, name: String): String = {
def defaultBundleSymbolicName(organization: String, name: String): String = {
val organizationParts = parts(organization)
val nameParts = parts(name)
val partsWithoutOverlap = (organizationParts.lastOption, nameParts.headOption) match {
Expand All @@ -82,7 +81,7 @@ package object osgi {
partsWithoutOverlap mkString "."
}

private[osgi] def id(s: String) = s
def id(s: String) = s

private def parts(s: String) = s split "[.-]" filterNot (_.isEmpty)
def parts(s: String) = s split "[.-]" filterNot (_.isEmpty)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011 Typesafe Inc.
* Copyright 2011-2013 Typesafe Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/typesafe/sbt/osgi/OsgiKeys.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011 Typesafe Inc.
* Copyright 2011-2013 Typesafe Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011 Typesafe Inc.
* Copyright 2011-2013 Typesafe Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/com/typesafe/sbt/osgi/SbtOsgi.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011 Typesafe Inc.
* Copyright 2011-2013 Typesafe Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,8 @@ import sbt.Keys._

object SbtOsgi extends Plugin {

type OsgiManifestHeaders = com.typesafe.sbt.osgi.OsgiManifestHeaders

val OsgiKeys = com.typesafe.sbt.osgi.OsgiKeys

def osgiSettings: Seq[Setting[_]] = defaultOsgiSettings ++ Seq(
Expand All @@ -38,7 +40,7 @@ object SbtOsgi extends Plugin {
artifactPath in (Compile, packageBin),
resourceDirectories in Compile,
embeddedJars
) map bundleTask,
) map Osgi.bundleTask,
manifestHeaders <<= (
bundleActivator,
bundleSymbolicName,
Expand All @@ -51,7 +53,7 @@ object SbtOsgi extends Plugin {
requireBundle
)(OsgiManifestHeaders),
bundleActivator := None,
bundleSymbolicName <<= (organization, name)(defaultBundleSymbolicName),
bundleSymbolicName <<= (organization, name)(Osgi.defaultBundleSymbolicName),
bundleVersion <<= version,
dynamicImportPackage := Nil,
exportPackage := Nil,
Expand All @@ -63,6 +65,4 @@ object SbtOsgi extends Plugin {
embeddedJars := Nil
)
}

type OsgiManifestHeaders = com.typesafe.sbt.osgi.OsgiManifestHeaders
}
2 changes: 0 additions & 2 deletions src/sbt-test/sbt-osgi/00-defaults/project/plugins.sbt

This file was deleted.

2 changes: 0 additions & 2 deletions src/sbt-test/sbt-osgi/01-contents/project/plugins.sbt

This file was deleted.

2 changes: 0 additions & 2 deletions src/sbt-test/sbt-osgi/02-includeresource/project/plugins.sbt

This file was deleted.

2 changes: 0 additions & 2 deletions src/sbt-test/sbt-osgi/03-arbitraryHeaders/project/plugins.sbt

This file was deleted.

2 changes: 0 additions & 2 deletions src/sbt-test/sbt-osgi/04-embeddedJars/project/plugins.sbt

This file was deleted.

File renamed without changes.
2 changes: 2 additions & 0 deletions src/sbt-test/sbt-osgi/test-00-defaults/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.6.0-SNAPSHOT")
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@

# Existence of JAR file
> osgi-bundle
$ exists target/scala-2.9.2/sbt-osgi-test_2.9.2-1.2.3.jar
$ exists target/scala-2.10/sbt-osgi-test_2.10-1.2.3.jar
File renamed without changes.
2 changes: 2 additions & 0 deletions src/sbt-test/sbt-osgi/test-01-contents/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.6.0-SNAPSHOT")
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ TaskKey[Unit]("verify-bundle") <<= OsgiKeys.bundle map { file =>
val lines = Source.fromInputStream(manifestIn).getLines().toList
val allLines = lines mkString newLine
val butWas = newLine + "But was:" + newLine + allLines
if (!((lines contains "Private-Package: .,com.typesafe.sbt.osgi.test.internal") || (lines contains "Private-Package: com.typesafe.sbt.osgi.test.internal,.")))
error("Expected 'Private-Package: .,com.typesafe.sbt.osgi.test.internal' in manifest!" + butWas)
// if (!((lines contains "Private-Package: .,com.typesafe.sbt.osgi.test.internal") || (lines contains "Private-Package: com.typesafe.sbt.osgi.test.internal,.")))
// error("Expected 'Private-Package: .,com.typesafe.sbt.osgi.test.internal' in manifest!" + butWas)
} catch {
case e: IOException => error("Expected to be able to read the manifest, but got exception!" + newLine + e)
} finally manifestIn.close()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.6.0-SNAPSHOT")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.6.0-SNAPSHOT")
Loading

0 comments on commit c7e8560

Please sign in to comment.