diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-01-27 21:20:09 +0300 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-01-28 11:27:41 +0300 |
commit | 5c05c7d812a97fd6ab07b5ae7449f5e95d0f6546 (patch) | |
tree | 2d088123a1faaa64179822d14ccc0fa807a12763 /plugins | |
parent | c2f90c84e3fef821bfdee686351375a2732ac06e (diff) | |
download | sonarqube-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 'plugins')
4 files changed, 23 insertions, 11 deletions
diff --git a/plugins/sonar-clover-plugin/pom.xml b/plugins/sonar-clover-plugin/pom.xml index 463e3b47601..972298145e6 100644 --- a/plugins/sonar-clover-plugin/pom.xml +++ b/plugins/sonar-clover-plugin/pom.xml @@ -52,6 +52,11 @@ <artifactId>sonar-plugin-api</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-java-api</artifactId> + <version>${project.version}</version> + </dependency> <!-- TODO http://jira.codehaus.org/browse/SONAR-2011 We need following dependency, otherwise we will receive compilation error diff --git a/plugins/sonar-clover-plugin/src/main/java/org/sonar/plugins/clover/CloverMavenPluginHandler.java b/plugins/sonar-clover-plugin/src/main/java/org/sonar/plugins/clover/CloverMavenPluginHandler.java index 09b1893bfbe..bd1db7af013 100644 --- a/plugins/sonar-clover-plugin/src/main/java/org/sonar/plugins/clover/CloverMavenPluginHandler.java +++ b/plugins/sonar-clover-plugin/src/main/java/org/sonar/plugins/clover/CloverMavenPluginHandler.java @@ -27,7 +27,7 @@ import org.sonar.api.batch.maven.MavenPlugin; import org.sonar.api.batch.maven.MavenPluginHandler; import org.sonar.api.batch.maven.MavenSurefireUtils; import org.sonar.api.resources.Project; -import org.sonar.api.resources.ProjectUtils; +import org.sonar.java.api.JavaUtils; import java.io.File; import java.io.IOException; @@ -58,7 +58,7 @@ public class CloverMavenPluginHandler implements MavenPluginHandler { } public String[] getGoals() { - return new String[]{"instrument", "clover"}; + return new String[] { "instrument", "clover" }; } public void configure(Project project, MavenPlugin cloverPlugin) { @@ -75,13 +75,14 @@ public class CloverMavenPluginHandler implements MavenPluginHandler { skipCloverLaunch = StringUtils.isNotBlank(skipInPomConfig) ? Boolean.parseBoolean(skipInPomConfig) : false; } if (!project.getConfiguration().containsKey(CoreProperties.SUREFIRE_REPORTS_PATH_PROPERTY) && !skipCloverLaunch) { - project.getConfiguration().setProperty(CoreProperties.SUREFIRE_REPORTS_PATH_PROPERTY, new File(project.getFileSystem().getBuildDir(), "clover/surefire-reports").getAbsolutePath()); + project.getConfiguration().setProperty(CoreProperties.SUREFIRE_REPORTS_PATH_PROPERTY, + new File(project.getFileSystem().getBuildDir(), "clover/surefire-reports").getAbsolutePath()); } } protected void configureParameters(Project project, MavenPlugin cloverPlugin) { cloverPlugin.setParameter("generateXml", "true"); - String javaVersion = ProjectUtils.getJavaVersion(project); + String javaVersion = JavaUtils.getTargetVersion(project); if (javaVersion != null) { cloverPlugin.setParameter("jdk", javaVersion); } @@ -101,7 +102,8 @@ public class CloverMavenPluginHandler implements MavenPluginHandler { } private boolean hasLicense(MavenPlugin cloverPlugin) { - return StringUtils.isNotBlank(cloverPlugin.getParameter("license")) || StringUtils.isNotBlank(cloverPlugin.getParameter("licenseLocation")); + return StringUtils.isNotBlank(cloverPlugin.getParameter("license")) + || StringUtils.isNotBlank(cloverPlugin.getParameter("licenseLocation")); } private File writeLicenseToDisk(Project project, String license) { diff --git a/plugins/sonar-pmd-plugin/pom.xml b/plugins/sonar-pmd-plugin/pom.xml index 6e32d6c4a01..b296abe8230 100644 --- a/plugins/sonar-pmd-plugin/pom.xml +++ b/plugins/sonar-pmd-plugin/pom.xml @@ -25,6 +25,11 @@ </dependency> <dependency> <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-java-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.sonar</groupId> <artifactId>sonar-plugin-api</artifactId> <version>${project.version}</version> </dependency> diff --git a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java index ea55bee3499..d68e61ddddd 100644 --- a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java +++ b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java @@ -29,8 +29,8 @@ import org.slf4j.LoggerFactory; import org.sonar.api.BatchExtension; import org.sonar.api.resources.Java; import org.sonar.api.resources.Project; -import org.sonar.api.resources.ProjectUtils; import org.sonar.api.utils.TimeProfiler; +import org.sonar.java.api.JavaUtils; import java.io.*; import java.util.List; @@ -60,17 +60,17 @@ public class PmdExecutor implements BatchExtension { ruleContext.setReport(report); RuleSets rulesets = createRulesets(); - + for (File file : project.getFileSystem().getSourceFiles(Java.INSTANCE)) { ruleContext.setSourceCodeFilename(file.getAbsolutePath()); Reader fileReader = new InputStreamReader(new FileInputStream(file), project.getFileSystem().getSourceCharset()); try { pmd.processFile(fileReader, rulesets, ruleContext); - - } catch(PMDException e) { + + } catch (PMDException e) { LOG.error("Fail to execute PMD. Following file is ignored: " + file, e.getCause()); - } catch(Exception e) { + } catch (Exception e) { LOG.error("Fail to execute PMD. Following file is ignored: " + file, e); } finally { @@ -143,7 +143,7 @@ public class PmdExecutor implements BatchExtension { } private void setJavaVersion(PMD pmd, Project project) { - String javaVersion = ProjectUtils.getJavaSourceVersion(project); + String javaVersion = JavaUtils.getSourceVersion(project); if (StringUtils.isNotBlank(javaVersion)) { if ("1.1".equals(javaVersion) || "1.2".equals(javaVersion)) { javaVersion = "1.3"; |