Skip to content

Commit 80206cf

Browse files
authored
Fix lein build command when uberjar profile is used (#199)
1 parent 681ef10 commit 80206cf

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

bin/compile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,15 @@ clojure -e "(println)" &>/dev/null
7474
output::step "Reading Leiningen project properties"
7575

7676
lein_project_plugins=$("${BUILDPACK_DIR}/opt/get_project_property.clj" "${BUILD_DIR}/project.clj" "plugins")
77-
lein_project_uberjar_name=$("${BUILDPACK_DIR}/opt/get_project_property.clj" "${BUILD_DIR}/project.clj" "uberjar-name")
7877
lein_project_min_lein_version=$("${BUILDPACK_DIR}/opt/get_project_property.clj" "${BUILD_DIR}/project.clj" "min-lein-version")
7978

79+
lein_project_uberjar_name=$("${BUILDPACK_DIR}/opt/get_project_property.clj" "${BUILD_DIR}/project.clj" "uberjar-name")
80+
# The :uberjar profile is automatically activated by Leiningen when running "lein uberjar".
81+
# Check for :uberjar-name inside this profile if it's not defined at the top level.
82+
if [[ -z "${lein_project_uberjar_name}" ]]; then
83+
lein_project_uberjar_name=$("${BUILDPACK_DIR}/opt/get_project_property.clj" "${BUILD_DIR}/project.clj" "profiles" "uberjar" "uberjar-name")
84+
fi
85+
8086
if grep -q lein-npm <<<"${lein_project_plugins}"; then
8187
if ! command -v npm &>/dev/null; then
8288
output::error <<-EOF

hatchet.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"hatchet": {
33
"directory": "test/spec/fixtures"
4-
}
4+
},
5+
"github": ["heroku/clojure-getting-started"]
56
}

hatchet.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
--- []
1+
---
2+
- - test/spec/fixtures/repos/github/clojure-getting-started
3+
- main

opt/get_project_property.clj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414

1515
(when (< (count *command-line-args*) 2)
1616
(binding [*out* *err*]
17-
(println "Usage: get_project_property.clj <project.clj> <property-name>"))
17+
(println "Usage: get_project_property.clj <project.clj> <property-name> [<nested-key>...]"))
1818
(System/exit 1))
1919

20-
(defn get-project-property [file-path property-name]
20+
(defn get-project-property [file-path & property-path]
2121
(let [project-data (read-string (slurp file-path))
22-
properties (apply hash-map (drop 3 project-data))]
23-
(get properties (keyword property-name))))
22+
properties (apply hash-map (drop 3 project-data))
23+
key-path (map keyword property-path)]
24+
(get-in properties key-path)))
2425

2526
(let [file-path (first *command-line-args*)
26-
property-name (second *command-line-args*)
27-
property-value (get-project-property file-path property-name)]
27+
property-path (rest *command-line-args*)
28+
property-value (apply get-project-property file-path property-path)]
2829
(println (or property-value "")))

test/spec/smoke_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'spec_helper'
4+
5+
RSpec.describe 'Clojure buildpack' do
6+
it 'can build and run Heroku\'s Clojure getting started app' do
7+
app = Hatchet::Runner.new('clojure-getting-started')
8+
app.deploy do
9+
expect(http_get(app)).to include('Clojure Getting Started on Heroku')
10+
end
11+
end
12+
end

0 commit comments

Comments
 (0)