aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-09-05 16:13:54 +0200
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-09-05 16:13:54 +0200
commite76b7521b278dbbbdf9e8bd3c885e55b7132d19d (patch)
tree693844c2e5c8c742ed4ba9690f3cfd7f8e8d649a /src
parent7fb9922dd7e9e97dbdf697d98e1e47ff00f35c5a (diff)
downloadsonar-scanner-cli-e76b7521b278dbbbdf9e8bd3c885e55b7132d19d.tar.gz
sonar-scanner-cli-e76b7521b278dbbbdf9e8bd3c885e55b7132d19d.zip
Refactor and fix violations (again)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/sonar/runner/Main.java5
-rw-r--r--src/main/java/org/sonar/runner/Runner.java12
-rw-r--r--src/main/java/org/sonar/runner/bootstrapper/Bootstrapper.java16
-rw-r--r--src/main/java/org/sonar/runner/model/Launcher.java5
-rw-r--r--src/main/java/org/sonar/runner/utils/SonarRunnerIOUtils.java (renamed from src/main/java/org/sonar/runner/bootstrapper/BootstrapperIOUtils.java)6
-rw-r--r--src/main/java/org/sonar/runner/utils/SonarRunnerVersion.java3
6 files changed, 25 insertions, 22 deletions
diff --git a/src/main/java/org/sonar/runner/Main.java b/src/main/java/org/sonar/runner/Main.java
index 1bfcf7d..12580b7 100644
--- a/src/main/java/org/sonar/runner/Main.java
+++ b/src/main/java/org/sonar/runner/Main.java
@@ -20,10 +20,11 @@
package org.sonar.runner;
+import org.sonar.runner.utils.SonarRunnerIOUtils;
+
import org.sonar.runner.utils.SonarRunnerVersion;
import org.sonar.runner.bootstrapper.BootstrapException;
-import org.sonar.runner.bootstrapper.BootstrapperIOUtils;
import java.io.File;
import java.io.FileInputStream;
@@ -160,7 +161,7 @@ public final class Main {
throw new BootstrapException(e);
} finally {
- BootstrapperIOUtils.closeQuietly(in);
+ SonarRunnerIOUtils.closeQuietly(in);
}
}
diff --git a/src/main/java/org/sonar/runner/Runner.java b/src/main/java/org/sonar/runner/Runner.java
index 0be391f..a24ae84 100644
--- a/src/main/java/org/sonar/runner/Runner.java
+++ b/src/main/java/org/sonar/runner/Runner.java
@@ -19,11 +19,10 @@
*/
package org.sonar.runner;
-import org.sonar.runner.utils.SonarRunnerVersion;
-
import org.sonar.runner.bootstrapper.BootstrapClassLoader;
import org.sonar.runner.bootstrapper.BootstrapException;
import org.sonar.runner.bootstrapper.Bootstrapper;
+import org.sonar.runner.utils.SonarRunnerVersion;
import java.io.File;
import java.lang.reflect.Constructor;
@@ -91,7 +90,7 @@ public final class Runner {
String path = properties.getProperty("project.home", ".");
projectDir = new File(path);
if (!projectDir.isDirectory() || !projectDir.exists()) {
- throw new IllegalArgumentException("Project home must be an existing directory: " + path);
+ throw new RunnerException("Project home must be an existing directory: " + path);
}
// project home exists: add its absolute path as "sonar.runner.projectDir" property
properties.put(PROPERTY_PROJECT_DIR, projectDir.getAbsolutePath());
@@ -101,7 +100,7 @@ public final class Runner {
private File initWorkDir() {
String customWorkDir = properties.getProperty(PROPERTY_WORK_DIRECTORY);
if (customWorkDir == null || customWorkDir.trim().length() == 0) {
- return new File(projectDir, DEF_VALUE_WORK_DIRECTORY);
+ return new File(getProjectDir(), DEF_VALUE_WORK_DIRECTORY);
}
return defineCustomizedWorkDir(new File(customWorkDir));
}
@@ -110,9 +109,12 @@ public final class Runner {
if (customWorkDir.isAbsolute()) {
return customWorkDir;
}
- return new File(projectDir, customWorkDir.getPath());
+ return new File(getProjectDir(), customWorkDir.getPath());
}
+ /**
+ * @return the project base directory
+ */
protected File getProjectDir() {
return projectDir;
}
diff --git a/src/main/java/org/sonar/runner/bootstrapper/Bootstrapper.java b/src/main/java/org/sonar/runner/bootstrapper/Bootstrapper.java
index d033364..8bf7466 100644
--- a/src/main/java/org/sonar/runner/bootstrapper/Bootstrapper.java
+++ b/src/main/java/org/sonar/runner/bootstrapper/Bootstrapper.java
@@ -19,6 +19,8 @@
*/
package org.sonar.runner.bootstrapper;
+import org.sonar.runner.utils.SonarRunnerIOUtils;
+
import org.sonar.runner.utils.SonarRunnerVersion;
import java.io.*;
@@ -108,14 +110,14 @@ public class Bootstrapper {
HttpURLConnection connection = newHttpConnection(new URL(fullUrl));
output = new FileOutputStream(toFile, false);
input = connection.getInputStream();
- BootstrapperIOUtils.copyLarge(input, output);
+ SonarRunnerIOUtils.copyLarge(input, output);
} catch (IOException e) {
- BootstrapperIOUtils.closeQuietly(output);
- BootstrapperIOUtils.deleteFileQuietly(toFile);
+ SonarRunnerIOUtils.closeQuietly(output);
+ SonarRunnerIOUtils.deleteFileQuietly(toFile);
throw new BootstrapException("Fail to download the file: " + fullUrl, e);
} finally {
- BootstrapperIOUtils.closeQuietly(input);
- BootstrapperIOUtils.closeQuietly(output);
+ SonarRunnerIOUtils.closeQuietly(input);
+ SonarRunnerIOUtils.closeQuietly(output);
}
}
@@ -128,9 +130,9 @@ public class Bootstrapper {
if (statusCode != HttpURLConnection.HTTP_OK) {
throw new IOException("Status returned by url : '" + fullUrl + "' is invalid : " + statusCode);
}
- return BootstrapperIOUtils.toString(reader);
+ return SonarRunnerIOUtils.toString(reader);
} finally {
- BootstrapperIOUtils.closeQuietly(reader);
+ SonarRunnerIOUtils.closeQuietly(reader);
conn.disconnect();
}
}
diff --git a/src/main/java/org/sonar/runner/model/Launcher.java b/src/main/java/org/sonar/runner/model/Launcher.java
index 948a6c0..24202a3 100644
--- a/src/main/java/org/sonar/runner/model/Launcher.java
+++ b/src/main/java/org/sonar/runner/model/Launcher.java
@@ -20,9 +20,6 @@
package org.sonar.runner.model;
-import org.sonar.runner.Main;
-import org.sonar.runner.Runner;
-
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
@@ -39,6 +36,8 @@ import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.utils.SonarException;
import org.sonar.batch.Batch;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
+import org.sonar.runner.Main;
+import org.sonar.runner.Runner;
import java.io.File;
import java.io.InputStream;
diff --git a/src/main/java/org/sonar/runner/bootstrapper/BootstrapperIOUtils.java b/src/main/java/org/sonar/runner/utils/SonarRunnerIOUtils.java
index af55370..3fac758 100644
--- a/src/main/java/org/sonar/runner/bootstrapper/BootstrapperIOUtils.java
+++ b/src/main/java/org/sonar/runner/utils/SonarRunnerIOUtils.java
@@ -17,7 +17,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
-package org.sonar.runner.bootstrapper;
+package org.sonar.runner.utils;
import java.io.Closeable;
import java.io.File;
@@ -28,9 +28,9 @@ import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
-public final class BootstrapperIOUtils {
+public final class SonarRunnerIOUtils {
- private BootstrapperIOUtils() {
+ private SonarRunnerIOUtils() {
// only static methods
}
diff --git a/src/main/java/org/sonar/runner/utils/SonarRunnerVersion.java b/src/main/java/org/sonar/runner/utils/SonarRunnerVersion.java
index 12ebbef..12622fa 100644
--- a/src/main/java/org/sonar/runner/utils/SonarRunnerVersion.java
+++ b/src/main/java/org/sonar/runner/utils/SonarRunnerVersion.java
@@ -19,7 +19,6 @@
*/
package org.sonar.runner.utils;
-import org.sonar.runner.bootstrapper.BootstrapperIOUtils;
import java.io.IOException;
import java.io.InputStream;
@@ -48,7 +47,7 @@ public enum SonarRunnerVersion {
this.version = "";
} finally {
- BootstrapperIOUtils.closeQuietly(input);
+ SonarRunnerIOUtils.closeQuietly(input);
}
}
}