boot-clj / boot

Build tooling for Clojure.
https://boot-clj.github.io/
Eclipse Public License 1.0
1.75k stars 180 forks source link

Jar tasks :file option could treat input string as template #617

Open jgrzebyta opened 7 years ago

jgrzebyta commented 7 years ago

boot.task.built-in/jar uses the argument :file value literally. It would be useful if the value was treated as a template. For exmaple "{project}-{version}-standalone.jar".

martinklepsch commented 7 years ago

@jgrzebyta the jar task itself has little knowledge about the project and version. These things are encoded in a pom.xml file (see pom task) which eventually ends up inside the Jar.

If you have project & version defined in your build.boot you can also just do something like this:

(jar :file (str project "-" version "-standalone.jar")

I think this is preferable over string templating and since you pass project and version to the pom task anyways it's probably not a big deal to move those to their own defs.

Sidenote: There is also some code to determine the jar name from a pom file but it does not always work well when building uberjars. You may try to use the jar tasks project option if it doesn't.

jgrzebyta commented 7 years ago

The problem occurs when the version is setup by external tool (boot-semver for example). Details described at degree9/boot-semver#60 .

I fixed that issue and will send PR.

martinklepsch commented 7 years ago

@jgrzebyta are you using boot-semver's version-pom task? If you do, I think the jar task should pick up the project and version accordingly. Maybe also @flyboarder can weigh in how he solves this issue when using boot-semver.

While it's great that you provide a patch in #618 I think this needs a bit more discussion before we can decide whether to add a feature that allows this kind of jar name string interpolation.

burn2delete commented 7 years ago

Boot-semver patches the built-in tasks by first checking an internal atom before defaulting to task options for the version and project strings. I believe the correct patch would be to check the boot env instead of my atom.

jgrzebyta commented 7 years ago

IMHO on the boot-semver side was all right since 1.7.0-snap. All things works till pom file. Boot reads project and version from pom correctly as well. The proof is that jar alone works fine for both release and snapshot.

The issue affects if I want to change default layout of the final jar file: project-version.jar. Option :file makes boot that the string argiment is taken literally. It would be fine if boot-semver makes possible to export version ecentre if I change it using task or task options. Unfortunately direct reading from the atom does not work: it stores only the default value.

On 16 Jun 2017 16:52, "Matthew Ratzke" notifications@github.com wrote:

Boot-semver patches the built-in tasks by first checking an internal atom before defaulting to task options for the version and project strings. I believe the correct patch would be to check the boot env instead of my atom.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/boot-clj/boot/issues/617#issuecomment-309063188, or mute the thread https://github.com/notifications/unsubscribe-auth/AGbRXNPOpjJKTufS4NgzDYyhOsX99JLSks5sEqTPgaJpZM4N8M3I .