Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
import clojure and standard java utils
- Loading branch information
Showing
5 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
numArgs=$# | ||
|
||
set -e -o pipefail | ||
|
||
function die() { | ||
MESG="${1:-Died}" | ||
echo "${MESG}" >&2 | ||
exit 1 | ||
} | ||
|
||
|
||
if [[ !$numArgs -gt 0 ]]; then | ||
die "Please supply a version number e.g. 0.0.1" | ||
fi | ||
|
||
group="de.mpg.shh" | ||
artifact="util" | ||
version=$1 | ||
|
||
lein clean | ||
lein deps | ||
lein jar | ||
lein pom | ||
|
||
test -f "target/${artifact}-${version}.jar" || die "Build failed: jar not found" | ||
|
||
lein localrepo install -p pom.xml target/${artifact}-${version}.jar ${group}/${artifact} ${version} | ||
|
||
# create sha1sums for the jar and pom | ||
group_path=$(echo "${group}" | tr "." "/") | ||
jar_path="${HOME}/.m2/repository/${group_path}/${artifact}/${version}/${artifact}-${version}.jar" | ||
jar_sum_path="${jar_path}.sha1" | ||
|
||
pom_path="${HOME}/.m2/repository/${group_path}/${artifact}/${version}/${artifact}-${version}.pom" | ||
pom_sum_path="${pom_path}.sha1" | ||
|
||
shasum ${jar_path} | cut -d ' ' -f 1 > ${jar_sum_path} | ||
shasum ${pom_path} | cut -d ' ' -f 1 > ${pom_sum_path} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(defproject de.mpg.shh/util "0.2.0" | ||
:description "Miscellaneous utilities for shh projects" | ||
:url "http://www.shh.mpg.de/" | ||
:license {:name "Eclipse Public License" | ||
:url "http://www.eclipse.org/legal/epl-v10.html"} | ||
:dependencies [[org.clojure/clojure "1.8.0"] | ||
[org.clojure/tools.logging "0.3.1"] | ||
[org.apache.logging.log4j/log4j-api "2.5"] | ||
[org.apache.logging.log4j/log4j-core "2.5"] | ||
[org.apache.logging.log4j/log4j-1.2-api "2.5"] | ||
[org.slf4j/slf4j-log4j12 "1.6.4"]] | ||
:source-paths ["src/main/clojure"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(ns de.mpg.shh.util.core) | ||
|
||
(defn not-nil? [maybe-nil] (not (nil? maybe-nil))) | ||
(defn not-empty? [maybe-empty] (not (empty? maybe-empty))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(ns de.mpg.shh.util.exceptions | ||
(:import [java.io StringWriter PrintWriter])) | ||
|
||
(defn stack-trace-to-string | ||
"Returns a string containing the output of .printStackTrace" | ||
[t] | ||
(let [sw (StringWriter.) | ||
pw (PrintWriter. sw) | ||
_ (.printStackTrace t pw)] | ||
(.toString sw))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns de.mpg.shh.util.file | ||
(:import [java.nio.file Files])) | ||
|
||
(defn file-to-byte-array | ||
"Converts a java.io.File to a byte[]" | ||
[file] | ||
(Files/readAllBytes (.toPath file))) |