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

Commit

Permalink
switch to using github for releases so we don't anger clojars
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjudd committed Aug 30, 2010
1 parent 285dfb3 commit a0107b2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,4 +7,5 @@ gem/
lib/
classes/
build/
releases/
.*
29 changes: 8 additions & 21 deletions bin/cake
Expand Up @@ -2,7 +2,6 @@
# Save your fork, there's cake!"
require 'find'
require 'open-uri'
require 'rexml/document'
require 'socket'
require 'timeout'
require 'fileutils'
Expand Down Expand Up @@ -244,12 +243,12 @@ def download(url, path)
end

def get_cake(version, dest = nil, opts = {})
jar = version =~ /(.*)-SNAPSHOT/ ? "cake-#{$1}-#{snapshot(version)}.jar" : "cake-#{version}.jar"
jar = "cake-#{version}.jar"
repo = File.expand_path("~/.m2/repository/cake/cake/#{version}")
path = "#{repo}/#{jar}"

if not File.exists?(path)
url = "#{$repo}/#{version}/#{jar}"
url = "#{$repo}/#{jar}"
log(:deps, "fetching cake libraries. this may take a moment...") unless @logged; @logged = true
FileUtils.makedirs(repo)
download(url, path)
Expand All @@ -268,24 +267,11 @@ rescue OpenURI::HTTPError => e
end

def current_version
version = open("#{$repo}/maven-metadata.xml") do |file|
doc = REXML::Document.new file
doc.elements['metadata'].elements['versioning'].elements['versions'].elements.to_a('version').last.get_text.to_s
end
log(:deps, "most recent clojars version is #{version}") if debug?
version = open("#{$repo}/version").gets
log(:deps, "most recent standalone version is #{version}") if debug?
version
end

def snapshot(version)
open("#{$repo}/#{version}/maven-metadata.xml") do |file|
doc = REXML::Document.new file
snapshot = doc.elements['metadata'].elements['versioning'].elements['snapshot'].elements
timestamp = snapshot['timestamp'].get_text
build_num = snapshot['buildNumber'].get_text
"#{timestamp}-#{build_num}"
end
end

def extract(jar, file, dest = File.dirname(jar))
if not File.exists?("#{dest}/#{file}")
log(:deps, "extracting #{file} from #{jar}") if verbose?
Expand Down Expand Up @@ -670,9 +656,10 @@ private
output = `stty -echo 2>&1`
log($command, output) if verbose?
echo_off = $?.exitstatus == 0
prompt << " (WARNING, input will be visible on console!)" unless echo_off
prompt << ' (WARNING, input will be visible on console!)' unless echo_off
prompt << ':'
end
input = Readline.readline(prompt + ": ") || ''
input = Readline.readline(prompt + ' ') || ''
input + "\n"
ensure
if echo_off
Expand Down Expand Up @@ -718,7 +705,7 @@ $script = File.expand_path($opts[:run].first) if $opts[:run]
$pwd = Dir.getwd
$bakedir = project_dir($pwd)
$cakedir = File.dirname(File.dirname(readlink(__FILE__)))
$repo = "http://clojars.org/repo/cake/cake"
$repo = "http://github.com/ninjudd/cake-standalone/raw/master"
$confdir = ".cake"
$config = Configuration.new("#{$home}/.cake/config", ".cake/config")
$timeout = ($config['connect.timeout'] || 20).to_i
Expand Down
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject cake "0.4.10"
(defproject cake "0.4.11"
:description "Save your fork, there's cake!"
:dependencies [[clojure "1.2.0"]
[ordered-set "0.1.0"]
Expand Down
2 changes: 1 addition & 1 deletion src/cake/ant.clj
Expand Up @@ -95,7 +95,7 @@
(apply path "src" "lib/*" paths))

(defn args [task & args]
(doseq [a (flatten args)]
(doseq [a (remove nil? (flatten args))]
(.. task createArg (setValue a))))

(defn sys [task map]
Expand Down
2 changes: 1 addition & 1 deletion src/cake/tasks/dependencies.clj
Expand Up @@ -77,7 +77,7 @@
(doseq [type [:dependencies :dev-dependencies]
[dep _ & opts] (*project* type) :let [opts (apply array-map opts)]]
(when-let [path (subproject-path dep)]
(binding [cake/*root* path]
(binding [*root* path]
(cake-exec "install")))))

(defn extract-native [jars dest]
Expand Down
2 changes: 1 addition & 1 deletion src/cake/tasks/release.clj
Expand Up @@ -81,7 +81,7 @@
(let [code (.read in)]
(when-not (= 0 code)
(copy in *outs*)
(throw (Exception. (case code 1 "ssh error" 2 "ssh fatal error"))))))
(throw (Exception. (case code 1 "ssh error" 2 "ssh fatal error" -1 "disconnect error" "unknown error"))))))

(defn- send-ack [out]
(.write out (byte-array [(byte 0)]))
Expand Down
28 changes: 17 additions & 11 deletions tasks.clj
Expand Up @@ -41,14 +41,20 @@

(undeftask release)
(deftask release #{uberjar gem}
"Release project jar to clojars and gem package to rubygems."
(let [uberjarfile (uberjarfile)
jarfile (file "cake.jar")]
(ant Copy {:file uberjarfile :tofile jarfile})
(upload-to-clojars jarfile))
(let [version (:version *project*)]
(when-not (snapshot? version)
(let [gem (str "cake-" version ".gem")]
(log "Releasing gem:" gem)
(ant ExecTask {:executable "gem" :dir (file "gem")}
(args ["push" gem]))))))
"Release project jar to github and gem package to rubygems."
(let [version (:version *project*)
amend? (= version (slurp "releases/version"))]
(if (and amend? (not (snapshot? version)))
(println "cannot replace non-snapshot version:" version)
(let [jar (format "cake-%s.jar" version)]
(ant Copy {:file (uberjarfile) :tofile (file "releases" jar)})
(spit (file "releases/version") version)
(binding [*root* "releases"]
(git "add" jar "version")
(git "commit" (when amend? "--amend") "-m" (format "'release cake %s'" version))
(git "push" (when amend? "-f")))
(when-not (snapshot? version)
(let [gem (str "cake-" version ".gem")]
(log "Releasing gem:" gem)
(ant ExecTask {:executable "gem" :dir (file "gem")}
(args ["push" gem]))))))))

0 comments on commit a0107b2

Please sign in to comment.