sormuras / bach

🎼 Bach Builds (on(ly)) Modules
https://bach.run
Universal Permissive License v1.0
234 stars 51 forks source link

Feature: add tweaks to specific modules #198

Closed Thihup closed 3 years ago

Thihup commented 3 years ago

For instance, using the jar --main-class.

Something like:

tweaks = {
   @Tweak(tool = "jar", with = {"--main-class", "com.foo.bar.Main"}, modules = {"com.foo.bar"}},
   @Tweak(tool = "jar", with = {"--main-class", "com.foo.baz.Main"}, modules = {"com.foo.baz"}},
}
sormuras commented 3 years ago

An interesting idea. The suggested modules field would work like a filter, with an empty array as the default, meaning "tweak all tool calls".

Although I consider Bach 16 feature-freezed, I might add this tiny tweak tweak. 😉

sormuras commented 3 years ago

Erm. Was about to implement this feature and found:

var jar =
    Command.builder("jar")
        .with("--create")
        .with("--file", main.workspace("modules", archive))
        .with(mainClass, (builder, className) -> builder.with("--main-class", className))
        .withEach(main.tweaks().arguments("jar"))
        .withEach(main.tweaks().arguments("jar(" + name + ')'));

Can you please try:

tweaks = {
   @Tweak(tool = "jar(com.foo.bar)", with = {"--main-class", "com.foo.bar.Main"}},
   @Tweak(tool = "jar(com.foo.baz)", with = {"--main-class", "com.foo.baz.Main"}},
}

Same goes for junit(MODULE) tweaks.

Thihup commented 3 years ago

Well, that worked 😄 Thanks!