sormuras / bach

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

Configuration annotations #114

Closed sormuras closed 4 years ago

sormuras commented 4 years ago

Introduce a set of annotations to configure a module?

@MainClass(m.n.Main.class)
@Version("12.3")
module m {
    requires java.base;
}

Introduce a set of annotations to configure a project?

@Name("project")
@Version("12")
@Release(11)
@LibraryLink(module = "junit", maven = "junit:junit:4.13")
project p {}
sormuras commented 4 years ago

Declined. Don't let build tool specific annotations leak into project sources.

Alternative that is also future-proof:

public class Build {

  private static final String VERSION = "2.1-ea";

  public static void main(String... args) {
    System.out.println("Building Bach.java " + VERSION + "...");
    Bach.build(
        Configuration.of("Bach.java", VERSION)
            .setLog(Log.ofSystem(true))
            .setMainRelease(11)
            .setModuleDescriber(Build::describeModule)
            .setGroup("de.sormuras.bach"));
  }

  static ModuleDescriptor describeModule(Path info) {
    var builder = Configuration.newModule(info);
    var module = builder.build();
    if (module.name().equals("de.sormuras.bach")) builder.mainClass(Bach.class.getName());
    return builder.build();
  }
}