From b114df6ec1167ab46e59533bad44ecfc9043db23 Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Thu, 9 May 2013 11:03:14 +0200 Subject: [PATCH 01/11] avoid writing version uselessly --- src/main/scala/ReleaseExtra.scala | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index 7bb0a5a..4ccc561 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -68,16 +68,26 @@ object ReleaseStateTransformations { lazy val setNextVersion: ReleaseStep = setVersion(_._2) private[sbtrelease] def setVersion(selectVersion: Versions => String): ReleaseStep = { st: State => val vs = st.get(versions).getOrElse(sys.error("No versions are set! Was this release part executed before inquireVersions?")) - val selected = selectVersion(vs) + val newVersion = selectVersion(vs) - st.log.info("Setting version to '%s'." format selected) + val currentVersion = Project.extract(st).get(version) + if (newVersion == currentVersion) { + st.log.info("No version update needed, version remains '%s'" format currentVersion) + st + } else { + st.log.info("Setting version to '%s'." format newVersion) - val versionString = "%sversion in ThisBuild := \"%s\"%s" format (lineSep, selected, lineSep) - IO.write(new File("version.sbt"), versionString) + writeVersionToFile(newVersion) + + reapply(Seq( + version in ThisBuild := newVersion + ), st) + } + } - reapply(Seq( - version in ThisBuild := selected - ), st) + private def writeVersionToFile(version: String) { + val versionString = "%sversion in ThisBuild := \"%s\"%s" format (lineSep, version, lineSep) + IO.write(new File("version.sbt"), versionString) } private def vcs(st: State): Vcs = { From 08ae1e0a48bb02374358801253cf111f5e33e166 Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Thu, 9 May 2013 12:48:48 +0200 Subject: [PATCH 02/11] logs version.sbt absolute path --- src/main/scala/ReleaseExtra.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index 4ccc561..9306cb5 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -77,17 +77,19 @@ object ReleaseStateTransformations { } else { st.log.info("Setting version to '%s'." format newVersion) - writeVersionToFile(newVersion) - + writeVersionToFile(newVersion, st) + reapply(Seq( version in ThisBuild := newVersion ), st) } } - private def writeVersionToFile(version: String) { + private def writeVersionToFile(version: String, st: State) { val versionString = "%sversion in ThisBuild := \"%s\"%s" format (lineSep, version, lineSep) - IO.write(new File("version.sbt"), versionString) + val file = new File("version.sbt") + st.log.info("Updating " + file.getAbsolutePath) + IO.write(file, versionString) } private def vcs(st: State): Vcs = { From ef102eaa531dee587d47a9e585b0f9455670c27c Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Thu, 9 May 2013 13:38:26 +0200 Subject: [PATCH 03/11] interactive commit --- src/main/scala/ReleaseExtra.scala | 18 ++++++++++++++++-- src/main/scala/ReleasePlugin.scala | 1 + src/main/scala/Vcs.scala | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index 9306cb5..24b50fe 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -70,7 +70,7 @@ object ReleaseStateTransformations { val vs = st.get(versions).getOrElse(sys.error("No versions are set! Was this release part executed before inquireVersions?")) val newVersion = selectVersion(vs) - val currentVersion = Project.extract(st).get(version) + val currentVersion = st.extract.get(version) if (newVersion == currentVersion) { st.log.info("No version update needed, version remains '%s'" format currentVersion) st @@ -99,7 +99,21 @@ object ReleaseStateTransformations { private[sbtrelease] lazy val initialVcsChecks = { st: State => val status = (vcs(st).status !!).trim if (status.nonEmpty) { - sys.error("Aborting release. Working directory is dirty.") + if( st.get(interactiveCommit).getOrElse(true) ) { + st.log.info("Working directory is dirty:") + st.log.info("\n\t" + status.replaceAll("\\n","\n\t")) + + SimpleReader.readLine("\nEnter a message to add everything and commit: ") match { + case Some(message) => + vcs(st).addAll !! st.log + vcs(st).commit(message) !! st.log + + case None => + sys.error("No message entered. Aborting release!") + } + } else { + sys.error("Aborting release. Working directory is dirty.") + } } st.log.info("Starting release process off commit: " + vcs(st).currentHash) diff --git a/src/main/scala/ReleasePlugin.scala b/src/main/scala/ReleasePlugin.scala index b220b46..783f9d1 100644 --- a/src/main/scala/ReleasePlugin.scala +++ b/src/main/scala/ReleasePlugin.scala @@ -18,6 +18,7 @@ object ReleasePlugin extends Plugin { lazy val versions = AttributeKey[Versions]("release-versions") lazy val useDefaults = AttributeKey[Boolean]("release-use-defaults") + lazy val interactiveCommit = AttributeKey[Boolean]("release-interactive-commit", "If the repository is dirty, allow the user to commit within the SBT shell") lazy val skipTests = AttributeKey[Boolean]("release-skip-tests") lazy val crossBuild = AttributeKey[Boolean]("release-cross-build") diff --git a/src/main/scala/Vcs.scala b/src/main/scala/Vcs.scala index a384324..d709374 100644 --- a/src/main/scala/Vcs.scala +++ b/src/main/scala/Vcs.scala @@ -10,6 +10,7 @@ trait Vcs { def status: ProcessBuilder def currentHash: String def add(files: String*): ProcessBuilder + def addAll: ProcessBuilder def commit(message: String): ProcessBuilder def existsTag(name: String): Boolean def checkRemote(remote: String): ProcessBuilder @@ -60,6 +61,8 @@ object Mercurial extends Vcs with GitLike { protected val markerDirectory = ".hg" + def addAll = cmd("add") + def status = cmd("status") def currentHash = (cmd("identify", "-i") !!) trim @@ -93,6 +96,8 @@ object Git extends Vcs with GitLike { private lazy val trackingRemoteCmd: ProcessBuilder = cmd("config", "branch.%s.remote" format currentBranch) def trackingRemote: String = (trackingRemoteCmd !!) trim + def addAll = cmd("add","-A",".") + def hasUpstream = trackingRemoteCmd ! devnull == 0 && trackingBranchCmd ! devnull == 0 def currentBranch = (cmd("symbolic-ref", "HEAD") !!).trim.stripPrefix("refs/heads/") From 24bc40522d6a3a78c39f573ac6d37855d8f8ecbb Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Thu, 9 May 2013 14:17:32 +0200 Subject: [PATCH 04/11] make sure versions are homogeneous; prevent old version.sbt file to override new version set in ThisBuild. --- src/main/scala/ReleaseExtra.scala | 32 +++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index 24b50fe..566ced6 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -33,8 +33,23 @@ object ReleaseStateTransformations { newSt } - - lazy val inquireVersions: ReleaseStep = { st: State => + lazy val inquireVersions = ReleaseStep(inquireVersionsAction, homogeneousVersionsCheck) + private lazy val homogeneousVersionsCheck = { st: State => + // as we set one global version for all projects (version in ThisBuild) + // we have to make sure versions are homogeneous across aggregated projects + // so that we don't publish aggregates with incorrect versions (for instance a SNAPSHOT) + val extracted = st.extract + val rootVersion = extracted.get(version) + for(aggregate <- extracted.currentProject.aggregate) { + val aggregateVersion = extracted.get(version.in(aggregate)) + if( aggregateVersion != rootVersion ) { + sys.error("Aggregated project '%s' has version '%s' which differs from its root : '%s'" format (aggregate.project, aggregateVersion, rootVersion)) + sys.error("You probably have multiple 'version.sbt' files. sbt-release only support one identical version for all aggregated projects.") + } + } + st + } + private lazy val inquireVersionsAction = { st: State => val extracted = Project.extract(st) val useDefs = st.get(useDefaults).getOrElse(false) @@ -70,6 +85,10 @@ object ReleaseStateTransformations { val vs = st.get(versions).getOrElse(sys.error("No versions are set! Was this release part executed before inquireVersions?")) val newVersion = selectVersion(vs) + // TODO check versions are homogeneous + val extracted = st.extract + st.extract.currentProject.aggregate.foreach( p => println("version for " + p + " : " + extracted.get(version.in(p)))) + val currentVersion = st.extract.get(version) if (newVersion == currentVersion) { st.log.info("No version update needed, version remains '%s'" format currentVersion) @@ -79,9 +98,14 @@ object ReleaseStateTransformations { writeVersionToFile(newVersion, st) - reapply(Seq( - version in ThisBuild := newVersion + val newSt = reapply(Seq( + version in ThisBuild := newVersion, + version := newVersion // in case the previous version.sbt file had its version defined this way + // it would override 'version in ThisBuild' so we could be releasing a + // SNAPSHOT instead ), st) + + homogeneousVersionsCheck(newSt) } } From 5aa1e38be97d4a205a8c389013590d6b29d2b7b2 Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Thu, 9 May 2013 14:31:41 +0200 Subject: [PATCH 05/11] cleanup --- project/build.properties | 2 +- src/main/scala/ReleaseExtra.scala | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/project/build.properties b/project/build.properties index d428711..66ad72c 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.11.3 +sbt.version=0.12.2 diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index 566ced6..803158d 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -85,10 +85,6 @@ object ReleaseStateTransformations { val vs = st.get(versions).getOrElse(sys.error("No versions are set! Was this release part executed before inquireVersions?")) val newVersion = selectVersion(vs) - // TODO check versions are homogeneous - val extracted = st.extract - st.extract.currentProject.aggregate.foreach( p => println("version for " + p + " : " + extracted.get(version.in(p)))) - val currentVersion = st.extract.get(version) if (newVersion == currentVersion) { st.log.info("No version update needed, version remains '%s'" format currentVersion) From 6bb6de4be9b676fc534570f14499c81b099a302f Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Tue, 14 May 2013 11:05:11 +0200 Subject: [PATCH 06/11] global release switch --- build.sbt | 14 +++----- src/main/scala/ReleaseExtra.scala | 54 ++++++++++++++++++++---------- src/main/scala/ReleasePlugin.scala | 10 +++++- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/build.sbt b/build.sbt index 0dbe9d0..b2b8607 100644 --- a/build.sbt +++ b/build.sbt @@ -2,19 +2,13 @@ organization := "com.github.gseitz" name := "sbt-release" -version := "0.8-SNAPSHOT" +version := "0.8-BBSNAPSHOT" unmanagedSourceDirectories in Compile <+= (sbtVersion, sourceDirectory in Compile) ((sv, sd) => new File(sd, "scala-sbt-" + sv)) sbtPlugin := true -publishTo <<= (version) { version: String => - val scalasbt = "http://scalasbt.artifactoryonline.com/scalasbt/" - val (name, url) = if (version.contains("-SNAPSHOT")) - ("sbt-plugin-snapshots", scalasbt+"sbt-plugin-snapshots") - else - ("sbt-plugin-releases", scalasbt+"sbt-plugin-releases") - Some(Resolver.url(name, new URL(url))(Resolver.ivyStylePatterns)) -} -publishMavenStyle := false +publishTo := Some("backuity" at "http://dev.backuity.com:8081/nexus/content/repositories/releases/") + +credentials += Credentials("Sonatype Nexus Repository Manager", "dev.backuity.com", "developer", "b@ckuit1") diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index 803158d..caa2c93 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -35,16 +35,24 @@ object ReleaseStateTransformations { lazy val inquireVersions = ReleaseStep(inquireVersionsAction, homogeneousVersionsCheck) private lazy val homogeneousVersionsCheck = { st: State => - // as we set one global version for all projects (version in ThisBuild) - // we have to make sure versions are homogeneous across aggregated projects - // so that we don't publish aggregates with incorrect versions (for instance a SNAPSHOT) val extracted = st.extract - val rootVersion = extracted.get(version) - for(aggregate <- extracted.currentProject.aggregate) { - val aggregateVersion = extracted.get(version.in(aggregate)) - if( aggregateVersion != rootVersion ) { - sys.error("Aggregated project '%s' has version '%s' which differs from its root : '%s'" format (aggregate.project, aggregateVersion, rootVersion)) - sys.error("You probably have multiple 'version.sbt' files. sbt-release only support one identical version for all aggregated projects.") + + if( st.get(globalRelease) ) { + // as we set one global version for all projects (version in ThisBuild) + // we have to make sure versions are homogeneous across aggregated projects + // so that we don't publish aggregates with incorrect versions (for instance a SNAPSHOT) + val rootVersion = extracted.get(version) + for(aggregate <- extracted.currentProject.aggregate) { + val aggregateVersion = extracted.get(version.in(aggregate)) + if( aggregateVersion != rootVersion ) { + sys.error("Aggregated project '%s' has version '%s' which differs from its root : '%s'" format (aggregate.project, aggregateVersion, rootVersion)) + sys.error("You probably have multiple 'version.sbt' files. sbt-release only support one identical version for all aggregated projects.") + } + } + } else { + // make sure we have no aggregated projects + if( !extracted.currentProject.aggregate.isEmpty ) { + sys.error("Non global release cannot work on aggregated projects.") } } st @@ -94,20 +102,27 @@ object ReleaseStateTransformations { writeVersionToFile(newVersion, st) - val newSt = reapply(Seq( - version in ThisBuild := newVersion, - version := newVersion // in case the previous version.sbt file had its version defined this way - // it would override 'version in ThisBuild' so we could be releasing a - // SNAPSHOT instead - ), st) + // ideally we'd like to reload the project with the updated file... + + val newVersionSettings = if( st.get(globalRelease) ) { + Seq(version in ThisBuild := newVersion) + } else { + Nil + } ++ Seq(version := newVersion) // always set version scoped to the current project as it precedes version scoped to ThisBuild (see below) + // + // under global release, if the previous version.sbt file had its version defined as `version := "xxx"` + // it would override 'version in ThisBuild' so we could be releasing a SNAPSHOT instead + + val newSt = reapply(newVersionSettings, st) homogeneousVersionsCheck(newSt) } } private def writeVersionToFile(version: String, st: State) { - val versionString = "%sversion in ThisBuild := \"%s\"%s" format (lineSep, version, lineSep) - val file = new File("version.sbt") + val scope = if( st.get(globalRelease) ) "in ThisBuild" else "" // scope to the current project + val versionString = "%sversion %s := \"%s\"%s" format (lineSep, scope, version, lineSep) + val file = new File(st.extract.get(baseDirectory), "version.sbt") st.log.info("Updating " + file.getAbsolutePath) IO.write(file, versionString) } @@ -119,7 +134,7 @@ object ReleaseStateTransformations { private[sbtrelease] lazy val initialVcsChecks = { st: State => val status = (vcs(st).status !!).trim if (status.nonEmpty) { - if( st.get(interactiveCommit).getOrElse(true) ) { + if( st.get(interactiveCommit) ) { st.log.info("Working directory is dirty:") st.log.info("\n\t" + status.replaceAll("\\n","\n\t")) @@ -344,10 +359,13 @@ object ExtraReleaseCommands { object Utilities { + val lineSep = sys.props.get("line.separator").getOrElse(sys.error("No line separator? Really?")) class StateW(st: State) { def extract = Project.extract(st) + def get[T](a: AttributeKey[T]) : Option[T] = st.attributes.get(a) + def get[T](s: SettingKey[T]) : T = extract.get(s) } implicit def stateW(st: State): StateW = new StateW(st) diff --git a/src/main/scala/ReleasePlugin.scala b/src/main/scala/ReleasePlugin.scala index 783f9d1..60237d2 100644 --- a/src/main/scala/ReleasePlugin.scala +++ b/src/main/scala/ReleasePlugin.scala @@ -14,11 +14,16 @@ object ReleasePlugin extends Plugin { lazy val tagComment = TaskKey[String]("release-tag-comment") lazy val commitMessage = TaskKey[String]("release-commit-message") + // a non-global release will generate version.sbt file containing a version scoped to the current project, not to the build + lazy val globalRelease = SettingKey[Boolean]("global-release", "Release the current project and all its aggregated projects as one global project under " + + "a common version (i.e a version scoped to the build), otherwise release only the current project allowing a different version scheme than its parent " + + "(i.e a version scoped to the project only)") + lazy val interactiveCommit = SettingKey[Boolean]("release-interactive-commit", "If the repository is dirty, allow the user to commit within the SBT shell") + lazy val versionControlSystem = SettingKey[Option[Vcs]]("release-vcs") lazy val versions = AttributeKey[Versions]("release-versions") lazy val useDefaults = AttributeKey[Boolean]("release-use-defaults") - lazy val interactiveCommit = AttributeKey[Boolean]("release-interactive-commit", "If the repository is dirty, allow the user to commit within the SBT shell") lazy val skipTests = AttributeKey[Boolean]("release-skip-tests") lazy val crossBuild = AttributeKey[Boolean]("release-cross-build") @@ -59,6 +64,9 @@ object ReleasePlugin extends Plugin { snapshots }, + interactiveCommit := true, + globalRelease := true, + releaseVersion := { ver => Version(ver).map(_.withoutQualifier.string).getOrElse(versionFormatError) }, nextVersion := { ver => Version(ver).map(_.bumpMinor.asSnapshot.string).getOrElse(versionFormatError) }, From c91a2f1749602f936ddf2b318a9a9fad7285e286 Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Tue, 14 May 2013 11:07:55 +0200 Subject: [PATCH 07/11] tag prefix --- src/main/scala/ReleasePlugin.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/scala/ReleasePlugin.scala b/src/main/scala/ReleasePlugin.scala index 60237d2..8d096c4 100644 --- a/src/main/scala/ReleasePlugin.scala +++ b/src/main/scala/ReleasePlugin.scala @@ -10,6 +10,7 @@ object ReleasePlugin extends Plugin { lazy val releaseProcess = SettingKey[Seq[ReleaseStep]]("release-process") lazy val releaseVersion = SettingKey[String => String]("release-release-version") lazy val nextVersion = SettingKey[String => String]("release-next-version") + lazy val tagPrefix = SettingKey[String]("tag-prefix", "Allow to prefix tag-name, tag-comment and commit-message at once") lazy val tagName = TaskKey[String]("release-tag-name") lazy val tagComment = TaskKey[String]("release-tag-comment") lazy val commitMessage = TaskKey[String]("release-commit-message") @@ -70,9 +71,10 @@ object ReleasePlugin extends Plugin { releaseVersion := { ver => Version(ver).map(_.withoutQualifier.string).getOrElse(versionFormatError) }, nextVersion := { ver => Version(ver).map(_.bumpMinor.asSnapshot.string).getOrElse(versionFormatError) }, - tagName <<= (version in ThisBuild) map (v => "v" + v), - tagComment <<= (version in ThisBuild) map (v => "Releasing %s" format v), - commitMessage <<= (version in ThisBuild) map (v => "Setting version to %s" format v), + tagPrefix := "", + tagName <<= (version in ThisBuild, tagPrefix) map {(v,pref) => pref + "v" + v}, + tagComment <<= (version in ThisBuild, tagPrefix) map ((v,pref) => "Releasing %s%s" format (pref,v)), + commitMessage <<= (version in ThisBuild, tagPrefix) map ((v,pref) => "Setting version to %s%s" format (pref,v)), versionControlSystem <<= (baseDirectory)(Vcs.detect(_)), From 69e807e736e6368fad48bdf60bca7180e65b3665 Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Tue, 14 May 2013 11:29:32 +0200 Subject: [PATCH 08/11] fixed incorrect version in tagName, tagComment and commitMessage --- src/main/scala/ReleasePlugin.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/ReleasePlugin.scala b/src/main/scala/ReleasePlugin.scala index 8d096c4..2953d75 100644 --- a/src/main/scala/ReleasePlugin.scala +++ b/src/main/scala/ReleasePlugin.scala @@ -72,9 +72,9 @@ object ReleasePlugin extends Plugin { nextVersion := { ver => Version(ver).map(_.bumpMinor.asSnapshot.string).getOrElse(versionFormatError) }, tagPrefix := "", - tagName <<= (version in ThisBuild, tagPrefix) map {(v,pref) => pref + "v" + v}, - tagComment <<= (version in ThisBuild, tagPrefix) map ((v,pref) => "Releasing %s%s" format (pref,v)), - commitMessage <<= (version in ThisBuild, tagPrefix) map ((v,pref) => "Setting version to %s%s" format (pref,v)), + tagName <<= (version, tagPrefix) map {(v,pref) => pref + "v" + v}, + tagComment <<= (version, tagPrefix) map ((v,pref) => "Releasing %s%s" format (pref,v)), + commitMessage <<= (version, tagPrefix) map ((v,pref) => "Setting version to %s%s" format (pref,v)), versionControlSystem <<= (baseDirectory)(Vcs.detect(_)), From a57aa73e2b3aa9dc664ae9ba328b65aeb2605c2a Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Tue, 14 May 2013 12:09:54 +0200 Subject: [PATCH 09/11] fix commit incorrect version file --- src/main/scala/ReleaseExtra.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index caa2c93..9db9c34 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -122,11 +122,16 @@ object ReleaseStateTransformations { private def writeVersionToFile(version: String, st: State) { val scope = if( st.get(globalRelease) ) "in ThisBuild" else "" // scope to the current project val versionString = "%sversion %s := \"%s\"%s" format (lineSep, scope, version, lineSep) - val file = new File(st.extract.get(baseDirectory), "version.sbt") + val file = versionFile(st) st.log.info("Updating " + file.getAbsolutePath) IO.write(file, versionString) } + + private def versionFile(st: State): File = { + new File(st.extract.get(baseDirectory), "version.sbt") + } + private def vcs(st: State): Vcs = { st.extract.get(versionControlSystem).getOrElse(sys.error("Aborting release. Working directory is not a repository of a recognized VCS.")) } @@ -167,7 +172,7 @@ object ReleaseStateTransformations { lazy val commitNextVersion = ReleaseStep(commitVersion) private[sbtrelease] def commitVersion = { st: State => - vcs(st).add("version.sbt") !! st.log + vcs(st).add(versionFile(st).getAbsolutePath) !! st.log val status = (vcs(st).status !!) trim val newState = if (status.nonEmpty) { @@ -189,7 +194,7 @@ object ReleaseStateTransformations { if (vcs(st).existsTag(tag)) { defaultChoice orElse SimpleReader.readLine("Tag [%s] exists! Overwrite, keep or abort or enter a new tag (o/k/a)? [a] " format tag) match { case Some("" | "a" | "A") => - sys.error("Aborting release!") + sys.error("Tag [%s] already exist. Aborting release!") case Some("k" | "K") => st.log.warn("The current tag [%s] does not point to the commit for this release!" format tag) From bd5919fb6ad8474938a67f9a28be8075c85aa832 Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Thu, 16 May 2013 15:20:53 +0200 Subject: [PATCH 10/11] added missing tag in error message --- src/main/scala/ReleaseExtra.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index 9db9c34..dad7554 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -194,7 +194,7 @@ object ReleaseStateTransformations { if (vcs(st).existsTag(tag)) { defaultChoice orElse SimpleReader.readLine("Tag [%s] exists! Overwrite, keep or abort or enter a new tag (o/k/a)? [a] " format tag) match { case Some("" | "a" | "A") => - sys.error("Tag [%s] already exist. Aborting release!") + sys.error("Tag [%s] already exist. Aborting release!" format tag) case Some("k" | "K") => st.log.warn("The current tag [%s] does not point to the commit for this release!" format tag) From b94f6e2d0ad55f631244b1c2e741897f164e9b72 Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Wed, 30 Oct 2013 18:31:11 +0100 Subject: [PATCH 11/11] added sbt 0.13 compat --- build.sbt | 7 +++-- project/build.properties | 2 +- project/plugins.sbt | 1 + .../SbtCompat.scala | 0 src/main/scala-sbt-0.13/SbtCompat.scala | 31 +++++++++++++++++++ src/main/scala/ReleaseExtra.scala | 1 - 6 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 project/plugins.sbt rename src/main/{scala-sbt-0.12.2 => scala-sbt-0.12}/SbtCompat.scala (100%) create mode 100644 src/main/scala-sbt-0.13/SbtCompat.scala diff --git a/build.sbt b/build.sbt index b2b8607..d103cd0 100644 --- a/build.sbt +++ b/build.sbt @@ -4,11 +4,12 @@ name := "sbt-release" version := "0.8-BBSNAPSHOT" -unmanagedSourceDirectories in Compile <+= (sbtVersion, sourceDirectory in Compile) ((sv, sd) => new File(sd, "scala-sbt-" + sv)) - sbtPlugin := true - publishTo := Some("backuity" at "http://dev.backuity.com:8081/nexus/content/repositories/releases/") credentials += Credentials("Sonatype Nexus Repository Manager", "dev.backuity.com", "developer", "b@ckuit1") + +crossBuildingSettings + +CrossBuilding.crossSbtVersions := Seq("0.11.3", "0.12", "0.13") diff --git a/project/build.properties b/project/build.properties index 66ad72c..5e96e96 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.12.2 +sbt.version=0.12.4 diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 0000000..cb2afac --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("net.virtual-void" % "sbt-cross-building" % "0.8.0") \ No newline at end of file diff --git a/src/main/scala-sbt-0.12.2/SbtCompat.scala b/src/main/scala-sbt-0.12/SbtCompat.scala similarity index 100% rename from src/main/scala-sbt-0.12.2/SbtCompat.scala rename to src/main/scala-sbt-0.12/SbtCompat.scala diff --git a/src/main/scala-sbt-0.13/SbtCompat.scala b/src/main/scala-sbt-0.13/SbtCompat.scala new file mode 100644 index 0000000..57b6288 --- /dev/null +++ b/src/main/scala-sbt-0.13/SbtCompat.scala @@ -0,0 +1,31 @@ +package sbtrelease + +import sbt._ +import sbt.Aggregation.KeyValue +import sbt.std.Transform.DummyTaskMap +import Utilities._ + +object SbtCompat { + val EmptySetting = List.empty[String] + + def runTaskAggregated[T](taskKey: TaskKey[T], state: State) = { + import EvaluateTask._ + val extra = DummyTaskMap(Nil) + val extracted = state.extract + val config = extractedConfig(extracted, extracted.structure) + + val rkey = Utilities.resolve(taskKey.scopedKey, extracted) + val keys = Aggregation.aggregate(rkey, ScopeMask(), extracted.structure.extra) + val tasks = Act.keyValues(extracted.structure)(keys) + val toRun = tasks map { case KeyValue(k,t) => t.map(v => KeyValue(k,v)) } join; + val roots = tasks map { case KeyValue(k,_) => k } + + + val (newS, result) = withStreams(extracted.structure, state){ str => + val transform = nodeView(state, str, roots, extra) + runTask(toRun, state,str, extracted.structure.index.triggers, config)(transform) + } + (newS, result) + } + +} diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index dad7554..1e343c3 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -1,6 +1,5 @@ package sbtrelease -import java.io.File import sbt._ import Keys._ import annotation.tailrec