aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-application/src/main/assembly/extensions/rules/README.txt1
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java4
-rw-r--r--sonar-server/src/test/java/org/sonar/server/platform/DefaultServerFileSystemTest.java22
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules.jar0
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules.xml0
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules2.jar0
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldNotFailIfNoCheckstyleExtensions/extensions/rules/pmd/pmd.xml0
7 files changed, 26 insertions, 1 deletions
diff --git a/sonar-application/src/main/assembly/extensions/rules/README.txt b/sonar-application/src/main/assembly/extensions/rules/README.txt
deleted file mode 100644
index 763857b8945..00000000000
--- a/sonar-application/src/main/assembly/extensions/rules/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-See http://docs.codehaus.org/display/SONAR/Extending+Coding+Rules
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java b/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
index 1a213f48ec1..64d04967225 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
@@ -176,6 +176,10 @@ public class DefaultServerFileSystem implements ServerFileSystem {
*/
@Deprecated
public List<File> getExtensions(String dirName, String... suffixes) {
+ File dir = new File(getHomeDir(), "extensions/rules/" + dirName);
+ if (dir.exists() && dir.isDirectory()) {
+ return getFiles(dir, suffixes);
+ }
return Collections.emptyList();
}
diff --git a/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerFileSystemTest.java b/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerFileSystemTest.java
index 4ff3be82aba..358d951f464 100644
--- a/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerFileSystemTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerFileSystemTest.java
@@ -20,6 +20,7 @@
package org.sonar.server.platform;
import org.junit.Test;
+import org.sonar.api.platform.ServerFileSystem;
import org.sonar.core.persistence.Database;
import org.sonar.core.persistence.dialect.Dialect;
import org.sonar.core.persistence.dialect.MySql;
@@ -68,6 +69,27 @@ public class DefaultServerFileSystemTest {
assertEquals(0, plugins.size());
}
+ @Test
+ public void shouldFindCheckstyleExtensions() {
+ ServerFileSystem fs = new DefaultServerFileSystem(null, TestUtils.getResource(PATH + "shouldFindCheckstyleExtensions"), null);
+
+ List<File> xmls = fs.getExtensions("checkstyle", "xml");
+ assertEquals(1, xmls.size());
+
+ List<File> all = fs.getExtensions("checkstyle");
+ assertEquals(3, all.size());
+ }
+
+ @Test
+ public void shouldNotFailIfNoCheckstyleExtensions() {
+ ServerFileSystem fs = new DefaultServerFileSystem(null, TestUtils.getResource(PATH + "shouldNotFailIfNoCheckstyleExtensions"), null);
+ List<File> xmls = fs.getExtensions("checkstyle", "xml");
+ assertEquals(0, xmls.size());
+
+ List<File> jars = fs.getExtensions("checkstyle");
+ assertEquals(0, jars.size());
+ }
+
@Test(expected = IllegalStateException.class)
public void shouldFailIfHomeDirectoryNotExists() {
DefaultServerFileSystem fs = new DefaultServerFileSystem(null, new File("/notexists"), null);
diff --git a/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules.jar b/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules.jar
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules.jar
diff --git a/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules.xml b/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules.xml
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules.xml
diff --git a/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules2.jar b/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules2.jar
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldFindCheckstyleExtensions/extensions/rules/checkstyle/my-rules2.jar
diff --git a/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldNotFailIfNoCheckstyleExtensions/extensions/rules/pmd/pmd.xml b/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldNotFailIfNoCheckstyleExtensions/extensions/rules/pmd/pmd.xml
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/sonar-server/src/test/resources/org/sonar/server/platform/DefaultServerFileSystemTest/shouldNotFailIfNoCheckstyleExtensions/extensions/rules/pmd/pmd.xml