/** * Extracts a visual studio solution if the project is a valid solution. * * @param project * the maven project from which a solution will be extracted * @return a visual studio solution * @throws DotNetProjectException * if the project is not a valid .Net project */ public static VisualStudioSolution getSolution(Project project) throws DotNetProjectException { MavenProject mavenProject = project.getPom(); final VisualStudioSolution solution; if (solutionCache.containsKey(mavenProject)) { solution = solutionCache.get(mavenProject); } else { solution = VisualStudioUtils.getVisualSolution(mavenProject, (String) null); solutionCache.put(mavenProject, solution); } return solution; }
/** * Configures the project POM with base required surefire settings * * @param project the project currently analyzed * @return the configured surefire MavenPlugin object instance, cannot be null */ public static MavenPlugin configure(Project project) { MavenPlugin surefire = MavenPlugin.registerPlugin(project.getPom(), GROUP_ID, ARTIFACT_ID, VERSION, false); surefire.setParameter("disableXmlReport", "false"); surefire.setParameter("testFailureIgnore", "true"); return surefire; }
@Override public boolean accept(Object extension) { if (ExtensionUtils.isType(extension, BatchComponent.class) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT)) { // Special use-case: the extension point ProjectBuilder is used in a Maven environment to define some // new sub-projects without pom. // Example : C# plugin adds sub-projects at runtime, even if they are not defined in root pom. return !ExtensionUtils.isMavenExtensionOnly(extension) || module.getPom() != null; } return false; } });
private static File getReportsDirectoryFromPluginConfiguration(Project project) { MavenPlugin plugin = MavenPlugin.getPlugin(project.getPom(), MavenSurefireUtils.GROUP_ID, MavenSurefireUtils.ARTIFACT_ID); if (plugin != null) { String path = plugin.getParameter("reportsDirectory"); if (path != null) { return project.getFileSystem().resolvePath(path); } } return null; }
private static File getReportsDirectoryFromPluginConfiguration(Project project) { MavenPlugin plugin = MavenPlugin.getPlugin(project.getPom(), MavenSurefireUtils.GROUP_ID, MavenSurefireUtils.ARTIFACT_ID); if (plugin != null) { String path = plugin.getParameter("reportsDirectory"); if (path != null) { return project.getFileSystem().resolvePath(path); } } return null; }
private void computeDependencyTree(final Project project, final SensorContext context) { LOG.warn("Computation of Maven dependencies by SonarQube is deprecated. Please update the version of SonarQube Maven plugin to 2.5+"); try { DependencyNode root = treeBuilder.buildDependencyTree(project.getPom(), localRepository, artifactFactory, artifactMetadataSource, null, artifactCollector); DependencyNodeVisitor visitor = new BuildingDependencyNodeVisitor(new DependencyNodeVisitor() { @Override public boolean visit(DependencyNode node) { return true; } @Override public boolean endVisit(DependencyNode node) { if (node.getParent() != null && node.getParent() != node) { saveDependency(project, node, context); } return true; } }); // mode verbose OFF : do not show the same lib many times DependencyNodeFilter filter = StateDependencyNodeFilter.INCLUDED; CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor(); DependencyNodeVisitor firstPassVisitor = new FilteringDependencyNodeVisitor(collectingVisitor, filter); root.accept(firstPassVisitor); DependencyNodeFilter secondPassFilter = new AncestorOrSelfDependencyNodeFilter(collectingVisitor.getNodes()); visitor = new FilteringDependencyNodeVisitor(visitor, secondPassFilter); root.accept(visitor); } catch (DependencyTreeBuilderException e) { throw new SonarException("Can not load the graph of dependencies of the project " + project.getKey(), e); } }