aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-java-api
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-01-27 21:20:09 +0300
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-01-28 11:27:41 +0300
commit5c05c7d812a97fd6ab07b5ae7449f5e95d0f6546 (patch)
tree2d088123a1faaa64179822d14ccc0fa807a12763 /sonar-java-api
parentc2f90c84e3fef821bfdee686351375a2732ac06e (diff)
downloadsonarqube-5c05c7d812a97fd6ab07b5ae7449f5e95d0f6546.tar.gz
sonarqube-5c05c7d812a97fd6ab07b5ae7449f5e95d0f6546.zip
SONAR-2148: Add new properties to manage level of Java language
* Use sonar-java-api in sonar-pmd-plugin and sonar-clover-plugin
Diffstat (limited to 'sonar-java-api')
-rw-r--r--sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java b/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java
index 9fa234f5626..26ee5d17425 100644
--- a/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java
+++ b/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java
@@ -20,7 +20,11 @@
package org.sonar.java.api;
import org.apache.commons.lang.StringUtils;
+import org.sonar.api.resources.Project;
+/**
+ * @since 2.6
+ */
public final class JavaUtils {
public static final String PACKAGE_SEPARATOR = ".";
@@ -37,6 +41,16 @@ public final class JavaUtils {
*/
public static final String BARRIER_AFTER_SQUID = "squid";
+ /**
+ * To determine value of this property use {@link #getSourceVersion(Project)}.
+ */
+ public static final String JAVA_SOURCE_PROPERTY = "sonar.java.source";
+
+ /**
+ * To determine value of this property use {@link #getTargetVersion(Project)}.
+ */
+ public static final String JAVA_TARGET_PROPERTY = "sonar.java.target";
+
private JavaUtils() {
// only static methods
}
@@ -44,12 +58,20 @@ public final class JavaUtils {
public static String abbreviatePackage(String packageName) {
String[] parts = StringUtils.split(packageName, PACKAGE_SEPARATOR);
StringBuilder sb = new StringBuilder();
- if (parts.length>=1) {
+ if (parts.length >= 1) {
sb.append(parts[0]);
}
- for (int index=1 ; index<parts.length ; index++) {
+ for (int index = 1; index < parts.length; index++) {
sb.append(PACKAGE_SEPARATOR).append(parts[index].charAt(0));
}
return sb.toString();
}
-} \ No newline at end of file
+
+ public static String getSourceVersion(Project project) {
+ return project.getConfiguration().getString(JAVA_SOURCE_PROPERTY);
+ }
+
+ public static String getTargetVersion(Project project) {
+ return project.getConfiguration().getString(JAVA_TARGET_PROPERTY);
+ }
+}