private void configureJoobyRun(final Project project) {
project.getTasks()
.withType(JoobyTask.class, joobyRun -> {
ConventionMapping mapping = joobyRun.getConventionMapping();
mapping.map("classpath", () -> new JoobyProject(project).classpath());
mapping.map("src", () -> new JoobyProject(project).sources());
mapping.map("mainClassName", () -> project.getProperties().get("mainClassName"));
mapping.map("srcExtensions", () -> Arrays.asList(".java", ".conf", ".properties", ".kt"));
mapping.map("compiler", () -> {
File eclipseClasspath = new File(project.getProjectDir(), ".classpath");
return eclipseClasspath.exists() ? "off" : "on";
});
Gradle gradle = project.getGradle();
mapping.map("block", () -> !gradle.getStartParameter().isContinuous());
mapping.map("logLevel", () -> gradle.getStartParameter().getLogLevel().name());
});
Map<String, Object> options = new HashMap<>();
options.put(Task.TASK_TYPE, JoobyTask.class);
options.put(Task.TASK_DEPENDS_ON, "classes");
options.put(Task.TASK_NAME, "joobyRun");
options.put(Task.TASK_DESCRIPTION, "Run, debug and hot reload applications");
options.put(Task.TASK_GROUP, "jooby");
project.getTasks().create(options);
}