Skip to content
This repository has been archived by the owner on Mar 14, 2019. It is now read-only.

Commit

Permalink
Fixed #89.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongl committed Dec 12, 2012
1 parent 68c1553 commit f4508a6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 139 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,28 @@ It's inspiration came from [BTrace](http://kenai.com/projects/btrace), but more
## Pre-requirement

- JDK 6 +
- [sbt](https://github.com/harrah/xsbt)

## One-command install (On Linux or MacOSX)
## Build from code

> curl -Lk https://raw.github.com/zhongl/HouseMD/master/bin/install | bash
$ git clone https://github.com/zhongl/HouseMD.git housemd
$ cd housemd
$ sbt proguard

- Windows are not supported yet.
A runnable jar named `housemd_x.x.x-x.x.x.min.jar` should be generated blow `target/scala-x.x.x/`

## Normal install
> Caution: Windows are not supported yet.
- Click [here](https://github.com/zhongl/HouseMD/downloads) download lastest version executable jar
- Run it as:
## Run it

> java -Xbootclasspath/a:$JAVA_HOME/lib/tools.jar -jar housemd-assembly-x.x.x.jar
$ java -Xbootclasspath/a:$JAVA_HOME/lib/tools.jar -jar housemd_x.x.x-x.x.x.min.jar [OPTIONS] <pid>

> Caution: In Mac OSX, the `-Xbootclasspath` is no needed.
> You can created launch script as a shortcut.
# How to use

First all, type:
First all, suppose you created launch script file named `housemd`, type:

> ./housemd -h

Expand Down
26 changes: 0 additions & 26 deletions bin/housemd

This file was deleted.

26 changes: 0 additions & 26 deletions bin/install

This file was deleted.

82 changes: 21 additions & 61 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,20 @@
* limitations under the License.
*/

import java.security.MessageDigest
import org.eclipse.egit.github.core.{Download, RepositoryId}
import sbt._
import sbt.Keys._
import java.io.File
import org.eclipse.egit.github.core.client._
import org.eclipse.egit.github.core.service._
import ProguardPlugin._

object Build extends sbt.Build {

import Dependencies._
import Unmanaged._

val VERSION = "0.2.4"
val javaHome = sys.props("java.home").replace("/jre", "")

lazy val upload = TaskKey[Unit]("upload", "upload assembly jar to github downloads")
val VERSION = "0.2.4"
val javaHome = sys.props("java.home").replace("/jre", "")

lazy val proguard = proguardSettings ++ Seq(
proguardOptions := Seq(
proguardOptions := Seq(
"-keepclasseswithmembers public class * { public static void main(java.lang.String[]); }",
"-keep class * implements org.xml.sax.EntityResolver",
"-keep class com.github.zhongl.housemd.** { *;} ",
Expand All @@ -58,7 +51,9 @@ object Build extends sbt.Build {
scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference tail;
scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference cleanMe;
}"""),
proguardLibraryJars := {(jdkJarPath: PathFinder).get}
proguardLibraryJars := {
(jdkJarPath: PathFinder).get
}
)

private def jdkJarPath = {
Expand All @@ -78,15 +73,14 @@ object Build extends sbt.Build {
id = "housemd",
base = file("."),
settings = Defaults.defaultSettings ++ classpathSettings ++ proguard ++ Seq(
name := "housemd",
organization := "com.github.zhongl",
version := VERSION,
scalaVersion := "2.9.2",
scalacOptions ++= Seq("-unchecked", "-deprecation"),
resolvers += "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository",
libraryDependencies := compileLibs ++ testLibs,
upload <<= minJarPath map { file => uploadToGithubWith(file) },
packageOptions += Package.ManifestAttributes(
name := "housemd",
organization := "com.github.zhongl",
version := VERSION,
scalaVersion := "2.9.2",
scalacOptions ++= Seq("-unchecked", "-deprecation"),
resolvers += "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository",
libraryDependencies := compileLibs ++ testLibs,
packageOptions += Package.ManifestAttributes(
("Main-Class", "com.github.zhongl.housemd.house.House"),
("Agent-Class", "com.github.zhongl.housemd.duck.Duck"),
("Can-Retransform-Classes", "true"),
Expand All @@ -97,56 +91,22 @@ object Build extends sbt.Build {
)
)

private def uploadToGithubWith(file: File) {
import collection.JavaConversions._

val username = readInput("Please input credentials username: ")
val password = readHidden("Please input credentials password: ")

val client = new GitHubClient()
client.setCredentials(username, password)

val service = new DownloadService(client)
val id = new RepositoryId("zhongl", "HouseMD")
service.getDownloads(id) find {_.getName == file.getName} foreach { d => service.deleteDownload(id, d.getId) } // delete if existed
service.createDownload(id, aDownloadOf(file), file)
}

private def sha1sum(file: File) = {
val sha1 = MessageDigest.getInstance("SHA-1")
val digest = sha1.digest(IO.readBytes(file))
("" /: digest)(_ + "%02x".format(_)) + " " + file.getName
}

private def aDownloadOf(file: File) = {
val download = new Download()
download.setName(file.getName)
download.setContentType("application/java-archive")
download.setSize(file.length())
download.setDescription(sha1sum(file))
download
}

private def readInput(msg: String) = SimpleReader.readLine(msg) getOrElse sys.error("Failed to grab input")

private def readHidden(msg: String) = SimpleReader.readLine(msg, Some('*')) getOrElse sys.error("Failed to grab input")

object Dependencies {
lazy val testLibs = Seq(
"org.mockito" % "mockito-all" % "1.9.0" % "test",
"org.scalatest" %% "scalatest" % "1.7.2" % "test"
"org.mockito" % "mockito-all" % "1.9.0" % "test",
"org.scalatest" %% "scalatest" % "1.7.2" % "test"
)

lazy val compileLibs = Seq(
"asm" % "asm" % "3.3.1",
"asm" % "asm-commons" % "3.3.1",
"com.github.zhongl" %% "yascli" % "0.1.0",
"org.scala-lang" % "scala-library" % "2.9.2"
"asm" % "asm" % "3.3.1",
"asm" % "asm-commons" % "3.3.1",
"com.github.zhongl" %% "yascli" % "0.1.0",
"org.scala-lang" % "scala-library" % "2.9.2"
)
}

object Unmanaged {
lazy val toolsFile = file(javaHome + "/lib/tools.jar")
lazy val toolsFile = file(javaHome + "/lib/tools.jar")
lazy val classpathSettings =
if (sys.props("os.name").contains("Linux")) Seq(
unmanagedClasspath in Compile += Attributed.blank(toolsFile),
Expand Down
4 changes: 0 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ resolvers += Resolver.url("sbt-plugin-releases",

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

libraryDependencies ++= Seq(
"org.eclipse.mylyn.github" % "org.eclipse.egit.github.core" % "1.2.1-SNAPSHOT"
)

libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-proguard-plugin" % (v+"-0.1.1"))
14 changes: 0 additions & 14 deletions sbt

This file was deleted.

0 comments on commit f4508a6

Please sign in to comment.