aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-06-12 10:40:59 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-06-24 14:34:21 +0200
commit12a57c668bb33f808cdae781a8d9308283c3da05 (patch)
treec728e756797cae6f1e5140450e814c00d9513b0f /sonar-plugin-api
parent20589b0579adb0c86f74aad19962b84b4a8901bd (diff)
downloadsonarqube-12a57c668bb33f808cdae781a8d9308283c3da05.tar.gz
sonarqube-12a57c668bb33f808cdae781a8d9308283c3da05.zip
SONAR-6649 Move initialization of persistit cache to global context
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/ProjectTempFolder.java54
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/TempFolder.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java15
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/JUnitTempFolder.java4
5 files changed, 80 insertions, 3 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
index 4df29867109..88553184e82 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
@@ -467,7 +467,15 @@ public interface CoreProperties {
* @since 4.0
*/
String WORKING_DIRECTORY = "sonar.working.directory";
+
String WORKING_DIRECTORY_DEFAULT_VALUE = ".sonar";
+
+ /**
+ * @since 5.2
+ */
+ String GLOBAL_WORKING_DIRECTORY = "sonar.globalWorking.directory";
+ String GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE = ".";
+
/**
* @since 3.4
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ProjectTempFolder.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ProjectTempFolder.java
new file mode 100644
index 00000000000..276be831528
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ProjectTempFolder.java
@@ -0,0 +1,54 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.api.utils;
+
+import javax.annotation.Nullable;
+
+import java.io.File;
+
+import org.sonar.api.batch.BatchSide;
+
+
+/**
+ * Use this component to deal with temp files/folders that have a scope linked to each
+ * project analysis.
+ * Root location will typically be the working directory (see sonar.working.directory)
+
+ * @since 5.2
+ *
+ */
+@BatchSide
+public interface ProjectTempFolder {
+
+ /**
+ * Create a directory in temp folder with a random unique name.
+ */
+ File newDir();
+
+ /**
+ * Create a directory in temp folder using provided name.
+ */
+ File newDir(String name);
+
+ File newFile();
+
+ File newFile(@Nullable String prefix, @Nullable String suffix);
+
+} \ No newline at end of file
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/TempFolder.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/TempFolder.java
index c456a020fc9..de63fadbfe4 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/TempFolder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/TempFolder.java
@@ -31,7 +31,7 @@ import java.io.File;
* depends on situation:
* <ul>
* <li>${SONAR_HOME}/temp on server side</li>
- * <li>Working directory on batch side (see sonar.working.directory)</li>
+ * <li>${SONAR_HOME}/.sonartmp<rnd> on the batch side</li>
* </ul>
* @since 4.0
*
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java
index c96ecc3e488..86582192407 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java
@@ -19,6 +19,7 @@
*/
package org.sonar.api.utils.internal;
+import org.sonar.api.utils.ProjectTempFolder;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.utils.TempFolder;
@@ -29,15 +30,21 @@ import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
-public class DefaultTempFolder implements TempFolder {
+public class DefaultTempFolder implements TempFolder, ProjectTempFolder {
/** Maximum loop count when creating temp directories. */
private static final int TEMP_DIR_ATTEMPTS = 10000;
private final File tempDir;
+ private final boolean cleanUp;
public DefaultTempFolder(File tempDir) {
+ this(tempDir, false);
+ }
+
+ public DefaultTempFolder(File tempDir, boolean cleanUp) {
this.tempDir = tempDir;
+ this.cleanUp = cleanUp;
}
@Override
@@ -106,4 +113,10 @@ public class DefaultTempFolder implements TempFolder {
FileUtils.deleteQuietly(tempDir);
}
+ public void stop() {
+ if(cleanUp) {
+ clean();
+ }
+ }
+
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/JUnitTempFolder.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/JUnitTempFolder.java
index 3a8c15bf474..e5cda14785f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/JUnitTempFolder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/JUnitTempFolder.java
@@ -19,6 +19,8 @@
*/
package org.sonar.api.utils.internal;
+import org.sonar.api.utils.ProjectTempFolder;
+
import org.apache.commons.lang.StringUtils;
import org.junit.rules.ExternalResource;
import org.junit.rules.TemporaryFolder;
@@ -51,7 +53,7 @@ import java.io.IOException;
*
* @since 5.1
*/
-public class JUnitTempFolder extends ExternalResource implements TempFolder {
+public class JUnitTempFolder extends ExternalResource implements TempFolder, ProjectTempFolder {
private final TemporaryFolder junit = new TemporaryFolder();