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); }
@TaskAction public void run() throws Exception { System.setProperty("logLevel", getLogLevel()); String mId = project.getName(); getLogger().info("compiler is {}", compiler); if ("on".equalsIgnoreCase(compiler)) { Path[] watchDirs = getSrc().stream().filter(File::exists).map(File::toPath).toArray(Path[]::new); getLogger().info("watching directories {}", Arrays.asList(watchDirs)); connection = GradleConnector.newConnector() .useInstallation(project.getGradle().getGradleHomeDir()) .forProjectDirectory(project.getRootDir()) .connect(); .onComplete(() -> connection.close()) .throwException())); watcher.start(); String[] args = project.getGradle().getStartParameter().getProjectProperties() .entrySet().stream().map(Object::toString).collect(Collectors.toList()) .toArray(new String[0]);
@Override public void execute(BuildResult buildResult) { Throwable failure = buildResult.getFailure(); if (failure != null) { DoHandleService.search(failure.getCause().getCause().getMessage(),5); } else { System.out.println("没有异常,这很棒!"); } } });
/** * Sets the build file that should be used for this build. * * @param file The build file. May be null to use the default build file for the build. */ public void setBuildFile(Object file) { getStartParameter().setBuildFile(getProject().file(file)); }
public BuildLayoutConfiguration(StartParameter startParameter) { currentDir = startParameter.getCurrentDir(); searchUpwards = startParameter.isSearchUpwards(); settingsFile = startParameter.getSettingsFile(); useEmptySettings = startParameter.isUseEmptySettings(); }
@Override public void buildFinished(BuildResult result) { super.buildFinished( result ); for ( DatabaseAllocation databaseAllocation : databaseAllocations ) { databaseAllocation.release(); } } }
public void buildFinished(BuildResult result) { Throwable failure = result.getFailure(); if (failure == null) { return; } execute(failure); }
public void buildFinished(BuildResult result) { buildProfile.setSuccessful(result.getFailure() == null); }
/** * Sets the tasks that should be executed for this build. * * @param tasks The task names. May be empty or null to use the default tasks for the build. */ public void setTasks(Collection<String> tasks) { getStartParameter().setTaskNames(tasks); }
@Override public void finishBuild() { if (stage != null) { finishBuild(new BuildResult(stage.name(), gradle, null)); } }
@Override public void buildFinished(BuildResult result) { if (result.getGradle() == rootGradle) { rootGradle = null; } }
private boolean isConfigureOnDemand() { return gradle.getStartParameter().isConfigureOnDemand(); }
public void buildFinished(BuildResult result) { for (BuildListener logger : resultLoggers) { logger.buildFinished(result); } } }
@Override public File getGradleUserHomeDir() { return startParameter.getGradleUserHomeDir(); }
public boolean isValid() { return !startParameter.isRecompileScripts(); } };
private void projectsEvaluated() { buildListener.projectsEvaluated(gradle); }
public JavaPerson(String name) { setName(name); } }
public BuildLayoutConfiguration(StartParameter startParameter) { currentDir = startParameter.getCurrentDir(); searchUpwards = startParameter.isSearchUpwards(); settingsFile = startParameter.getSettingsFile(); useEmptySettings = startParameter.isUseEmptySettings(); }
@Override public void buildFinished(BuildResult result) { super.buildFinished( result ); for ( DatabaseAllocation databaseAllocation : databaseAllocations ) { databaseAllocation.release(); } } }