@CheckReturnValue private Project createProject(Path[] files) { final Project project = new Project(); project.setProjectName(getClass().getSimpleName()); if (PLUGIN_JAR != null) { try { String pluginId = Plugin.addCustomPlugin(PLUGIN_JAR.toURI()).getPluginId(); project.setPluginStatusTrinary(pluginId, Boolean.TRUE); } catch (PluginException e) { throw new AssertionError("Failed to load plugin", e); } } for (Path file : files) { project.addFile(file.toAbsolutePath().toString()); } for (Path auxClasspathEntry : auxClasspathEntries) { project.addAuxClasspathEntry(auxClasspathEntry.toAbsolutePath().toString()); } return project; }
/** * Configure the BugCollection (if the BugReporter being used is * constructing one). * * @param findBugs * the IFindBugsEngine */ public static void configureBugCollection(IFindBugsEngine findBugs) { BugCollection bugs = findBugs.getBugReporter().getBugCollection(); if (bugs != null) { bugs.setReleaseName(findBugs.getReleaseName()); Project project = findBugs.getProject(); String projectName = project.getProjectName(); if (projectName == null) { projectName = findBugs.getProjectName(); project.setProjectName(projectName); } long timestamp = project.getTimestamp(); if (FindBugs.validTimestamp(timestamp)) { bugs.setTimestamp(timestamp); bugs.getProjectStats().setTimestamp(timestamp); } } }
origCollection.getProject().setProjectName(commandLine.projectName); project.setSuppressionFilter(Filter.parseFilter(commandLine.exclusionFilterFile)); project.getSourceDirList().clear(); project.getFileList().clear(); project.getAuxClasspathEntryList().clear(); project.getSourceDirList().clear(); project.addSourceDirs(commandLine.sourcePaths); project.addSourceDirs(foundPaths); for (String dir : foundPaths) { if (argCount < args.length) {
public static Project readXML(File f) throws IOException, SAXException { @SuppressWarnings("resource") // will be closed by caller Project project = new Project(); try (InputStream in = new BufferedInputStream(new FileInputStream(f))) { String tag = Util.getXMLType(in); SAXBugCollectionHandler handler; if ("Project".equals(tag)) { handler = new SAXBugCollectionHandler(project, f); } else if ("BugCollection".equals(tag)) { SortedBugCollection bugs = new SortedBugCollection(project); handler = new SAXBugCollectionHandler(bugs, f); } else { throw new IOException("Can't load a project from a " + tag + " file"); } XMLReader xr = XMLReaderFactory.createXMLReader(); xr.setContentHandler(handler); xr.setErrorHandler(handler); try (Reader reader = Util.getReader(in)) { xr.parse(new InputSource(reader)); } } catch (IOException | SAXException e) { project.close(); throw e; } // Presumably, project is now up-to-date project.setModified(false); return project; }
private IClassPath buildClassPath(IClassPathBuilder builder, IClassFactory factory) throws InterruptedException, IOException, CheckedAnalysisException { progress.startScanningArchives(project.getFileCount()); for (String path : project.getFileList()) { builder.addCodeBase(factory.createFilesystemCodeBaseLocator(path), true); } for (String path : project.getAuxClasspathEntryList()) { builder.addCodeBase(factory.createFilesystemCodeBaseLocator(path), false); } IClassPath classPath = factory.createClassPath(); builder.build(classPath, progress); progress.doneScanningArchives(); return classPath; }
/** * Create project. * @param basedir Base dir * @param outdir Output dir (with classes) * @param paths Paths of a classpath * @return The project */ private static Project project(final String basedir, final String outdir, final String... paths) { final Project project = new Project(); for (final String jar : paths) { if (!jar.equals(outdir)) { project.addAuxClasspathEntry(jar); } } project.addFile(outdir); project.addSourceDir(new File(basedir, "src/main/java").getPath()); return project; }
private Project createProject() { final Project project = new Project(); PluginLoader.addPluginsTo(project); for (final AnalyzerConfig.Path clazz : config.getClassPaths()) { project.addFile(clazz.getPath()); } project.addSourceDirs(config.getSourcePaths().stream().map(AnalyzerConfig.Path::getPath).collect(toList())); final String pathSeparator = System.getProperty("path.separator"); final String classPath = System.getProperty("java.class.path"); for (final String entry : classPath.split(pathSeparator)) { project.addAuxClasspathEntry(entry); } return project; }
/** * Constructor. Creates an empty object given an existing ProjectStats. * * @param projectStats * the ProjectStats * @param comparator * to use for sorting bug instances */ public SortedBugCollection(ProjectStats projectStats, Comparator<BugInstance> comparator) { this(projectStats, comparator, new Project()); }
String oldCloudId = null; p = project; oldCloudId = project.getCloudId(); p.setGuiCallback(MainFrame.getInstance().getGuiCallback()); clearProjectSettings(p); p.addFile(analyzeModel.get(i)); p.addAuxClasspathEntry(auxModel.get(i)); p.addSourceDir(sourceModel.get(i)); p.setProjectName(projectName.getText()); CloudPlugin cloudPlugin = (CloudPlugin) cloudSelector.getSelectedItem(); String newCloudId; newCloudId = cloudPlugin.getId(); p.setCloudId(newCloudId); String name = p.getProjectName(); if (name == null) { name = Project.UNNAMED_PROJECT;
public Project getFindbugsProject() throws IOException { Project findbugsProject = new Project(); findbugsProject.addAuxClasspathEntry(file.getCanonicalPath()); findbugsProject.addFile(absolutePath); if (annotationsLib != null) { findbugsProject.addAuxClasspathEntry(annotationsLib.getCanonicalPath()); findbugsProject.addAuxClasspathEntry(jsr305Lib.getCanonicalPath()); findbugsProject.setCurrentWorkingDirectory(fileSystem.workDir()); return findbugsProject;
@Override public void actionPerformed(ActionEvent evt) { final Project tempProject = new Project(); for (int i = 0; i < analyzeModel.getSize(); i++) { tempProject.addFile(analyzeModel.get(i)); } for (int i = 0; i < auxModel.getSize(); i++) { tempProject.addAuxClasspathEntry(auxModel.get(i)); } java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { final SourceDirectoryWizard dialog = new SourceDirectoryWizard(new javax.swing.JFrame(), true, tempProject, thisGUI); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { if (dialog.discover != null && dialog.discover.isAlive()) { dialog.discover.interrupt(); } } }); dialog.setVisible(true); } }); } });
project.addSourceDirs(sourceDirs); } else if (elementStack.size() > 1) { String outerElement = elementStack.get(elementStack.size() - 2); assert project != null; if ("Jar".equals(qName)) { project.addFile(makeAbsolute(getTextContents())); } else if ("SrcDir".equals(qName)) { sourceDirs.add(makeAbsolute(getTextContents())); } else if ("AuxClasspathEntry".equals(qName)) { project.addAuxClasspathEntry(makeAbsolute(getTextContents()));
if (project == null) { ProjectSettings.newInstance(); project = new Project(); isNewProject = true; cloudSelector.setRenderer(aRenderer); cloudSelector.addItem(null); String cloudId = project.getCloudId(); Boolean fbPluginStatus = project.getPluginStatus(plugin); if ((!c.isHidden() || c.getId().equals(cloudId)) && !Boolean.FALSE.equals(fbPluginStatus)) { cloudSelector.addItem(c); CloudPlugin c = DetectorFactoryCollection.instance().getRegisteredClouds().get(project.getCloudId()); cloudSelector.setSelectedItem(c); for (String i : curProject.getFileList()) { analyzeModel.addElement(i); for (String i : curProject.getAuxClasspathEntryList()) { auxModel.addElement(i); for (String i : curProject.getSourceDirList()) { sourceModel.addElement(i); projectName.setText(curProject.getProjectName()); projectName.addKeyListener(new KeyAdapter() { @Override
origCollection.getProject().setProjectName(commandLine.projectName); project.setSuppressionFilter(Filter.parseFilter(commandLine.exclusionFilterFile)); project.getSourceDirList().clear(); project.getFileList().clear(); project.getAuxClasspathEntryList().clear(); project.setCloudId(commandLine.cloudId); reinitializeCloud = true; project.getCloudProperties().setProperty(e.getKey(), e.getValue()); reinitializeCloud = true; project.getSourceDirList().clear(); project.addSourceDir(source); project.addSourceDir(dir); if (argCount < args.length) { System.out.println("Found " + dir);
assert project != null; if ("Jar".equals(qName)) { project.addFile(makeAbsolute(getTextContents())); } else if ("SrcDir".equals(qName)) { project.addSourceDir(makeAbsolute(getTextContents())); } else if ("AuxClasspathEntry".equals(qName)) { project.addAuxClasspathEntry(makeAbsolute(getTextContents())); assert project != null; assert cloudPropertyKey != null; project.getCloudProperties().setProperty(cloudPropertyKey, getTextContents()); cloudPropertyKey = null; } else if ("BugInstance".equals(outerElement)) {
/** * Parse the argument as auxclasspath entries and add them * * @param argument */ private void addAuxClassPathEntries(String argument) { StringTokenizer tok = new StringTokenizer(argument, File.pathSeparator); while (tok.hasMoreTokens()) { project.addAuxClasspathEntry(tok.nextToken()); } }
/** * Handle -analyzeFromFile command line option by reading jar file names * from a file and adding them to the project. * * @throws IOException */ private void handleAnalyzeFromFile(String filePath) throws IOException { try (BufferedReader in = new BufferedReader(UTF8.fileReader(filePath))) { while (true) { String s = in.readLine(); if (s == null) { break; } project.addFile(s); } } }
project.addFile(argv[i]); if (commandLine.getProject().getFileCount() == 0 && !commandLine.justPrintConfiguration() && !commandLine.justPrintVersion()) { System.out.println("No files to be analyzed");
static SortedBugCollection createPreconfiguredBugCollection(List<String> workingDirList, List<String> srcDirList, IGuiCallback guiCallback) { Project project = new Project(); for (String cwd : workingDirList) { project.addWorkingDir(cwd); } for (String srcDir : srcDirList) { project.addSourceDir(srcDir); } project.setGuiCallback(guiCallback); return new SortedBugCollection(project); }