public void clean() { myProjectBuilder.clean(); for (ModuleWrapper m : myModules.values()) { m.updateOutputStatus(); } new File(myProjectSnapshot).delete(); }
public void report(final String module) { final ModuleWrapper m = getModule(module); if (m == null) { System.out.println("No module \"" + module + "\" found in project \""); } else { System.out.println( "Module " + m.myName + " " + (m.isOutdated(false, myHistory) ? "is outdated" : "is up-to-date")); System.out.println( "Module " + m.myName + " tests " + (m.isOutdated(true, myHistory) ? "are outdated" : "are up-to-date")); } }
private ProjectWrapper(final BufferedReader r, final Set<String> affected) { affectedFiles = affected; myProject = null; myProjectBuilder = null; myHistory = null; myRoot = RW.readStringAttribute(r, "Root:"); myProjectSnapshot = myHomeDir + File.separator + myJPSDir + File.separator + myRoot.replace(File.separatorChar, myFileSeparatorReplacement); RW.readTag(r, "Libraries:"); final Set<LibraryWrapper> libs = (Set<LibraryWrapper>) RW.readMany(r, myLibraryWrapperReader, new HashSet<LibraryWrapper>()); for (LibraryWrapper l : libs) { myLibraries.put(l.getName(), l); } RW.readTag(r, "Modules:"); final Set<ModuleWrapper> mods = (Set<ModuleWrapper>) RW.readMany(r, myModuleWrapperReader, new HashSet<ModuleWrapper>()); for (ModuleWrapper m : mods) { myModules.put(m.getName(), m); } RW.readMany(r, RW.myStringReader, affectedFiles); try { dependencyMapping = new Mappings(getMapDir()); } catch (IOException e) { throw new RuntimeException(e); } backendCallback = dependencyMapping.getCallback(); }
public void report() { boolean moduleReport = true; System.out.println("Project \"" + myRoot + "\" report:"); if (myHistory == null) { System.out.println(" no project history found"); } if (moduleReport) { for (ModuleWrapper m : myModules.values()) { System.out.println( " module " + m.getName() + " " + (m.isOutdated(false, myHistory) ? "is outdated" : "is up-to-date")); System.out.println( " module " + m.getName() + " tests " + (m.isOutdated(true, myHistory) ? "are outdated" : "are up-to-date")); } } }
public boolean isOutdated(final boolean tests, final ProjectWrapper history) { if (history == null) { return true; } final ModuleWrapper past = history.getModule(myName); if (past == null) { return true; } final boolean outputChanged = !safeEquals(past.getOutputPath(), getOutputPath()); final boolean testOutputChanged = tests && !safeEquals(past.getTestOutputPath(), getTestOutputPath()); final boolean sourceChanged = !past.getSourceFiles().equals(getSourceFiles()); final boolean testSourceChanged = tests && !past.getTestSourceFiles().equals(getTestSourceFiles()); final boolean sourceOutdated = mySource.isOutdated() || !mySource.getOutdatedFiles(past.mySource).isEmpty(); final boolean testSourceOutdated = tests && (myTest.isOutdated() || !myTest.getOutdatedFiles(past.myTest).isEmpty()); final boolean unsafeDependencyChange = (new Object() { public boolean run( final List<ClasspathItemWrapper> today, final List<ClasspathItemWrapper> yesterday) { final Iterator<ClasspathItemWrapper> t = today.iterator(); final Iterator<ClasspathItemWrapper> y = yesterday.iterator(); while (true) { if (!y.hasNext()) return false; if (!t.hasNext()) return true; if (!safeEquals(t.next(), y.next())) return true; } } }.run(dependsOn(tests), past.dependsOn(tests))); return sourceOutdated || testSourceOutdated || sourceChanged || testSourceChanged || outputChanged || testOutputChanged || unsafeDependencyChange; }
public WeakClasspathItemWrapper(final ModuleWrapper m) { myType = "Module"; myName = m.getName(); }
public BuildStatus build(final Collection<Module> modules, final Flags flags) { boolean incremental = flags.incremental(); final List<ModuleChunk> chunks = myProjectBuilder.getChunks(flags.tests()).getChunkList(); for (final ModuleChunk c : chunks) { final Set<Module> chunkModules = c.getElements(); if (!DefaultGroovyMethods.intersect(modules, chunkModules).isEmpty()) { final Set<String> removedSources = new HashSet<String>(); if (incremental) { final Set<String> chunkSources = new HashSet<String>(); final Set<String> outdatedSources = new HashSet<String>(); for (Module m : chunkModules) { final ModuleWrapper mw = getModule(m.getName()); outdatedSources.addAll(mw.getOutdatedFiles(flags.tests())); chunkSources.addAll(mw.getSources(flags.tests())); removedSources.addAll(mw.getRemovedFiles(flags.tests())); } final BuildStatus result = iterativeCompile(c, chunkSources, outdatedSources, removedSources, flags); incremental = result == BuildStatus.INCREMENTAL; if (result == BuildStatus.FAILURE) { return result; } } else { new Logger(flags) { @Override public void log(PrintStream stream) { stream.println("Compiling chunk " + c.getName() + " non-incrementally."); } }.log(); for (Module m : chunkModules) { final ModuleWrapper mw = getModule(m.getName()); removedSources.addAll(flags.tests() ? mw.getRemovedTests() : mw.getRemovedSources()); } final Set<Module> toClean = new HashSet<Module>(); for (Module m : chunkModules) { if (!cleared.contains(m)) { toClean.add(m); } } if (!toClean.isEmpty() && !flags.tests()) { builder.clearChunk(new ModuleChunk(toClean), null, ProjectWrapper.this); cleared.addAll(toClean); } final Mappings delta = dependencyMapping.createDelta(); final Callbacks.Backend deltaCallback = delta.getCallback(); try { builder.buildChunk(c, flags.tests(), null, deltaCallback, ProjectWrapper.this); } catch (Exception e) { e.printStackTrace(); return BuildStatus.FAILURE; } final Set<String> allFiles = new HashSet<String>(); for (Module m : c.getElements()) { final ModuleWrapper module = getModule(m.getName()); affectedFiles.removeAll(module.getSources(flags.tests())); allFiles.addAll(module.getSources(flags.tests())); } final Collection<File> files = new HashSet<File>(); for (String f : allFiles) { files.add(new File(f)); } dependencyMapping.integrate(delta, files, removedSources); for (Module m : chunkModules) { Reporter.reportBuildSuccess(m, flags.tests()); } } } } return BuildStatus.INCREMENTAL; }