Skip to content

Commit

Permalink
Pick correct binary in newer versions of clojure
Browse files Browse the repository at this point in the history
  • Loading branch information
paulocsanz committed Nov 6, 2024
1 parent 1b278d4 commit 28ad1f3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/pages/docs/providers/clojure.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The version can be overridden by
If a `build.clj` file for [`tools.build`](https://clojure.org/guides/tools_build) is found:

```
clojure -T:build uber; if [ -f /app/target/uberjar/*standalone.jar ]; then mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi
"clojure -T:build uber; for name in /app/target/default+uberjar/*.jar; do case $name in (*SNAPSHOT*) continue;; esac; mv $name /app/target/standalone.jar; fi"
```

If the `lein-ring` plugin is found:
Expand Down
5 changes: 3 additions & 2 deletions src/providers/clojure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ impl Provider for ClojureProvider {
};

// based on project config, uberjar can be created under ./target/uberjar or ./target, This ensure file will be found on the same place whatevery the project config is
let move_file_cmd = "if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi";
let move_file_cmd = "for name in /app/target/default+uberjar/*.jar; do case $name in (*SNAPSHOT*) continue;; esac; mv $name /app/target/standalone.jar; fi";

let mut build = Phase::build(Some(format!("{build_cmd}; {move_file_cmd}")));
build.depends_on_phase("setup");

let start = StartPhase::new("JAR_FILE=$(find ./target -name \"*standalone.jar\"); bash -c \"java $JAVA_OPTS -jar $JAR_FILE\"");
let start = StartPhase::new("JAR_FILE=$(find ./target -name \"standalone.jar\"); bash -c \"java $JAVA_OPTS -jar $JAR_FILE\"");

let plan = BuildPlan::new(&vec![setup, build], Some(start));
Ok(Some(plan))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ expression: plan
"setup"
],
"cmds": [
"clojure -T:build uber; if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi"
"clojure -T:build uber; for name in /app/target/default+uberjar/*.jar; do case $name in (*SNAPSHOT*) continue;; esac; mv $name /app/target/standalone.jar; fi"
]
},
"setup": {
Expand Down

0 comments on commit 28ad1f3

Please sign in to comment.