aboutsummaryrefslogtreecommitdiffstats
path: root/it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java
diff options
context:
space:
mode:
Diffstat (limited to 'it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java')
-rw-r--r--it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java b/it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java
new file mode 100644
index 00000000000..a8ac1c854e9
--- /dev/null
+++ b/it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java
@@ -0,0 +1,40 @@
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.config.Settings;
+import org.sonar.api.utils.TempFolder;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+@Properties({
+ @Property(
+ key = TempFolderExtension.CREATE_TEMP_FILES,
+ type = PropertyType.BOOLEAN,
+ name = "Property to decide if it should create temp files",
+ defaultValue = "false")
+})
+public class TempFolderExtension implements ServerExtension {
+
+ private static final Logger LOG = Loggers.get(TempFolderExtension.class);
+
+ public static final String CREATE_TEMP_FILES = "sonar.createTempFiles";
+
+ private Settings settings;
+
+ private TempFolder tempFolder;
+
+ public TempFolderExtension(Settings settings, TempFolder tempFolder) {
+ this.settings = settings;
+ this.tempFolder = tempFolder;
+ start();
+ }
+
+ public void start() {
+ if (settings.getBoolean(CREATE_TEMP_FILES)) {
+ LOG.info("Creating temp directory: " + tempFolder.newDir("sonar-it").getAbsolutePath());
+ LOG.info("Creating temp file: " + tempFolder.newFile("sonar-it", ".txt").getAbsolutePath());
+ }
+ }
+
+}