private void updateRakeTasks() { RubyPlatform platform = getPlatform(); if (hasRakeFile() && platform != null && platform.hasValidRake(false)) { requestProcessor.post(new Runnable() { public void run() { RakeSupport.refreshTasks(RubyBaseProject.this, false); } }); } }
/** * Checks whether project has a valid platform and in turn whether the * platform has a valid Rake installed. * * @param warn whether to show warning message to the user if ther is no * valid Rake installed */ public static boolean hasValidRake(final Project project, final boolean warn) { RubyPlatform platform = RubyPlatform.platformFor(project); if (platform == null) { if (warn) { showWarning(project); } return false; } return platform.hasValidRake(warn); }
/** * Runs the tasks specifed by the given <code>taskNames</code>. * * @param taskNames the names of the tasks to run. */ public List<Future<Integer>> run(String... taskNames) { if (taskNames.length == 0) { taskNames = new String[]{"default"}; // NOI18N } if (!RubyPlatform.hasValidRake(project, showWarnings)) { return null; } RakeTask[] rakeTasks = new RakeTask[taskNames.length]; for (int i = 0; i < taskNames.length; i++) { RakeTask rakeTask = RakeSupport.getRakeTask(project, taskNames[i]); if (rakeTask == null) { if (showWarnings) { Util.notifyLocalized(RakeRunner.class, "RakeRunner.task.does.not.exist", taskNames[i]); // NOI18N } return null; // run only when all tasks are available } rakeTasks[i] = rakeTask; } return run(rakeTasks); }
/** * Runs 'rake -D' and writes the output into the {@link #RAKE_D_OUTPUT} if * succeed. * * @param project project for which tasks are read */ public static void refreshTasks(final Project project, final boolean warn) { final FileObject projectDir = project.getProjectDirectory(); try { projectDir.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() { public void run() throws IOException { FileObject rakeD = project.getProjectDirectory().getFileObject(RAKE_D_OUTPUT); // clean old content if (rakeD != null && rakeD.isValid() && rakeD.isData()) { rakeD.delete(); } } }); } catch (IOException ioe) { Exceptions.printStackTrace(ioe); } if (!RubyPlatform.hasValidRake(project, true)) { return; } String rakeOutput = readRakeTasksOutput(project, warn); if (rakeOutput != null) { writeRakeTasks(project, rakeOutput); } }
private List<Future<Integer>> run(final RakeTask... tasks) { assert tasks.length > 0 : "must pass at least one task"; if (!RubyPlatform.hasValidRake(project, showWarnings)) { return null; } // Save all files first LifecycleManager.getDefault().saveAll(); // EMPTY CONTEXT?? if (fileLocator == null) { fileLocator = new RubyFileLocator(Lookup.EMPTY, project); } if (rakeFile == null) { rakeFile = RakeSupport.findRakeFile(project); } if (rakeFile == null) { pwd = FileUtil.toFile(project.getProjectDirectory()); } if (pwd == null) { pwd = FileUtil.toFile(rakeFile.getParent()); } List<RakeTask> tasksToRun = Arrays.asList(tasks); computeAndSetDisplayName(tasksToRun); final List<ExecutionService> services = getExecutionServices(tasksToRun); List<Future<Integer>> futures = new ArrayList<Future<Integer>>(services.size()); for (ExecutionService each : services) { futures.add(each.run()); } return futures; }
public void run() { if (!RubyPlatform.hasValidRake(project, true)) { return; } // Save all files first LifecycleManager.getDefault().saveAll(); // EMPTY CONTEXT?? RailsFileLocator fileLocator = new RailsFileLocator(Lookup.EMPTY, project); String displayName = NbBundle.getMessage(MigrateAction.class, "Migration"); File pwd = FileUtil.toFile(project.getProjectDirectory()); if (version == 0 && !confirmReset()) { return; } RakeRunner runner = new RakeRunner(project); runner.setPWD(pwd); runner.setDisplayName(displayName); runner.setFileLocator(fileLocator); runner.showWarnings(true); if (version != -1) { runner.setParameters("VERSION=" + Long.toString(version)); // NOI18N } runner.run("db:migrate"); }
if (!platform.hasRubyGemsInstalled(true) || !platform.hasValidRake(true)) { return; if (!platform.hasValidRake(true)) { return;