Skip to content

Commit

Permalink
Deploy ad-hoc files.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed May 12, 2013
1 parent b4660d5 commit 0ddd6ca
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ If your preferred
has a relatively recent version of Leiningen, try that first.
Otherwise you can install by hand:

Leiningen bootstraps itself using the `lein` shell script;
there is no separate install script. It installs its dependencies
upon the first run on unix, so the first run will take longer.
Leiningen bootstraps itself using the `lein` shell script; there is no
separate install script. It handles installing its own dependencies,
which means the first run will take longer.

1. Make sure you have JDK 6 or later.
2. [Download the script](https://raw.github.com/technomancy/leiningen/stable/bin/lein).
Expand Down
14 changes: 8 additions & 6 deletions doc/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
**A:** Use [semantic versioning](http://semver.org).

**Q:** What if my project depends on jars that aren't in any repository?
**A:** The best thing to do is to get them in a repository. The
**A:** You will need to get them in a repository. The
[deploy guide](https://github.com/technomancy/leiningen/blob/stable/doc/DEPLOY.md)
explains how to set up a private repository. In general it's easiest
to deploy them to a static HTTP server or a private S3
bucket with the
to deploy them to a static HTTP server or a private S3 bucket with the
[s3-wagon-private](https://github.com/technomancy/s3-wagon-private)
plugin. If you are just doing exploratory coding and not
collaborating with a team you could
[install locally](https://github.com/kumarshantanu/lein-localrepo).
plugin. Once the repo is set up, `lein deploy private-repo com.mycorp/somejar
1.0.0 somejar.jar pom.xml` will push the artifacts out. If you don't
have a pom, you can create a dummy project with `lein new` and
generate a pom from that. If you are just doing exploratory coding
you can deploy to `file:///$HOME/.m2/repository` and the jars will
be available locally.

**Q:** I want to hack two projects in parallel, but it's annoying to switch between them.
**A:** Leiningen provides a feature called *checkout dependencies*.
Expand Down
48 changes: 37 additions & 11 deletions src/leiningen/deploy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
["--default-key" key])]
`["--yes" "-ab" ~@key-spec "--" ~file]))

;; TODO: be clearer about the fact that signing is going on
(defn sign [file opts]
"Create a detached signature and return the signature file name."
(let [{:keys [err exit]} (apply user/gpg (signing-args file opts))]
Expand Down Expand Up @@ -115,8 +116,8 @@
branches
not))

(defn deploy
"Build jar and deploy to remote repository.
(defn ^:no-project-needed deploy
"Deploy jar and pom to remote repository.
The target repository will be looked up in :repositories in project.clj:
Expand All @@ -125,16 +126,30 @@ The target repository will be looked up in :repositories in project.clj:
[\"alternate\" \"https://other.server/repo\"]]
If you don't provide a repository name to deploy to, either \"snapshots\" or
\"releases\" will be used depending on your project's current version. See
`lein help deploying` under \"Authentication\" for instructions on how to
configure your credentials so you are not prompted on each deploy."
([project repository-name]
\"releases\" will be used depending on your project's current version. You may
provide a repository URL instead of a name.
See `lein help deploying` under \"Authentication\" for instructions on
how to configure your credentials so you are not prompted on each
deploy.
You can also deploy arbitrary artifacts from disk:
$ lein deploy myrepo com.blueant/fancypants 1.0.1 fancypants.jar pom.xml
While this works with any arbitrary files on disk, downstream projects will not
be able to depend on jars that are deployed without a pom."
([project]
(deploy project (if (pom/snapshot? project)
"snapshots"
"releases")))
([project repository]
(let [branches (set (:deploy-branches project))]
(when (and (seq branches)
(in-branches branches))
(apply main/abort "Can only deploy from branches listed in :deploy-branches:" branches)))
(warn-missing-metadata project)
(let [repo (repo-for project repository-name)
(let [repo (repo-for project repository)
files (files-for project repo)]
(try
(main/debug "Deploying" files "to" repo)
Expand All @@ -147,7 +162,18 @@ configure your credentials so you are not prompted on each deploy."
(catch org.sonatype.aether.deployment.DeploymentException e
(when main/*debug* (.printStackTrace e))
(main/abort (abort-message (.getMessage e)))))))
([project]
(deploy project (if (pom/snapshot? project)
"snapshots"
"releases"))))
([project repository identifier version & files]
(let [identifier (symbol identifier)
artifact-id (name identifier)
group-id (or (namespace identifier))
repo (repo-for project repository)
artifacts (for [f files]
[[:extension (if (= "pom.xml" (.getName (io/file f)))
"pom" (last (.split f "\\.")))] f])]
(main/debug "Deploying" files "to" repo)
(aether/deploy
:coordinates [(symbol group-id artifact-id) version]
:artifact-map (into {} artifacts)
:transfer-listener :stdout
:repository [repo]
:local-repo (:local-repo project)))))

0 comments on commit 0ddd6ca

Please sign in to comment.