kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jun...@apache.org
Subject git commit: kafka-843; Re-add the release-zip sbt target; patched by Cosmin Lehene; reviewed by Jun Rao
Date Thu, 11 Apr 2013 18:01:35 GMT
Updated Branches:
  refs/heads/0.8 f9e36ca79 -> 158baf661


kafka-843; Re-add the release-zip sbt target; patched by Cosmin Lehene; reviewed by Jun Rao


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/158baf66
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/158baf66
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/158baf66

Branch: refs/heads/0.8
Commit: 158baf661c142d1ebeb96a817f5a121ca71360ac
Parents: f9e36ca
Author: Cosmin Lehene <clehene@adobe.com>
Authored: Thu Apr 11 11:01:11 2013 -0700
Committer: Jun Rao <junrao@gmail.com>
Committed: Thu Apr 11 11:01:11 2013 -0700

----------------------------------------------------------------------
 bin/kafka-run-class.sh |   11 +++++++++++
 project/Build.scala    |   38 ++++++++++++++++++++++++++++++++++++--
 sbt                    |    2 +-
 3 files changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/158baf66/bin/kafka-run-class.sh
----------------------------------------------------------------------
diff --git a/bin/kafka-run-class.sh b/bin/kafka-run-class.sh
index 8697963..978447d 100755
--- a/bin/kafka-run-class.sh
+++ b/bin/kafka-run-class.sh
@@ -35,6 +35,17 @@ do
   CLASSPATH=$CLASSPATH:$file
 done
 
+# classpath addition for release
+for file in $base_dir/libs/*.jar;
+do
+  CLASSPATH=$CLASSPATH:$file
+done
+
+for file in $base_dir/kafka*.jar;
+do
+  CLASSPATH=$CLASSPATH:$file
+done
+
 if [ -z "$KAFKA_JMX_OPTS" ]; then
   KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false
 -Dcom.sun.management.jmxremote.ssl=false "
 fi

http://git-wip-us.apache.org/repos/asf/kafka/blob/158baf66/project/Build.scala
----------------------------------------------------------------------
diff --git a/project/Build.scala b/project/Build.scala
index 3918579..11ccb75 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -17,17 +17,23 @@
 
 import sbt._
 import Keys._
+import Process._
 
 import scala.xml.{Node, Elem}
 import scala.xml.transform.{RewriteRule, RuleTransformer}
 
 object KafkaBuild extends Build {
+  val buildNumber = SettingKey[String]("build-number", "Build number defaults to $BUILD_NUMBER
environment variable")
+  val releaseName = SettingKey[String]("release-name", "the full name of this release")
   val commonSettings = Seq(
-    version := "0.8-SNAPSHOT",
     organization := "org.apache",
     scalacOptions ++= Seq("-deprecation", "-unchecked", "-g:none"),
     crossScalaVersions := Seq("2.8.0","2.8.2", "2.9.1", "2.9.2"),
     scalaVersion := "2.8.0",
+    buildNumber := System.getProperty("build.number", "SNAPSHOT"),
+    buildNumber <<= buildNumber { build => if (build == "") "SNAPSHOT" else build},
+    version <<= buildNumber  { build  => "0.8-" + build},
+    releaseName <<= (name, version, scalaVersion) {(name, version, scalaVersion) =>
name + "_" + scalaVersion + "-" + version},
     javacOptions ++= Seq("-Xlint:unchecked", "-source", "1.5"),
     parallelExecution in Test := false, // Prevent tests from overrunning each other
     libraryDependencies ++= Seq(
@@ -77,12 +83,40 @@ object KafkaBuild extends Build {
        </dependencies>
   )
 
+
   val runRat = TaskKey[Unit]("run-rat-task", "Runs Apache rat on Kafka")
   val runRatTask = runRat := {
     "bin/run-rat.sh" !
   }
 
-  lazy val kafka    = Project(id = "Kafka", base = file(".")).aggregate(core, examples, contrib,
perf).settings((commonSettings ++ runRatTask): _*)
+  val release = TaskKey[Unit]("release", "Creates a deployable release directory file with
dependencies, config, and scripts.")
+  val releaseTask = release <<= ( packageBin in (core, Compile), dependencyClasspath
in (core, Runtime), exportedProducts in Compile,
+    target, releaseName in core ) map { (packageBin, deps, products, target, releaseName)
=>
+      val jarFiles = deps.files.filter(f => !products.files.contains(f) && f.getName.endsWith(".jar"))
+      val destination = target / "RELEASE" / releaseName
+      IO.copyFile(packageBin, destination / packageBin.getName)
+      IO.copy(jarFiles.map { f => (f, destination / "libs" / f.getName) })
+      IO.copyDirectory(file("config"), destination / "config")
+      IO.copyDirectory(file("bin"), destination / "bin")
+      for {file <- (destination / "bin").listFiles} { file.setExecutable(true, true) }
+      IO.zip(Path.allSubpaths(target/"RELEASE"), target/"%s.zip".format(releaseName))
+  }
+
+  val releaseZip = TaskKey[Unit]("release-zip", "Creates a deployable zip file with dependencies,
config, and scripts.")
+  val releaseZipTask = releaseZip <<= (release, target, releaseName in core) map {
(release, target, releaseName) => 
+    IO.zip(Path.allSubpaths(target/"RELEASE"), target/ "RELEASE" / "%s.zip".format(releaseName))
+  }
+
+  val releaseTar = TaskKey[Unit]("release-tar", "Creates a deployable tar.gz file with dependencies,
config, and scripts.")
+  val releaseTarTask = releaseTar <<= ( release, target, releaseName in core) map {
(release, target, releaseName) =>
+    Process(Seq("tar", "czf", "%s.tar.gz".format(releaseName), releaseName), target / "RELEASE").!
match {
+        case 0 => ()
+        case n => sys.error("Failed to run native tar application!")
+      }
+  }
+
+  lazy val kafka    = Project(id = "Kafka", base = file(".")).aggregate(core, examples, contrib,
perf).settings((commonSettings ++
+    runRatTask ++ releaseTask ++ releaseZipTask ++ releaseTarTask): _*)
   lazy val core     = Project(id = "core", base = file("core")).settings(commonSettings:
_*)
   lazy val examples = Project(id = "java-examples", base = file("examples")).settings(commonSettings
:_*) dependsOn (core)
   lazy val perf     = Project(id = "perf", base = file("perf")).settings((Seq(name := "kafka-perf")
++ commonSettings):_*) dependsOn (core)

http://git-wip-us.apache.org/repos/asf/kafka/blob/158baf66/sbt
----------------------------------------------------------------------
diff --git a/sbt b/sbt
index 9ffb03b..944ebf8 100755
--- a/sbt
+++ b/sbt
@@ -13,4 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-java -Xmx1024M -XX:MaxPermSize=512m -jar `dirname $0`/lib/sbt-launch.jar "$@"
+java -Xmx1024M -XX:MaxPermSize=512m -Dbuild.number="$BUILD_NUMBER" -jar `dirname $0`/lib/sbt-launch.jar
"$@"


Mime
View raw message