diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-05 01:47:19 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-05 01:47:19 +0400 |
commit | fbbb9f83cca5dd1f47b1e1e696b2031394285bce (patch) | |
tree | 507db1761394ce5cb78da2615388cbc26f0cb542 /plugins | |
parent | 18ad773901849708d42042552339dd713e40ad65 (diff) | |
download | sonarqube-fbbb9f83cca5dd1f47b1e1e696b2031394285bce.tar.gz sonarqube-fbbb9f83cca5dd1f47b1e1e696b2031394285bce.zip |
SONAR-2332 Findbugs plugin must remove temporary files created during execution
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java index 2898de20b90..f55f637bf4b 100644 --- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java +++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java @@ -19,12 +19,6 @@ */ package org.sonar.plugins.findbugs; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.StringWriter; - import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; @@ -38,6 +32,8 @@ import org.sonar.plugins.findbugs.xml.ClassFilter; import org.sonar.plugins.findbugs.xml.FindBugsFilter; import org.sonar.plugins.findbugs.xml.Match; +import java.io.*; + /** * @since 2.4 */ @@ -75,12 +71,12 @@ public class FindbugsConfiguration implements BatchExtension { } findbugsProject.addFile(classesDir.getAbsolutePath()); for (File file : projectClasspath.getElements()) { - if ( !file.equals(classesDir)) { + if (!file.equals(classesDir)) { findbugsProject.addAuxClasspathEntry(file.getAbsolutePath()); } } - findbugsProject.addAuxClasspathEntry(copyLib("/annotations-" + FindbugsVersion.getVersion() + ".jar").getAbsolutePath()); - findbugsProject.addAuxClasspathEntry(copyLib("/jsr305-" + FindbugsVersion.getVersion() + ".jar").getAbsolutePath()); + findbugsProject.addAuxClasspathEntry(annotationsLib.getAbsolutePath()); + findbugsProject.addAuxClasspathEntry(jsr305Lib.getAbsolutePath()); findbugsProject.setCurrentWorkingDirectory(project.getFileSystem().getBuildDir()); return findbugsProject; } @@ -111,11 +107,29 @@ public class FindbugsConfiguration implements BatchExtension { return project.getConfiguration().getLong(CoreProperties.FINDBUGS_TIMEOUT_PROPERTY, CoreProperties.FINDBUGS_TIMEOUT_DEFAULT_VALUE); } + private File jsr305Lib; + private File annotationsLib; + + /** + * Invoked by PicoContainer to extract additional FindBugs libraries into temporary files. + */ + public void start() { + jsr305Lib = copyLib("/jsr305-" + FindbugsVersion.getVersion() + ".jar"); + annotationsLib = copyLib("/annotations-" + FindbugsVersion.getVersion() + ".jar"); + } + + /** + * Invoked by PicoContainer to remove temporary files. + */ + public void stop() { + jsr305Lib.delete(); + annotationsLib.delete(); + } + private File copyLib(String name) { try { InputStream is = getClass().getResourceAsStream(name); File temp = File.createTempFile("findbugs", ".jar"); - FileUtils.forceDeleteOnExit(temp); OutputStream os = FileUtils.openOutputStream(temp); IOUtils.copy(is, os); return temp; |