aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-09-17 10:47:32 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-09-17 10:48:31 +0200
commit000576a34e031bc58398d85116f1c7bb1f0a200e (patch)
tree7094aeb186a4a9d5566e8e5a367aff2157c561bd /plugins
parent9513bee576bda233b91e6703bf0e40a6c102752c (diff)
downloadsonarqube-000576a34e031bc58398d85116f1c7bb1f0a200e.tar.gz
sonarqube-000576a34e031bc58398d85116f1c7bb1f0a200e.zip
SONAR-5389 New dependency API
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-design-plugin/pom.xml103
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java48
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/DsmSerializer.java92
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/FileTangleIndexDecorator.java34
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java265
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/PackageTangleIndexDecorator.java34
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/ProjectDsmDecorator.java106
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/TangleIndexDecorator.java91
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/FileDesignWidget.java43
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/PackageDesignWidget.java43
-rw-r--r--plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb38
-rw-r--r--plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb61
-rw-r--r--plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java33
-rw-r--r--plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java60
-rw-r--r--plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/MavenDependenciesSensorTest.java93
-rw-r--r--plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json1
-rw-r--r--plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/MavenDependenciesSensorTest/getEffectiveLibraries/pom.xml29
17 files changed, 0 insertions, 1174 deletions
diff --git a/plugins/sonar-design-plugin/pom.xml b/plugins/sonar-design-plugin/pom.xml
deleted file mode 100644
index f04d435231f..00000000000
--- a/plugins/sonar-design-plugin/pom.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar</artifactId>
- <version>5.0-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
- <groupId>org.codehaus.sonar.plugins</groupId>
- <artifactId>sonar-design-plugin</artifactId>
- <packaging>sonar-plugin</packaging>
- <name>SonarQube :: Plugins :: Design</name>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-dependency-tree</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
-
- <!-- unit tests -->
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-testing-harness</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- </dependency>
- </dependencies>
-
- <build>
-
- <plugins>
- <plugin>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-packaging-maven-plugin</artifactId>
- <configuration>
- <pluginKey>design</pluginKey>
- <pluginName>Design</pluginName>
- <pluginClass>org.sonar.plugins.design.DesignPlugin</pluginClass>
- <pluginDescription><![CDATA[Analyze Java bytecode to compute O.O. metrics and extract dependencies between resources.]]></pluginDescription>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <artifactSet>
- <includes>
- <include>org.codehaus.sonar:sonar-gwt-pages</include>
- </includes>
- </artifactSet>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-dev-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>trim</id>
- <phase>process-resources</phase>
- <goals>
- <goal>trim</goal>
- </goals>
- <configuration>
- <directory>${project.build.outputDirectory}</directory>
- <includes>
- <include>**/*.erb</include>
- </includes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java
deleted file mode 100644
index bc464fe4b96..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design;
-
-import com.google.common.collect.ImmutableList;
-import org.sonar.api.Extension;
-import org.sonar.api.SonarPlugin;
-import org.sonar.plugins.design.batch.FileTangleIndexDecorator;
-import org.sonar.plugins.design.batch.MavenDependenciesSensor;
-import org.sonar.plugins.design.batch.PackageTangleIndexDecorator;
-import org.sonar.plugins.design.batch.ProjectDsmDecorator;
-import org.sonar.plugins.design.ui.widgets.FileDesignWidget;
-import org.sonar.plugins.design.ui.widgets.PackageDesignWidget;
-
-import java.util.List;
-
-public class DesignPlugin extends SonarPlugin {
-
- public List<Class<? extends Extension>> getExtensions() {
- return ImmutableList.of(
- // Batch
- MavenDependenciesSensor.class,
- ProjectDsmDecorator.class,
- PackageTangleIndexDecorator.class,
- FileTangleIndexDecorator.class,
-
- // UI
- FileDesignWidget.class,
- PackageDesignWidget.class);
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/DsmSerializer.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/DsmSerializer.java
deleted file mode 100644
index 01415ebb98b..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/DsmSerializer.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.batch;
-
-import org.sonar.api.design.Dependency;
-import org.sonar.api.resources.Resource;
-import org.sonar.graph.Dsm;
-import org.sonar.graph.DsmCell;
-
-public final class DsmSerializer {
-
- private Dsm dsm;
- private StringBuilder json;
-
- private DsmSerializer(Dsm<Resource> dsm) {
- this.dsm = dsm;
- this.json = new StringBuilder();
- }
-
- private String serialize() {
- json.append('[');
- serializeRows();
- json.append(']');
- return json.toString();
- }
-
- private void serializeRows() {
- for (int y = 0; y < dsm.getDimension(); y++) {
- if (y > 0) {
- json.append(',');
- }
- serializeRow(y);
- }
- }
-
- private void serializeRow(int y) {
- Resource resource = (Resource) dsm.getVertex(y);
-
- json.append("{");
- if (resource != null) {
- json.append("\"i\":");
- json.append(resource.getId());
- json.append(",\"n\":\"");
- json.append(resource.getName());
- json.append("\",\"q\":\"");
- json.append(resource.getQualifier());
- json.append("\",\"v\":[");
- for (int x = 0; x < dsm.getDimension(); x++) {
- if (x > 0) {
- json.append(',');
- }
- serializeCell(y, x);
- }
- json.append("]");
- }
- json.append("}");
- }
-
- private void serializeCell(int y, int x) {
- DsmCell cell = dsm.getCell(x, y);
- json.append('{');
- if (cell.getEdge() != null && cell.getWeight() > 0) {
- Dependency dep = (Dependency) cell.getEdge();
- json.append("\"i\":");
- json.append(dep.getId());
- json.append(",\"w\":");
- json.append(cell.getWeight());
- }
- json.append('}');
- }
-
- public static String serialize(Dsm<Resource> dsm) {
- return new DsmSerializer(dsm).serialize();
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/FileTangleIndexDecorator.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/FileTangleIndexDecorator.java
deleted file mode 100644
index 49c365bb7e9..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/FileTangleIndexDecorator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.batch;
-
-import org.sonar.api.measures.CoreMetrics;
-
-public class FileTangleIndexDecorator extends TangleIndexDecorator {
-
- public FileTangleIndexDecorator() {
- super(CoreMetrics.FILE_TANGLES, CoreMetrics.FILE_EDGES_WEIGHT, CoreMetrics.FILE_TANGLE_INDEX);
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName();
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java
deleted file mode 100644
index 49324d7340c..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.batch;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.reflect.TypeToken;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.apache.maven.shared.dependency.tree.filter.AncestorOrSelfDependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.filter.StateDependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.traversal.BuildingDependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.Sensor;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.batch.SonarIndex;
-import org.sonar.api.batch.SupportedEnvironment;
-import org.sonar.api.config.Settings;
-import org.sonar.api.design.Dependency;
-import org.sonar.api.resources.Library;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.utils.SonarException;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-@SupportedEnvironment("maven")
-public class MavenDependenciesSensor implements Sensor {
-
- private static final String SONAR_MAVEN_PROJECT_DEPENDENCY = "sonar.maven.projectDependencies";
-
- private static final Logger LOG = LoggerFactory.getLogger(MavenDependenciesSensor.class);
-
- private ArtifactRepository localRepository;
- private ArtifactFactory artifactFactory;
- private ArtifactMetadataSource artifactMetadataSource;
- private ArtifactCollector artifactCollector;
- private DependencyTreeBuilder treeBuilder;
- private SonarIndex index;
- private Settings settings;
-
- public MavenDependenciesSensor(Settings settings, ArtifactRepository localRepository, ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource,
- ArtifactCollector artifactCollector, DependencyTreeBuilder treeBuilder, SonarIndex index) {
- this.settings = settings;
- this.localRepository = localRepository;
- this.artifactFactory = artifactFactory;
- this.artifactMetadataSource = artifactMetadataSource;
- this.artifactCollector = artifactCollector;
- this.index = index;
- this.treeBuilder = treeBuilder;
- }
-
- /**
- * Used with SQ Maven plugin 2.5+
- */
- public MavenDependenciesSensor(Settings settings, SonarIndex index) {
- this.settings = settings;
- this.index = index;
- }
-
- public boolean shouldExecuteOnProject(Project project) {
- return true;
- }
-
- private static class InputDependency {
-
- private final String key;
-
- private final String version;
-
- private String scope;
-
- List<InputDependency> dependencies = new ArrayList<InputDependency>();
-
- public InputDependency(String key, String version) {
- this.key = key;
- this.version = version;
- }
-
- public String key() {
- return key;
- }
-
- public String version() {
- return version;
- }
-
- public String scope() {
- return scope;
- }
-
- public InputDependency setScope(String scope) {
- this.scope = scope;
- return this;
- }
-
- public List<InputDependency> dependencies() {
- return dependencies;
- }
- }
-
- private static class DependencyDeserializer implements JsonDeserializer<InputDependency> {
-
- @Override
- public InputDependency deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
-
- JsonObject dep = json.getAsJsonObject();
- String key = dep.get("k").getAsString();
- String version = dep.get("v").getAsString();
- InputDependency result = new InputDependency(key, version);
- result.setScope(dep.get("s").getAsString());
- JsonElement subDeps = dep.get("d");
- if (subDeps != null) {
- JsonArray arrayOfSubDeps = subDeps.getAsJsonArray();
- for (JsonElement e : arrayOfSubDeps) {
- result.dependencies().add(deserialize(e, typeOfT, context));
- }
- }
- return result;
- }
-
- }
-
- public void analyse(final Project project, final SensorContext context) {
- if (settings.hasKey(SONAR_MAVEN_PROJECT_DEPENDENCY)) {
- LOG.debug("Using dependency provided by property " + SONAR_MAVEN_PROJECT_DEPENDENCY);
- String depsAsJson = settings.getString(SONAR_MAVEN_PROJECT_DEPENDENCY);
- Collection<InputDependency> deps;
- try {
- GsonBuilder gsonBuilder = new GsonBuilder();
- gsonBuilder.registerTypeAdapter(InputDependency.class, new DependencyDeserializer());
- Gson gson = gsonBuilder.create();
-
- Type collectionType = new TypeToken<Collection<InputDependency>>() {
- }.getType();
- deps = gson.fromJson(depsAsJson, collectionType);
- saveDependencies(project, deps, context);
- } catch (Exception e) {
- throw new IllegalStateException("Unable to deserialize dependency information: " + depsAsJson, e);
- }
- } else if (treeBuilder != null) {
- computeDependencyTree(project, context);
- }
- }
-
- 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() {
- public boolean visit(DependencyNode node) {
- return true;
- }
-
- public boolean endVisit(DependencyNode node) {
- if (node.getParent() != null && node.getParent() != node) {
- saveDependency(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);
- }
- }
-
- private void saveDependencies(Resource from, Collection<InputDependency> deps, SensorContext context) {
- for (InputDependency inputDep : deps) {
- Resource to = toResource(inputDep, context);
- Dependency dependency = new Dependency(from, to);
- dependency.setUsage(inputDep.scope());
- dependency.setWeight(1);
- context.saveDependency(dependency);
- if (!inputDep.dependencies().isEmpty()) {
- saveDependencies(to, inputDep.dependencies(), context);
- }
- }
- }
-
- private Resource toResource(InputDependency dependency, SensorContext context) {
- Project project = new Project(dependency.key());
- Resource result = context.getResource(project);
- if (result == null || !((Project) result).getAnalysisVersion().equals(dependency.version())) {
- Library lib = new Library(project.getKey(), dependency.version());
- context.saveResource(lib);
- result = context.getResource(lib);
- }
- return result;
- }
-
- protected void saveDependency(DependencyNode node, SensorContext context) {
- Resource from = (node.getParent().getParent() == null) ? index.getProject() : toResource(node.getParent().getArtifact(), context);
- Resource to = toResource(node.getArtifact(), context);
- Dependency dependency = new Dependency(from, to);
- dependency.setUsage(node.getArtifact().getScope());
- dependency.setWeight(1);
- context.saveDependency(dependency);
- }
-
- protected static Resource toResource(Artifact artifact, SensorContext context) {
- Project project = Project.createFromMavenIds(artifact.getGroupId(), artifact.getArtifactId());
- Resource result = context.getResource(project);
- if (result == null || !((Project) result).getAnalysisVersion().equals(artifact.getBaseVersion())) {
- Library lib = new Library(project.getKey(), artifact.getBaseVersion());
- context.saveResource(lib);
- result = context.getResource(lib);
- }
- return result;
- }
-
- @Override
- public String toString() {
- return "Maven dependencies";
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/PackageTangleIndexDecorator.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/PackageTangleIndexDecorator.java
deleted file mode 100644
index 50072e3c8dd..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/PackageTangleIndexDecorator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.batch;
-
-import org.sonar.api.measures.CoreMetrics;
-
-public class PackageTangleIndexDecorator extends TangleIndexDecorator {
-
- public PackageTangleIndexDecorator() {
- super(CoreMetrics.PACKAGE_TANGLES, CoreMetrics.PACKAGE_EDGES_WEIGHT, CoreMetrics.PACKAGE_TANGLE_INDEX);
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName();
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/ProjectDsmDecorator.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/ProjectDsmDecorator.java
deleted file mode 100644
index c84a98ebee0..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/ProjectDsmDecorator.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.batch;
-
-import com.google.common.collect.Lists;
-import org.sonar.api.batch.Decorator;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.SonarIndex;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.PersistenceMode;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.ResourceUtils;
-import org.sonar.graph.*;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-/**
- * For performance reasons, this decorator is currently limited to matrix between modules.
- * Squid is optimized for cycle detections (better hashCode and equals methods of SourceCode classes than Resource).
- */
-public class ProjectDsmDecorator implements Decorator {
-
- // hack as long as DecoratorContext does not implement SonarIndex
- private SonarIndex index;
-
- public ProjectDsmDecorator(SonarIndex index) {
- this.index = index;
- }
-
- public boolean shouldExecuteOnProject(Project project) {
- return true;
- }
-
- public void decorate(final Resource resource, DecoratorContext context) {
- if (shouldDecorateResource(resource, context)) {
- Collection<Resource> subProjects = getSubProjects((Project) resource);
-
- if (!subProjects.isEmpty()) {
- Dsm<Resource> dsm = getDsm(subProjects);
- saveDsm(context, dsm);
- }
- }
- }
-
- private void saveDsm(DecoratorContext context, Dsm<Resource> dsm) {
- Measure measure = new Measure(CoreMetrics.DEPENDENCY_MATRIX, DsmSerializer.serialize(dsm));
- measure.setPersistenceMode(PersistenceMode.DATABASE);
- context.saveMeasure(measure);
- }
-
- private Dsm<Resource> getDsm(Collection<Resource> subProjects) {
- CycleDetector<Resource> cycleDetector = new CycleDetector<Resource>(index, subProjects);
- Set<Cycle> cycles = cycleDetector.getCycles();
-
- MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycles);
- Set<Edge> feedbackEdges = solver.getEdges();
-
- Dsm<Resource> dsm = new Dsm<Resource>(index, subProjects, feedbackEdges);
- DsmTopologicalSorter.sort(dsm);
- return dsm;
- }
-
- /**
- * sub-projects, including all descendants but not only direct children
- */
- private Collection<Resource> getSubProjects(final Project project) {
- List<Resource> subProjects = Lists.newArrayList();
- addSubProjects(project, subProjects);
- return subProjects;
- }
-
- private void addSubProjects(Project project, List<Resource> subProjects) {
- for (Project subProject : project.getModules()) {
- Project indexedSubProject = index.getResource(subProject);
- if (indexedSubProject != null) {
- subProjects.add(indexedSubProject);
- }
- addSubProjects(subProject, subProjects);
- }
- }
-
- private boolean shouldDecorateResource(Resource resource, DecoratorContext context) {
- return ResourceUtils.isProject(resource) && context.getMeasure(CoreMetrics.DEPENDENCY_MATRIX) == null;
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/TangleIndexDecorator.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/TangleIndexDecorator.java
deleted file mode 100644
index 8c5c5cead5a..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/TangleIndexDecorator.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.batch;
-
-import org.sonar.api.batch.Decorator;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependedUpon;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-
-import java.util.Arrays;
-import java.util.List;
-
-public abstract class TangleIndexDecorator implements Decorator {
-
- private Metric tanglesMetric;
- private Metric edgesWeightMetric;
- private Metric tangleIndexMetric;
-
- protected TangleIndexDecorator(Metric tanglesMetric, Metric edgesWeightMetric, Metric tangleIndexMetric) {
- this.tanglesMetric = tanglesMetric;
- this.edgesWeightMetric = edgesWeightMetric;
- this.tangleIndexMetric = tangleIndexMetric;
- }
-
- @DependsUpon
- public final List<Metric> dependsUponMetrics() {
- return Arrays.asList(tanglesMetric, edgesWeightMetric);
- }
-
- /**
- * Used to define downstream dependencies
- */
- @DependedUpon
- public final Metric generatesMetric() {
- return tangleIndexMetric;
- }
-
- public final boolean shouldExecuteOnProject(Project project) {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public final void decorate(Resource resource, DecoratorContext context) {
- if (!shouldDecorateResource(context)) {
- return;
- }
- Measure tangles = context.getMeasure(tanglesMetric);
- Measure totalweight = context.getMeasure(edgesWeightMetric);
-
- if (MeasureUtils.hasValue(totalweight)) {
- context.saveMeasure(new Measure(tangleIndexMetric, compute(MeasureUtils.getValue(tangles, 0.0), totalweight.getValue())));
- }
- }
-
- private boolean shouldDecorateResource(DecoratorContext context) {
- return context.getMeasure(tangleIndexMetric) == null;
- }
-
-
- private double compute(double tangles, double totalWeight) {
- if (totalWeight==0.0) {
- return 0.0;
- }
- double result = 2 * tangles / totalWeight;
- return result * 100;
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/FileDesignWidget.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/FileDesignWidget.java
deleted file mode 100644
index 6da07758166..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/FileDesignWidget.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.ui.widgets;
-
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
-import org.sonar.api.web.UserRole;
-import org.sonar.api.web.WidgetCategory;
-
-@UserRole(UserRole.USER)
-@WidgetCategory({ "Design" })
-public final class FileDesignWidget extends AbstractRubyTemplate implements RubyRailsWidget {
-
- public String getId() {
- return "file_design";
- }
-
- public String getTitle() {
- return "File design";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/design/ui/widgets/file_design.html.erb";
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/PackageDesignWidget.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/PackageDesignWidget.java
deleted file mode 100644
index f5d18f61c2f..00000000000
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/PackageDesignWidget.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.ui.widgets;
-
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
-import org.sonar.api.web.UserRole;
-import org.sonar.api.web.WidgetCategory;
-
-@UserRole(UserRole.USER)
-@WidgetCategory({ "Design" })
-public final class PackageDesignWidget extends AbstractRubyTemplate implements RubyRailsWidget {
-
- public String getId() {
- return "package_design";
- }
-
- public String getTitle() {
- return "Package design";
- }
-
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/design/ui/widgets/package_design.html.erb";
- }
-}
diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb
deleted file mode 100644
index 2fcac1fc7a9..00000000000
--- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb
+++ /dev/null
@@ -1,38 +0,0 @@
-<%
- file_tangle_index=measure('file_tangle_index')
- if file_tangle_index
- file_cycles=measure('file_cycles')
- file_feedback_edges=measure('file_feedback_edges')
-%>
-<table width="100%">
- <tbody>
- <tr>
- <td valign="top" width="50%">
- <div class="dashbox">
- <p class="title"><%= message('widget.file_design.file_tangle_index') -%></p>
- <p>
- <span class="big"><%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('file_tangle_index')) -%></span> <%= dashboard_configuration.selected_period? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%>
- </p>
- <% if file_cycles %>
- <p>
- > <%= format_measure(file_cycles, :suffix => message('widget.file_design.cycles.suffix'), :url => url_for_drilldown('file_cycles')) %> <%= dashboard_configuration.selected_period? ? format_variation(file_cycles) : trend_icon(file_cycles) -%>
- </p>
- <% end %>
- </div>
- </td>
- <td valign="top" width="50%">
- <% if file_feedback_edges %>
- <div class="dashbox">
- <p class="title"><%= message('widget.file_design.suspect_file_dependencies') -%></p>
- <p>
- <span class="big"><%= format_measure(file_feedback_edges, :url => url_for_drilldown('file_feedback_edges')) -%></span> <%= dashboard_configuration.selected_period? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%>
- </p>
- </div>
- <% end %>
- </td>
- </tr>
- </tbody>
-</table>
-<%
- end
-%> \ No newline at end of file
diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb
deleted file mode 100644
index 5d9b7a2c796..00000000000
--- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb
+++ /dev/null
@@ -1,61 +0,0 @@
-<%
- package_tangle_index=measure('package_tangle_index')
- if package_tangle_index
- package_cycles=measure('package_cycles')
- package_feedback_edges=measure('package_feedback_edges')
- package_tangles=measure('package_tangles')
-%>
- <div class="widget-row">
- <div class="widget-span widget-span-5">
- <div class="widget-measure-container">
- <div class="widget-measure widget-measure-main">
- <span class="widget-label"><%= message('widget.package_design.package_tangle_index') -%></span>
- <span class="nowrap">
- <%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown(package_tangle_index)) %>
- <%= dashboard_configuration.selected_period? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index) -%>
- </span>
- </div>
-
- <% if package_cycles %>
- <div class="widget-measure">
- <span class="widget-label"><%= message('widget.package_design.cycles.suffix') -%></span>
- <span class="nowrap">
- <span class="widget-medium">&gt;</span>
- <%= format_measure(package_cycles, :default => '-', :url => url_for_drilldown(package_cycles)) %>
- <%= dashboard_configuration.selected_period? ? format_variation(package_cycles) : trend_icon(package_cycles) -%>
- </span>
- </div>
- <% end %>
- </div>
- </div>
-
- <div class="widget-span widget-span-5">
- <div class="widget-measure-container">
- <div class="widget-measure widget-measure-main">
- <span class="widget-label"><%= message('widget.package_design.dependencies_to_cut') -%></span>
- </div>
-
- <% if package_feedback_edges %>
- <div class="widget-measure">
- <span class="widget-label"><%= message('widget.package_design.between_packages.suffix') -%></span>
- <span class="nowrap">
- <%= format_measure(package_feedback_edges, :default => '-', :url => url_for_drilldown(package_feedback_edges)) %>
- <%= dashboard_configuration.selected_period? ? format_variation(package_feedback_edges) : trend_icon(package_feedback_edges) -%>
- </span>
- </div>
- <% end %>
-
- <% if package_tangles %>
- <div class="widget-measure">
- <span class="widget-label"><%= message('widget.package_design.between_files.suffix') -%></span>
- <span class="nowrap">
- <%= format_measure(package_tangles, :default => '-', :url => url_for_drilldown(package_tangles)) %>
- <%= dashboard_configuration.selected_period? ? format_variation(package_tangles) : trend_icon(package_tangles) -%>
- </span>
- </div>
- <% end %>
- </div>
- </div>
- </div>
-
-<% end %> \ No newline at end of file
diff --git a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java
deleted file mode 100644
index 336889f2f81..00000000000
--- a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design;
-
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertThat;
-import org.junit.Test;
-
-public class DesignPluginTest {
-
- @Test
- public void getExtensions() {
- DesignPlugin plugin = new DesignPlugin();
- assertThat(plugin.getExtensions().size(), greaterThan(1));
- }
-}
diff --git a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java
deleted file mode 100644
index 4cff2b11f1b..00000000000
--- a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.batch;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.sonar.api.design.Dependency;
-import org.sonar.api.resources.Directory;
-import org.sonar.api.resources.Resource;
-import org.sonar.graph.DirectedGraph;
-import org.sonar.graph.Dsm;
-import org.sonar.graph.DsmManualSorter;
-import org.sonar.graph.Edge;
-
-import java.io.IOException;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-public class DsmSerializerTest {
- @Test
- public void serializeEmptyDsm() {
- Dsm<Resource> dsm = new Dsm<Resource>(new DirectedGraph<Resource, Edge<Resource>>());
- assertThat(DsmSerializer.serialize(dsm), is("[]"));
- }
-
- @Test
- public void serialize() throws IOException {
- Resource foo = Directory.create("src/org/foo", "org/foo").setId(7);
- Resource bar = Directory.create("src/org/bar", "org/bar").setId(8);
- Dependency dep = new Dependency(foo, bar).setId(30l).setWeight(1);
-
- DirectedGraph<Resource, Dependency> graph = new DirectedGraph<Resource, Dependency>();
- graph.addVertex(foo);
- graph.addVertex(bar);
- graph.addEdge(dep);
-
- Dsm<Resource> dsm = new Dsm<Resource>(graph);
- DsmManualSorter.sort(dsm, bar, foo); // for test reproductibility
- String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json")).trim();
- assertThat(DsmSerializer.serialize(dsm), is(json));
- }
-}
diff --git a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/MavenDependenciesSensorTest.java b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/MavenDependenciesSensorTest.java
deleted file mode 100644
index cf3221d7bf9..00000000000
--- a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/MavenDependenciesSensorTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.design.batch;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.batch.SonarIndex;
-import org.sonar.api.config.Settings;
-import org.sonar.api.design.Dependency;
-import org.sonar.api.resources.Library;
-import org.sonar.api.resources.Project;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class MavenDependenciesSensorTest {
-
- private MavenDependenciesSensor sensor;
- private Settings settings;
- private SonarIndex sonarIndex;
- private SensorContext sensorContext;
-
- @Before
- public void prepare() {
- settings = new Settings();
- sonarIndex = mock(SonarIndex.class);
- sensor = new MavenDependenciesSensor(settings, sonarIndex);
- sensorContext = mock(SensorContext.class);
- when(sensorContext.getResource(any(Library.class))).thenAnswer(new Answer<Library>() {
- public Library answer(InvocationOnMock invocation) throws Throwable {
- return (invocation.getArguments()[0] instanceof Library) ? (Library) invocation.getArguments()[0] : null;
- }
- });
-
- }
-
- @Test
- public void testDependenciesProvidedAsProperties() {
- settings
- .setProperty(
- "sonar.maven.projectDependencies",
- "[{\"k\":\"antlr:antlr\",\"v\":\"2.7.2\",\"s\":\"compile\",\"d\":[]},"
- + "{\"k\":\"commons-beanutils:commons-beanutils\",\"v\":\"1.7.0\",\"s\":\"compile\",\"d\":[]},"
- + "{\"k\":\"commons-chain:commons-chain\",\"v\":\"1.1\",\"s\":\"compile\",\"d\":[]},"
- + "{\"k\":\"commons-digester:commons-digester\",\"v\":\"1.8\",\"s\":\"compile\",\"d\":[]},"
- + "{\"k\":\"commons-fileupload:commons-fileupload\",\"v\":\"1.1.1\",\"s\":\"compile\",\"d\":[{\"k\":\"commons-io:commons-io\",\"v\":\"1.1\",\"s\":\"compile\",\"d\":[]}]},"
- + "{\"k\":\"commons-logging:commons-logging\",\"v\":\"1.0.4\",\"s\":\"compile\",\"d\":[]},"
- + "{\"k\":\"commons-validator:commons-validator\",\"v\":\"1.3.1\",\"s\":\"compile\",\"d\":[]},"
- + "{\"k\":\"javax.servlet:servlet-api\",\"v\":\"2.3\",\"s\":\"provided\",\"d\":[]},"
- + "{\"k\":\"junit:junit\",\"v\":\"3.8.1\",\"s\":\"test\",\"d\":[]},"
- + "{\"k\":\"oro:oro\",\"v\":\"2.0.8\",\"s\":\"compile\",\"d\":[]}]");
-
- Project project = new Project("foo");
- sensor.analyse(project, sensorContext);
-
- Library antlr = new Library("antlr:antlr", "2.7.2");
- verify(sensorContext).saveResource(eq(antlr));
- Library commonsFU = new Library("commons-fileupload:commons-fileupload", "1.1.1");
- verify(sensorContext).saveResource(eq(commonsFU));
- Library commonsIo = new Library("commons-io:commons-io", "1.1");
- verify(sensorContext).saveResource(eq(commonsIo));
- Library junit = new Library("junit:junit", "3.8.1");
- verify(sensorContext).saveResource(eq(junit));
-
- verify(sensorContext).saveDependency(new Dependency(project, antlr).setUsage("compile").setWeight(1));
- verify(sensorContext).saveDependency(new Dependency(commonsFU, commonsIo).setUsage("compile").setWeight(1));
- verify(sensorContext).saveDependency(new Dependency(project, junit).setUsage("test").setWeight(1));
- }
-
-}
diff --git a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json b/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json
deleted file mode 100644
index 57996b089e7..00000000000
--- a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json
+++ /dev/null
@@ -1 +0,0 @@
-[{"i":8,"n":"src/org/bar","q":"DIR","v":[{},{"i":30,"w":1}]},{"i":7,"n":"src/org/foo","q":"DIR","v":[{},{}]}]
diff --git a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/MavenDependenciesSensorTest/getEffectiveLibraries/pom.xml b/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/MavenDependenciesSensorTest/getEffectiveLibraries/pom.xml
deleted file mode 100644
index 1ff8aa38516..00000000000
--- a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/MavenDependenciesSensorTest/getEffectiveLibraries/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>fake.group</groupId>
- <artifactId>fake-artifact</artifactId>
- <version>0.1-SNAPSHOT</version>
- <name>Fake</name>
- <dependencies>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.4</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.7</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project> \ No newline at end of file