diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-01-30 10:19:34 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-01-30 10:19:34 +0100 |
commit | 9f2628c20da0a377f81bdeffdec77691568e23c6 (patch) | |
tree | 743a4527737deeb837fe94afd336d6c8798c6935 | |
parent | 6c62a2c27cc29c9a74a833f2226adbd734c132ff (diff) | |
download | sonar-scanner-cli-9f2628c20da0a377f81bdeffdec77691568e23c6.tar.gz sonar-scanner-cli-9f2628c20da0a377f81bdeffdec77691568e23c6.zip |
SONAR-2291 Implemented cache on Sonar Runner side (for bootstrap JARs).
-rw-r--r-- | api/pom.xml | 95 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/BootstrapClassLoader.java (renamed from src/main/java/org/sonar/runner/BootstrapClassLoader.java) | 2 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/Bootstrapper.java (renamed from src/main/java/org/sonar/runner/Bootstrapper.java) | 101 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/Logs.java (renamed from src/main/java/org/sonar/runner/Logs.java) | 22 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/Main.java (renamed from src/main/java/org/sonar/runner/Main.java) | 17 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/Runner.java (renamed from src/main/java/org/sonar/runner/Runner.java) | 59 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/RunnerException.java (renamed from src/main/java/org/sonar/runner/RunnerException.java) | 2 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/SonarCache.java | 193 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/Stats.java (renamed from src/main/java/org/sonar/runner/Stats.java) | 2 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/Version.java (renamed from src/main/java/org/sonar/runner/Version.java) | 4 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/VersionUtils.java (renamed from src/test/java/org/sonar/runner/IOUtilsTest.java) | 27 | ||||
-rw-r--r-- | api/src/main/java/org/sonar/runner/package-info.java (renamed from src/main/java/org/sonar/runner/package-info.java) | 2 | ||||
-rw-r--r-- | api/src/main/resources/org/sonar/runner/version.txt (renamed from src/main/resources/org/sonar/runner/version.txt) | 0 | ||||
-rw-r--r-- | api/src/test/java/org/sonar/runner/BootstrapClassLoaderTest.java (renamed from src/test/java/org/sonar/runner/BootstrapClassLoaderTest.java) | 2 | ||||
-rw-r--r-- | api/src/test/java/org/sonar/runner/BootstrapperTest.java | 177 | ||||
-rw-r--r-- | api/src/test/java/org/sonar/runner/LogsTest.java (renamed from src/test/java/org/sonar/runner/LogsTest.java) | 7 | ||||
-rw-r--r-- | api/src/test/java/org/sonar/runner/MainTest.java (renamed from src/test/java/org/sonar/runner/MainTest.java) | 2 | ||||
-rw-r--r-- | api/src/test/java/org/sonar/runner/RunnerTest.java (renamed from src/test/java/org/sonar/runner/RunnerTest.java) | 11 | ||||
-rw-r--r-- | api/src/test/java/org/sonar/runner/StatsTest.java (renamed from src/test/java/org/sonar/runner/StatsTest.java) | 2 | ||||
-rw-r--r-- | api/src/test/java/org/sonar/runner/VersionTest.java (renamed from src/test/java/org/sonar/runner/VersionTest.java) | 2 | ||||
-rw-r--r-- | api/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/project/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/project/sonar-project.properties) | 0 | ||||
-rw-r--r-- | api/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/runner/conf/sonar-runner.properties (renamed from src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/runner/conf/sonar-runner.properties) | 0 | ||||
-rw-r--r-- | api/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByDirectPath/other-conf.properties (renamed from src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByDirectPath/other-conf.properties) | 0 | ||||
-rw-r--r-- | api/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByHome/conf/sonar-runner.properties (renamed from src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByHome/conf/sonar-runner.properties) | 0 | ||||
-rw-r--r-- | api/src/test/resources/org/sonar/runner/RunnerTest/shouldInitDirs/fake.txt (renamed from src/test/resources/org/sonar/runner/RunnerTest/shouldInitDirs/fake.txt) | 0 | ||||
-rw-r--r-- | distribution/assembly.xml (renamed from assembly.xml) | 20 | ||||
-rw-r--r-- | distribution/pom.xml | 48 | ||||
-rw-r--r-- | distribution/src/main/assembly/conf/sonar-runner.properties (renamed from src/main/assembly/conf/sonar-runner.properties) | 0 | ||||
-rw-r--r-- | impl/pom.xml | 83 | ||||
-rw-r--r-- | impl/src/main/java/org/sonar/runner/internal/batch/Launcher.java (renamed from src/main/java/org/sonar/runner/internal/batch/Launcher.java) | 5 | ||||
-rw-r--r-- | impl/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java (renamed from src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java) | 2 | ||||
-rw-r--r-- | impl/src/main/java/org/sonar/runner/internal/batch/SonarRunnerUtils.java (renamed from src/main/java/org/sonar/runner/internal/batch/SonarRunnerUtils.java) | 2 | ||||
-rw-r--r-- | impl/src/main/java/org/sonar/runner/internal/batch/package-info.java (renamed from src/main/java/org/sonar/runner/internal/batch/package-info.java) | 2 | ||||
-rw-r--r-- | impl/src/test/java/org/sonar/runner/internal/batch/LauncherTest.java (renamed from src/test/java/org/sonar/runner/internal/batch/LauncherTest.java) | 2 | ||||
-rw-r--r-- | impl/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java (renamed from src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java) | 2 | ||||
-rw-r--r-- | impl/src/test/java/org/sonar/runner/internal/batch/SonarRunnerUtilsTest.java (renamed from src/test/java/org/sonar/runner/internal/batch/SonarRunnerUtilsTest.java) | 2 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/groovy/Fake.groovy (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/groovy/Fake.groovy) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/java/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/java/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module1/sources/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module1/sources/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module2/src/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module2/src/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sources/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sources/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/newBaseDir/src/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/newBaseDir/src/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sources/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sources/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/newBaseDir/src/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/newBaseDir/src/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/modules/module1/sources/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/modules/module1/sources/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/generated/any-file.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/generated/any-file.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/sources/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/sources/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/any-file.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/any-file.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/sources/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/sources/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/module1/src/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/module1/src/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-basedir/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-basedir/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-file/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-file/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/module1/src/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/module1/src/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/exclude.txt (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/exclude.txt) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/include.txt (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/include.txt) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldGetFile/foo.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldGetFile/foo.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib1.txt (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib1.txt) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib2.txt (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib2.txt) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sources/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sources/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-unexisting-source-dir/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-unexisting-source-dir/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib1.txt (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib1.txt) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib2.txt (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib2.txt) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sonar-project.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sonar-project.properties) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sources/Fake.java (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sources/Fake.java) | 0 | ||||
-rw-r--r-- | impl/src/test/resources/org/sonar/runner/internal/batch/SonarRunnerUtilsTest/shouldGetList/foo.properties (renamed from src/test/resources/org/sonar/runner/internal/batch/SonarRunnerUtilsTest/shouldGetList/foo.properties) | 0 | ||||
-rw-r--r-- | pom.xml | 97 | ||||
-rwxr-xr-x | src/main/assembly/bin/sonar-runner | 101 | ||||
-rw-r--r-- | src/main/assembly/bin/sonar-runner.bat | 97 | ||||
-rw-r--r-- | src/main/java/org/sonar/runner/IOUtils.java | 200 | ||||
-rw-r--r-- | src/test/java/org/sonar/runner/BootstrapperTest.java | 66 |
90 files changed, 813 insertions, 645 deletions
diff --git a/api/pom.xml b/api/pom.xml new file mode 100644 index 0000000..7b901f2 --- /dev/null +++ b/api/pom.xml @@ -0,0 +1,95 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.codehaus.sonar-plugins</groupId> + <artifactId>sonar-runner</artifactId> + <version>2.1-SNAPSHOT</version> + </parent> + + <artifactId>sonar-runner-api</artifactId> + <name>Sonar Runner - API</name> + + <dependencies> + <!-- Dependencies will be shaded --> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.2</version> + </dependency> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>1.4</version> + </dependency> + <!-- Unit tests --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.10</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.easytesting</groupId> + <artifactId>fest-assert</artifactId> + <version>1.4</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.9.5</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + </manifest> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.0</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <createDependencyReducedPom>true</createDependencyReducedPom> + <minimizeJar>true</minimizeJar> + <relocations> + <relocation> + <pattern>org.apache.commons.io</pattern> + <shadedPattern>org.sonar.runner.commonsio</shadedPattern> + </relocation> + <relocation> + <pattern>org.apache.commons.codec</pattern> + <shadedPattern>org.sonar.runner.commonscodec</shadedPattern> + </relocation> + </relocations> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/src/main/java/org/sonar/runner/BootstrapClassLoader.java b/api/src/main/java/org/sonar/runner/BootstrapClassLoader.java index 1a492c1..75d2a10 100644 --- a/src/main/java/org/sonar/runner/BootstrapClassLoader.java +++ b/api/src/main/java/org/sonar/runner/BootstrapClassLoader.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/main/java/org/sonar/runner/Bootstrapper.java b/api/src/main/java/org/sonar/runner/Bootstrapper.java index bfe6757..9f482bb 100644 --- a/src/main/java/org/sonar/runner/Bootstrapper.java +++ b/api/src/main/java/org/sonar/runner/Bootstrapper.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * @@ -19,6 +19,9 @@ */ package org.sonar.runner; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -32,6 +35,8 @@ import java.net.URL; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Bootstrapper used to download everything from the server and create the correct classloader required to execute a Sonar analysis in isolation. @@ -40,19 +45,25 @@ class Bootstrapper { static final String VERSION_PATH = "/api/server/version"; static final String BATCH_PATH = "/batch/"; + static final String BOOTSTRAP_INDEX_PATH = "/batch_bootstrap/index"; static final int CONNECT_TIMEOUT_MILLISECONDS = 30000; static final int READ_TIMEOUT_MILLISECONDS = 60000; + private static final Pattern CHARSET_PATTERN = Pattern.compile("(?i)\\bcharset=\\s*\"?([^\\s;\"]*)"); + + private static final String[] UNSUPPORTED_VERSIONS_FOR_CACHE = {"1", "2", "3.0", "3.1", "3.2", "3.3", "3.4"}; private File bootDir; private String serverUrl; private String productToken; private String serverVersion; + private SonarCache cache; /** * @param productToken part of User-Agent request-header field - see http://tools.ietf.org/html/rfc1945#section-10.15 */ - Bootstrapper(String productToken, String serverUrl, File workDir) { + Bootstrapper(String productToken, String serverUrl, File workDir, File cacheLocation) { this.productToken = productToken; + this.cache = SonarCache.create().setCacheLocation(cacheLocation).build(); bootDir = new File(workDir, "batch"); bootDir.mkdirs(); if (serverUrl.endsWith("/")) { @@ -117,6 +128,13 @@ class Bootstrapper { InputStream input = null; FileOutputStream output = null; String fullUrl = serverUrl + path; + if (Logs.isDebugEnabled()) { + Logs.debug("Downloading " + fullUrl + " to " + toFile.getAbsolutePath()); + } + // Don't log for old versions without cache to not pollute logs + else if (!isUnsupportedVersionForCache(getServerVersion())) { + Logs.info("Downloading " + path.substring(path.lastIndexOf("/") + 1)); + } try { HttpURLConnection connection = newHttpConnection(new URL(fullUrl)); output = new FileOutputStream(toFile, false); @@ -124,7 +142,7 @@ class Bootstrapper { IOUtils.copyLarge(input, output); } catch (IOException e) { IOUtils.closeQuietly(output); - IOUtils.deleteQuietly(toFile); + FileUtils.deleteQuietly(toFile); throw new IllegalStateException("Fail to download the file: " + fullUrl, e); } finally { IOUtils.closeQuietly(input); @@ -135,11 +153,11 @@ class Bootstrapper { String remoteContent(String path) throws IOException { String fullUrl = serverUrl + path; HttpURLConnection conn = newHttpConnection(new URL(fullUrl)); - String charset = IOUtils.getCharsetFromContentType(conn.getContentType()); + String charset = getCharsetFromContentType(conn.getContentType()); if (charset == null || "".equals(charset)) { charset = "UTF-8"; } - Reader reader = new InputStreamReader((InputStream) conn.getContent(), charset); + Reader reader = new InputStreamReader(conn.getInputStream(), charset); try { int statusCode = conn.getResponseCode(); if (statusCode != HttpURLConnection.HTTP_OK) { @@ -172,15 +190,78 @@ class Bootstrapper { private List<File> downloadBatchFiles() { try { List<File> files = new ArrayList<File>(); - String libs = remoteContent(BATCH_PATH); - for (String lib : libs.split(",")) { - File file = new File(bootDir, lib); - remoteContentToFile(BATCH_PATH + lib, file); - files.add(file); + if (isUnsupportedVersionForCache(getServerVersion())) { + getBootstrapFilesFromOldURL(files); + } + else { + getBootstrapFiles(files); } return files; } catch (Exception e) { throw new IllegalStateException("Fail to download libraries from server", e); } } + + private void getBootstrapFilesFromOldURL(List<File> files) throws IOException { + String libs = remoteContent(BATCH_PATH); + for (String lib : libs.split(",")) { + File file = new File(bootDir, lib); + remoteContentToFile(BATCH_PATH + lib, file); + files.add(file); + } + } + + private void getBootstrapFiles(List<File> files) throws IOException { + String libs = remoteContent(BOOTSTRAP_INDEX_PATH); + String[] lines = libs.split("[\r\n]+"); + for (String line : lines) { + line = line.trim(); + if ("".equals(line)) { + continue; + } + String[] libAndMd5 = line.split("\\|"); + String libName = libAndMd5[0]; + String remoteMd5 = libAndMd5.length > 0 ? libAndMd5[1] : null; + Logs.debug("Looking if library " + libName + " with md5 " + remoteMd5 + " is already in cache"); + File libInCache = cache.getFileFromCache(libName, remoteMd5); + if (libInCache != null) { + Logs.debug("File is already cached at location " + libInCache.getAbsolutePath()); + } + else { + Logs.debug("File is not cached"); + File tmpLocation = cache.getTemporaryFile(); + remoteContentToFile(BATCH_PATH + libName, tmpLocation); + Logs.debug("Trying to cache file"); + String md5 = cache.cacheFile(tmpLocation, libName); + libInCache = cache.getFileFromCache(libName, md5); + if (!md5.equals(remoteMd5)) { + Logs.warn("INVALID CHECKSUM: File " + libInCache.getAbsolutePath() + " was expected to have checksum " + remoteMd5 + " but was cached with checksum " + md5); + } + Logs.debug("File cached at location " + libInCache.getAbsolutePath()); + } + files.add(libInCache); + } + } + + static boolean isUnsupportedVersionForCache(String version) { + return VersionUtils.isUnsupportedVersion(version, UNSUPPORTED_VERSIONS_FOR_CACHE); + } + + /** + * Parse out a charset from a content type header. + * + * @param contentType e.g. "text/html; charset=EUC-JP" + * @return "EUC-JP", or null if not found. Charset is trimmed and uppercased. + */ + static String getCharsetFromContentType(String contentType) { + if (contentType == null) { + return null; + } + + Matcher m = CHARSET_PATTERN.matcher(contentType); + if (m.find()) { + return m.group(1).trim().toUpperCase(); + } + return null; + } } diff --git a/src/main/java/org/sonar/runner/Logs.java b/api/src/main/java/org/sonar/runner/Logs.java index 2bd24d6..b7da73c 100644 --- a/src/main/java/org/sonar/runner/Logs.java +++ b/api/src/main/java/org/sonar/runner/Logs.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * @@ -23,10 +23,30 @@ final class Logs { private Logs() { } + private static boolean debugEnabled = false; + + public static void setDebugEnabled(boolean debugEnabled) { + Logs.debugEnabled = debugEnabled; + } + + public static boolean isDebugEnabled() { + return debugEnabled; + } + + static void debug(String message) { + if (isDebugEnabled()) { + System.out.println("DEBUG: " + message); + } + } + static void info(String message) { System.out.println("INFO: " + message); } + static void warn(String message) { + System.out.println("WARN: " + message); + } + static void error(String message) { System.err.println("ERROR: " + message); } diff --git a/src/main/java/org/sonar/runner/Main.java b/api/src/main/java/org/sonar/runner/Main.java index add38bf..ef5b908 100644 --- a/src/main/java/org/sonar/runner/Main.java +++ b/api/src/main/java/org/sonar/runner/Main.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * @@ -19,7 +19,7 @@ */ package org.sonar.runner; -import com.google.common.annotations.VisibleForTesting; +import org.apache.commons.io.IOUtils; import java.io.File; import java.io.FileInputStream; @@ -49,17 +49,11 @@ public final class Main { // TODO Remove this after everything is updated to support tasks private static final String TASK_COMMAND = "sonar.task"; - @VisibleForTesting boolean debugMode = false; - @VisibleForTesting boolean displayVersionOnly = false; - @VisibleForTesting boolean displayStackTrace = false; - @VisibleForTesting String command; - @VisibleForTesting Properties globalProperties; - @VisibleForTesting Properties projectProperties; /** @@ -69,7 +63,6 @@ public final class Main { new Main().execute(args); } - @VisibleForTesting Main() { } @@ -156,13 +149,11 @@ public final class Main { Logs.error("Re-run Sonar Runner using the -X switch to enable full debug logging."); } - @VisibleForTesting void loadProperties(Properties argsProperties) { globalProperties = loadGlobalProperties(argsProperties); projectProperties = loadProjectProperties(argsProperties); } - @VisibleForTesting Properties loadGlobalProperties(Properties argsProperties) { Properties commandLineProps = new Properties(); commandLineProps.putAll(System.getProperties()); @@ -175,7 +166,6 @@ public final class Main { return result; } - @VisibleForTesting Properties loadProjectProperties(Properties argsProperties) { Properties commandLineProps = new Properties(); commandLineProps.putAll(System.getProperties()); @@ -195,7 +185,6 @@ public final class Main { return result; } - @VisibleForTesting Properties loadRunnerConfiguration(Properties props) { File settingsFile = locatePropertiesFile(props, RUNNER_HOME, "conf/sonar-runner.properties", RUNNER_SETTINGS); if (settingsFile != null && settingsFile.isFile() && settingsFile.exists()) { @@ -248,7 +237,6 @@ public final class Main { } } - @VisibleForTesting Properties parseArguments(String[] args) { int i = 0; if (args.length > 0 && !args[0].startsWith("-")) { @@ -274,6 +262,7 @@ public final class Main { props.setProperty(Runner.PROPERTY_VERBOSE, "true"); displayStackTrace = true; debugMode = true; + Logs.setDebugEnabled(true); } else if ("-D".equals(arg) || "--define".equals(arg)) { i++; diff --git a/src/main/java/org/sonar/runner/Runner.java b/api/src/main/java/org/sonar/runner/Runner.java index 9d404da..cf488e0 100644 --- a/src/main/java/org/sonar/runner/Runner.java +++ b/api/src/main/java/org/sonar/runner/Runner.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * @@ -19,7 +19,7 @@ */ package org.sonar.runner; -import com.google.common.annotations.VisibleForTesting; +import org.apache.commons.io.FileUtils; import java.io.File; import java.lang.reflect.Constructor; @@ -101,6 +101,13 @@ public final class Runner { public static final String PROPERTY_ENVIRONMENT_INFORMATION_VERSION = "sonar.environment.information.version"; /** + * Property used to define cache location (default to ~/.sonar/.cache). + * + * @since 2.1 + */ + public static final String PROPERTY_CACHE_LOCATION = "sonar.cacheLocation"; + + /** * Array of prefixes of versions of Sonar without support of this runner. */ private static final String[] UNSUPPORTED_VERSIONS = {"1", "2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10"}; @@ -110,6 +117,7 @@ public final class Runner { private String command; private File projectDir; + private File cacheLocation; private File workDir; private String[] unmaskedPackages; private List<Object> containerExtensions = new ArrayList<Object>(); @@ -171,7 +179,7 @@ public final class Runner { * Runs a Sonar analysis. */ public void execute() { - Bootstrapper bootstrapper = new Bootstrapper("SonarRunner/" + Version.getVersion(), getSonarServerURL(), getWorkDir()); + Bootstrapper bootstrapper = new Bootstrapper("SonarRunner/" + Version.getVersion(), getSonarServerURL(), getWorkDir(), cacheLocation); checkSonarVersion(bootstrapper); delegateExecution(createClassLoader(bootstrapper)); } @@ -181,14 +189,28 @@ public final class Runner { } private void initDirs() { - String path = projectProperties.getProperty(PROPERTY_SONAR_PROJECT_BASEDIR, "."); - projectDir = new File(path); - if (!projectDir.isDirectory()) { - throw new RunnerException("Project home must be an existing directory: " + path); - } + projectDir = initProjectDir(); // project home exists: add its absolute path as "sonar.projectBaseDir" property projectProperties.put(PROPERTY_SONAR_PROJECT_BASEDIR, projectDir.getAbsolutePath()); workDir = initWorkDir(); + cacheLocation = initCacheLocation(); + } + + private File initCacheLocation() { + String path = projectProperties.getProperty(PROPERTY_CACHE_LOCATION); + if (path != null) { + return new File(path); + } + return null; + } + + private File initProjectDir() { + String path = projectProperties.getProperty(PROPERTY_SONAR_PROJECT_BASEDIR, "."); + File dir = new File(path); + if (!dir.isDirectory()) { + throw new RunnerException("Project home must be an existing directory: " + path); + } + return dir; } private File initWorkDir() { @@ -200,7 +222,7 @@ public final class Runner { else { newWorkDir = defineCustomizedWorkDir(new File(customWorkDir)); } - IOUtils.deleteQuietly(newWorkDir); + FileUtils.deleteQuietly(newWorkDir); return newWorkDir; } @@ -246,7 +268,6 @@ public final class Runner { /** * @return global properties, project properties and command-line properties */ - @VisibleForTesting public Properties getProperties() { Properties props = new Properties(); props.putAll(globalProperties); @@ -305,25 +326,11 @@ public final class Runner { } static boolean isUnsupportedVersion(String version) { - for (String unsupportedVersion : UNSUPPORTED_VERSIONS) { - if (isVersion(version, unsupportedVersion)) { - return true; - } - } - return false; + return VersionUtils.isUnsupportedVersion(version, UNSUPPORTED_VERSIONS); } static boolean isUnsupportedVersionForTasks(String version) { - for (String unsupportedVersion : UNSUPPORTED_VERSIONS_FOR_TASKS) { - if (isVersion(version, unsupportedVersion)) { - return true; - } - } - return false; - } - - static boolean isVersion(String version, String prefix) { - return version.startsWith(prefix + ".") || version.equals(prefix); + return VersionUtils.isUnsupportedVersion(version, UNSUPPORTED_VERSIONS_FOR_TASKS); } private void delegateExecution(BootstrapClassLoader sonarClassLoader) { diff --git a/src/main/java/org/sonar/runner/RunnerException.java b/api/src/main/java/org/sonar/runner/RunnerException.java index 27ffffb..a676f57 100644 --- a/src/main/java/org/sonar/runner/RunnerException.java +++ b/api/src/main/java/org/sonar/runner/RunnerException.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/api/src/main/java/org/sonar/runner/SonarCache.java b/api/src/main/java/org/sonar/runner/SonarCache.java new file mode 100644 index 0000000..deb954b --- /dev/null +++ b/api/src/main/java/org/sonar/runner/SonarCache.java @@ -0,0 +1,193 @@ +/* + * Sonar Runner - API + * Copyright (C) 2011 SonarSource + * dev@sonar.codehaus.org + * + * This program 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. + * + * This program 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 02 + */ +package org.sonar.runner; + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +/** + * This class is responsible for managing Sonar batch file cache. You can put file into cache and + * later try to retrieve them. MD5 is used to differentiate files (name is not secure as files may come + * from different Sonar servers and have same name but be actually different, and same for SNAPSHOTs). + * Default location of cache is + * @author Julien HENRY + * + */ +public class SonarCache { + + private static final int TEMP_FILE_ATTEMPTS = 10000; + + private File cacheLocation; + /** + * Temporary directory where files should be stored before be inserted in the cache. + * Having a temporary close to the final location (read on same FS) will assure + * the move will be atomic. + */ + private File tmpDir; + + private SonarCache(File cacheLocation) { + this.cacheLocation = cacheLocation; + tmpDir = new File(cacheLocation, ".tmp"); + if (!cacheLocation.exists()) { + Logs.debug("Creating cache directory: " + cacheLocation.getAbsolutePath()); + try { + FileUtils.forceMkdir(cacheLocation); + } catch (IOException e) { + throw new RuntimeException("Unable to create cache directory " + cacheLocation.getAbsolutePath(), e); + } + } + } + + public static class Builder { + + private File cacheLocation; + + public Builder setCacheLocation(File cacheLocation) { + this.cacheLocation = cacheLocation; + return this; + } + + public SonarCache build() { + if (cacheLocation == null) { + File sonarHome = new File(System.getProperty("user.home"), ".sonar"); + return new SonarCache(new File(sonarHome, ".cache")); + } + else { + return new SonarCache(cacheLocation); + } + } + + } + + public static Builder create() { + return new Builder(); + } + + /** + * Move the given file inside the cache. Return the MD5 of the cached file. + * @param sourceFile + * @throws IOException + */ + public String cacheFile(File sourceFile, String filename) throws IOException { + File tmpFileName = null; + try { + if (!sourceFile.getParentFile().equals(getTmpDir())) { + // Provided file is not close to the cache so we will move it first in a temporary file (could be non atomic) + tmpFileName = getTemporaryFile(); + FileUtils.moveFile(sourceFile, tmpFileName); + } + else { + tmpFileName = sourceFile; + } + // Now compute the md5 to find the final destination + String md5; + FileInputStream fis = null; + try { + fis = new FileInputStream(tmpFileName); + md5 = DigestUtils.md5Hex(fis); + } finally { + IOUtils.closeQuietly(fis); + } + File finalDir = new File(cacheLocation, md5); + File finalFileName = new File(finalDir, filename); + // Try to create final destination folder + FileUtils.forceMkdir(finalDir); + // Now try to move the file from temporary folder to final location + boolean rename = tmpFileName.renameTo(finalFileName); + if (!rename) { + // Check if the file was already in cache + if (!finalFileName.exists()) { + Logs.warn("Unable to rename " + tmpFileName.getAbsolutePath() + " to " + finalFileName.getAbsolutePath()); + Logs.warn("A copy/delete will be tempted but with no garantee of atomicity"); + FileUtils.moveFile(tmpFileName, finalFileName); + } + } + return md5; + } finally { + FileUtils.deleteQuietly(tmpFileName); + } + + } + + /** + * Look for a file in the cache by its filename and md5 checksum. If the file is not + * present then return null. + */ + public File getFileFromCache(String filename, String md5) { + File location = new File(new File(cacheLocation, md5), filename); + if (location.exists()) { + return location; + } + Logs.debug("No file found in the cache with name " + filename + " and checksum " + md5); + return null; + } + + /** + * Return a temporary file that caller can use to store file content before + * asking for caching it with {@link #cacheFile(File)}. + * This is to avoid extra copy. + * @return + * @throws IOException + */ + public File getTemporaryFile() throws IOException { + return createTempFile(getTmpDir()); + } + + /** + * Create a temporary file in the given directory. + * @param baseDir + * @return + * @throws IOException + */ + private static File createTempFile(File baseDir) throws IOException { + String baseName = System.currentTimeMillis() + "-"; + + for (int counter = 0; counter < TEMP_FILE_ATTEMPTS; counter++) { + File tempFile = new File(baseDir, baseName + counter); + if (tempFile.createNewFile()) { + return tempFile; + } + } + throw new IOException("Failed to create temporary file in " + baseDir.getAbsolutePath() + " within " + + TEMP_FILE_ATTEMPTS + " attempts (tried " + + baseName + "0 to " + baseName + (TEMP_FILE_ATTEMPTS - 1) + ')'); + } + + public File getTmpDir() { + if (!tmpDir.exists()) { + Logs.debug("Creating temporary cache directory: " + tmpDir.getAbsolutePath()); + try { + FileUtils.forceMkdir(tmpDir); + } catch (IOException e) { + throw new RuntimeException("Unable to create temporary cache directory " + tmpDir.getAbsolutePath(), e); + } + } + return tmpDir; + } + + public File getCacheLocation() { + return cacheLocation; + } +} diff --git a/src/main/java/org/sonar/runner/Stats.java b/api/src/main/java/org/sonar/runner/Stats.java index fdec553..b5ce8d5 100644 --- a/src/main/java/org/sonar/runner/Stats.java +++ b/api/src/main/java/org/sonar/runner/Stats.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/main/java/org/sonar/runner/Version.java b/api/src/main/java/org/sonar/runner/Version.java index 313d727..e0447c0 100644 --- a/src/main/java/org/sonar/runner/Version.java +++ b/api/src/main/java/org/sonar/runner/Version.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * @@ -19,6 +19,8 @@ */ package org.sonar.runner; +import org.apache.commons.io.IOUtils; + import java.io.IOException; import java.io.InputStream; import java.util.Properties; diff --git a/src/test/java/org/sonar/runner/IOUtilsTest.java b/api/src/main/java/org/sonar/runner/VersionUtils.java index d7ff4d6..3e19df8 100644 --- a/src/test/java/org/sonar/runner/IOUtilsTest.java +++ b/api/src/main/java/org/sonar/runner/VersionUtils.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * @@ -19,16 +19,27 @@ */ package org.sonar.runner; -import org.junit.Test; +/** + * Internal class used only by the Runner. + * This class should not be used by Sonar Runner consumers. + */ +final class VersionUtils { -import static org.fest.assertions.Assertions.assertThat; + private VersionUtils() { + // only static methods + } -public class IOUtilsTest { + static boolean isUnsupportedVersion(String version, String[] unsuportedVersions) { + for (String unsupportedVersion : unsuportedVersions) { + if (isVersion(version, unsupportedVersion)) { + return true; + } + } + return false; + } - @Test - public void shouldParseEncodingFromContentType() { - assertThat(IOUtils.getCharsetFromContentType("text/html; charset=EUC-JP")).isEqualTo("EUC-JP"); - assertThat(IOUtils.getCharsetFromContentType("text/html")).isNull(); + private static boolean isVersion(String version, String prefix) { + return version.startsWith(prefix + ".") || version.equals(prefix); } } diff --git a/src/main/java/org/sonar/runner/package-info.java b/api/src/main/java/org/sonar/runner/package-info.java index 62e80e2..e837d88 100644 --- a/src/main/java/org/sonar/runner/package-info.java +++ b/api/src/main/java/org/sonar/runner/package-info.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/main/resources/org/sonar/runner/version.txt b/api/src/main/resources/org/sonar/runner/version.txt index defbd48..defbd48 100644 --- a/src/main/resources/org/sonar/runner/version.txt +++ b/api/src/main/resources/org/sonar/runner/version.txt diff --git a/src/test/java/org/sonar/runner/BootstrapClassLoaderTest.java b/api/src/test/java/org/sonar/runner/BootstrapClassLoaderTest.java index 9b59b55..7917d2d 100644 --- a/src/test/java/org/sonar/runner/BootstrapClassLoaderTest.java +++ b/api/src/test/java/org/sonar/runner/BootstrapClassLoaderTest.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/api/src/test/java/org/sonar/runner/BootstrapperTest.java b/api/src/test/java/org/sonar/runner/BootstrapperTest.java new file mode 100644 index 0000000..933a460 --- /dev/null +++ b/api/src/test/java/org/sonar/runner/BootstrapperTest.java @@ -0,0 +1,177 @@ +/* + * Sonar Runner - API + * Copyright (C) 2011 SonarSource + * dev@sonar.codehaus.org + * + * This program 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. + * + * This program 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 02 + */ +package org.sonar.runner; + +import org.apache.commons.io.IOUtils; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import static org.fest.assertions.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class BootstrapperTest { + + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + @Test + public void shouldRemoveLastUrlSlash() { + Bootstrapper bootstrapper = new Bootstrapper("", "http://test/", new File("target/tmp"), null); + assertThat(bootstrapper.getServerUrl()).isEqualTo("http://test"); + } + + @Test(expected = Exception.class) + public void shouldFailIfCanNotConnectServer() { + Bootstrapper bootstrapper = new Bootstrapper("", "http://unknown.foo", new File("target/tmp"), null); + bootstrapper.getServerVersion(); + } + + @Test + public void shouldReturnUserAgent() { + Bootstrapper bootstrapper = new Bootstrapper("test/0.1", "http://unknown.foo", new File("target/tmp"), null); + String userAgent = bootstrapper.getUserAgent(); + + assertThat(userAgent.length()).isGreaterThan(0); + assertThat(userAgent).startsWith("sonar-bootstrapper/"); + assertThat(userAgent).endsWith(" test/0.1"); + } + + @Test + public void shouldReturnValidVersion() { + Bootstrapper bootstrapper = new Bootstrapper("", "http://test", new File("target/tmp"), null) { + @Override + String remoteContent(String path) throws IOException { + return "2.6"; + } + }; + assertThat(bootstrapper.getServerVersion()).isEqualTo("2.6"); + } + + @Test + public void shouldParseEncodingFromContentType() { + assertThat(Bootstrapper.getCharsetFromContentType("text/html; charset=EUC-JP")).isEqualTo("EUC-JP"); + assertThat(Bootstrapper.getCharsetFromContentType("text/html")).isNull(); + } + + @Test + public void shouldCheckVersionForCache() { + assertThat(Bootstrapper.isUnsupportedVersionForCache("1.0")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("2.0")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("2.1")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("2.2")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("2.3")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("2.4")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("2.4.1")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("2.5")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("2.11")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("3.0")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("3.1")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("3.2")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("3.3")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("3.4")).isTrue(); + assertThat(Bootstrapper.isUnsupportedVersionForCache("3.5")).isFalse(); + } + + @Test + public void shouldCacheWhenNecessary() throws Exception { + File cacheLocation = tempFolder.newFolder(); + final MockedConnectionFactory connections = new MockedConnectionFactory("http://test"); + connections.register("/api/server/version", "3.5"); + connections.register("/batch_bootstrap/index", "foo.jar|922afef30ca31573d7131347d01b76c4\nbar.jar|69155f65900fbabbf21e28abb33dd06a"); + connections.register("/batch/foo.jar", "fakecontent1"); + connections.register("/batch/bar.jar", "fakecontent2"); + Bootstrapper bootstrapper = new Bootstrapper("", "http://test", new File("target/tmp"), cacheLocation) { + @Override + HttpURLConnection newHttpConnection(URL url) throws IOException { + return connections.get(url); + } + }; + bootstrapper.createClassLoader(new URL[] {}, this.getClass().getClassLoader()); + assertThat(new File(new File(cacheLocation, "922afef30ca31573d7131347d01b76c4"), "foo.jar")).exists(); + assertThat(new File(new File(cacheLocation, "69155f65900fbabbf21e28abb33dd06a"), "bar.jar")).exists(); + + // Should not download during the second execution + final MockedConnectionFactory connections2 = new MockedConnectionFactory("http://test"); + connections2.register("/api/server/version", "3.5"); + connections2.register("/batch_bootstrap/index", "foo.jar|922afef30ca31573d7131347d01b76c4\nbar.jar|69155f65900fbabbf21e28abb33dd06a"); + Bootstrapper bootstrapper2 = new Bootstrapper("", "http://test", new File("target/tmp"), cacheLocation) { + @Override + HttpURLConnection newHttpConnection(URL url) throws IOException { + return connections2.get(url); + } + }; + bootstrapper2.createClassLoader(new URL[] {}, this.getClass().getClassLoader()); + } + + @Test + public void shouldDownloadFromOldURL() throws Exception { + File cacheLocation = tempFolder.newFolder(); + final MockedConnectionFactory connections = new MockedConnectionFactory("http://test"); + connections.register("/api/server/version", "3.4"); + connections.register("/batch/", "foo.jar,bar.jar"); + connections.register("/batch/foo.jar", "fakecontent1"); + connections.register("/batch/bar.jar", "fakecontent2"); + Bootstrapper bootstrapper = new Bootstrapper("", "http://test", new File("target/tmp"), cacheLocation) { + @Override + HttpURLConnection newHttpConnection(URL url) throws IOException { + return connections.get(url); + } + }; + bootstrapper.createClassLoader(new URL[] {}, this.getClass().getClassLoader()); + verify(connections.get("/batch/foo.jar")).getInputStream(); + verify(connections.get("/batch/bar.jar")).getInputStream(); + } + + private class MockedConnectionFactory { + private Map<URL, HttpURLConnection> mockedConnections = new HashMap<URL, HttpURLConnection>(); + private String serverUrl; + + public MockedConnectionFactory(String serverUrl) { + this.serverUrl = serverUrl; + } + + public void register(String path, String content) throws Exception { + HttpURLConnection mockConnection = mock(HttpURLConnection.class); + when(mockConnection.getInputStream()).thenReturn(IOUtils.toInputStream(content)); + when(mockConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); + mockedConnections.put(new URL(serverUrl + path), mockConnection); + } + + public HttpURLConnection get(URL url) { + return mockedConnections.get(url); + } + + public HttpURLConnection get(String path) throws MalformedURLException { + return mockedConnections.get(new URL(serverUrl + path)); + } + + } +} diff --git a/src/test/java/org/sonar/runner/LogsTest.java b/api/src/test/java/org/sonar/runner/LogsTest.java index 19ce1cf..1131300 100644 --- a/src/test/java/org/sonar/runner/LogsTest.java +++ b/api/src/test/java/org/sonar/runner/LogsTest.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * @@ -22,7 +22,6 @@ package org.sonar.runner; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.sonar.api.utils.SonarException; import java.io.ByteArrayOutputStream; import java.io.PrintStream; @@ -76,9 +75,9 @@ public class LogsTest { @Test public void shouldLogErrorWithThrowable() { - Logs.error("error", new SonarException()); + Logs.error("error", new RuntimeException()); assertThat(baosOut.toString()).isEmpty(); - assertThat(baosErr.toString()).contains("ERROR: error").contains("SonarException"); + assertThat(baosErr.toString()).contains("ERROR: error").contains("RuntimeException"); } } diff --git a/src/test/java/org/sonar/runner/MainTest.java b/api/src/test/java/org/sonar/runner/MainTest.java index a915857..de7f17c 100644 --- a/src/test/java/org/sonar/runner/MainTest.java +++ b/api/src/test/java/org/sonar/runner/MainTest.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/test/java/org/sonar/runner/RunnerTest.java b/api/src/test/java/org/sonar/runner/RunnerTest.java index d3e89de..e02f55d 100644 --- a/src/test/java/org/sonar/runner/RunnerTest.java +++ b/api/src/test/java/org/sonar/runner/RunnerTest.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * @@ -22,7 +22,7 @@ package org.sonar.runner; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.test.TestUtils; +import org.junit.rules.TemporaryFolder; import java.io.File; import java.nio.charset.Charset; @@ -35,6 +35,9 @@ import static org.mockito.Mockito.when; public class RunnerTest { @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + @Rule public ExpectedException thrown = ExpectedException.none(); @Test @@ -120,7 +123,7 @@ public class RunnerTest { @Test public void shouldInitDirs() throws Exception { Properties props = new Properties(); - File home = TestUtils.getResource(this.getClass(), "shouldInitDirs"); + File home = tempFolder.newFolder("shouldInitDirs"); props.setProperty(Runner.PROPERTY_SONAR_PROJECT_BASEDIR, home.getCanonicalPath()); Runner runner = Runner.create(props); assertThat(runner.getProperties().get(Runner.PROPERTY_SONAR_PROJECT_BASEDIR)).isEqualTo(home.getCanonicalPath()); @@ -139,7 +142,7 @@ public class RunnerTest { @Test public void shouldSetValidBaseDirOnConstructor() { - File baseDir = TestUtils.getResource(this.getClass(), "shouldInitDirs"); + File baseDir = tempFolder.newFolder("shouldInitDirs"); Runner runner = Runner.create(new Properties(), baseDir); assertThat(runner.getProjectDir()).isEqualTo(baseDir); } diff --git a/src/test/java/org/sonar/runner/StatsTest.java b/api/src/test/java/org/sonar/runner/StatsTest.java index 2df6426..7ea5d84 100644 --- a/src/test/java/org/sonar/runner/StatsTest.java +++ b/api/src/test/java/org/sonar/runner/StatsTest.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/test/java/org/sonar/runner/VersionTest.java b/api/src/test/java/org/sonar/runner/VersionTest.java index 1ca1470..2280195 100644 --- a/src/test/java/org/sonar/runner/VersionTest.java +++ b/api/src/test/java/org/sonar/runner/VersionTest.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - API * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/project/sonar-project.properties b/api/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/project/sonar-project.properties index 0d1e025..0d1e025 100644 --- a/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/project/sonar-project.properties +++ b/api/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/project/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/runner/conf/sonar-runner.properties b/api/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/runner/conf/sonar-runner.properties index 7edfb99..7edfb99 100644 --- a/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/runner/conf/sonar-runner.properties +++ b/api/src/test/resources/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/runner/conf/sonar-runner.properties diff --git a/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByDirectPath/other-conf.properties b/api/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByDirectPath/other-conf.properties index 740a616..740a616 100644 --- a/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByDirectPath/other-conf.properties +++ b/api/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByDirectPath/other-conf.properties diff --git a/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByHome/conf/sonar-runner.properties b/api/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByHome/conf/sonar-runner.properties index e7d5c09..e7d5c09 100644 --- a/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByHome/conf/sonar-runner.properties +++ b/api/src/test/resources/org/sonar/runner/MainTest/shouldLoadRunnerSettingsByHome/conf/sonar-runner.properties diff --git a/src/test/resources/org/sonar/runner/RunnerTest/shouldInitDirs/fake.txt b/api/src/test/resources/org/sonar/runner/RunnerTest/shouldInitDirs/fake.txt index f0f877c..f0f877c 100644 --- a/src/test/resources/org/sonar/runner/RunnerTest/shouldInitDirs/fake.txt +++ b/api/src/test/resources/org/sonar/runner/RunnerTest/shouldInitDirs/fake.txt diff --git a/assembly.xml b/distribution/assembly.xml index 947fe6f..2a85a1d 100644 --- a/assembly.xml +++ b/distribution/assembly.xml @@ -7,13 +7,19 @@ <format>zip</format> </formats> <includeBaseDirectory>true</includeBaseDirectory> - <dependencySets> - <dependencySet> - <useProjectArtifact>true</useProjectArtifact> - <outputDirectory>lib</outputDirectory> - <fileMode>0644</fileMode> - </dependencySet> - </dependencySets> + <moduleSets> + <moduleSet> + <!-- Enable access to all projects in the current multimodule build! --> + <useAllReactorProjects>true</useAllReactorProjects> + <includes> + <include>org.codehaus.sonar-plugins:sonar-runner-impl</include> + </includes> + <binaries> + <outputDirectory>lib</outputDirectory> + <unpack>false</unpack> + </binaries> + </moduleSet> + </moduleSets> <fileSets> <fileSet> <directory>src/main/assembly/bin</directory> diff --git a/distribution/pom.xml b/distribution/pom.xml new file mode 100644 index 0000000..5847a29 --- /dev/null +++ b/distribution/pom.xml @@ -0,0 +1,48 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.codehaus.sonar-plugins</groupId> + <artifactId>sonar-runner</artifactId> + <version>2.1-SNAPSHOT</version> + </parent> + + <artifactId>sonar-runner-dist</artifactId> + <version>2.1-SNAPSHOT</version> + <packaging>pom</packaging> + <name>Sonar Runner - Distribution</name> + + <dependencies> + <dependency> + <groupId>org.codehaus.sonar-plugins</groupId> + <artifactId>sonar-runner-impl</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <!-- SONARPLUGINS-2573 --> + <version>2.4</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <escapeString>\</escapeString> + <descriptors> + <descriptor>${basedir}/assembly.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> + diff --git a/src/main/assembly/conf/sonar-runner.properties b/distribution/src/main/assembly/conf/sonar-runner.properties index 5744269..5744269 100644 --- a/src/main/assembly/conf/sonar-runner.properties +++ b/distribution/src/main/assembly/conf/sonar-runner.properties diff --git a/impl/pom.xml b/impl/pom.xml new file mode 100644 index 0000000..132da9e --- /dev/null +++ b/impl/pom.xml @@ -0,0 +1,83 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.codehaus.sonar-plugins</groupId> + <artifactId>sonar-runner</artifactId> + <version>2.1-SNAPSHOT</version> + </parent> + + <artifactId>sonar-runner-impl</artifactId> + <name>Sonar Runner - Implementation</name> + + <dependencies> + <!-- Would be available after bootstrapping so scope = provided --> + <dependency> + <groupId>org.codehaus.sonar-plugins</groupId> + <artifactId>sonar-runner-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>0.9.15</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-batch</artifactId> + <version>${sonar.buildVersion}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-plugin-api</artifactId> + <version>${sonar.buildVersion}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <artifactId>commons-configuration</artifactId> + <groupId>commons-configuration</groupId> + </exclusion> + </exclusions> + </dependency> + <!-- Unit tests --> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-testing-harness</artifactId> + <version>${sonar.buildVersion}</version> + <scope>test</scope> + <exclusions> + <exclusion> + <artifactId>commons-configuration</artifactId> + <groupId>commons-configuration</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.easytesting</groupId> + <artifactId>fest-assert</artifactId> + <version>1.4</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.0</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/src/main/java/org/sonar/runner/internal/batch/Launcher.java b/impl/src/main/java/org/sonar/runner/internal/batch/Launcher.java index 1aebbd9..6b9d996 100644 --- a/src/main/java/org/sonar/runner/internal/batch/Launcher.java +++ b/impl/src/main/java/org/sonar/runner/internal/batch/Launcher.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - Implementation * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * @@ -132,7 +132,8 @@ public class Launcher { @VisibleForTesting protected boolean isDebug() { - return Boolean.parseBoolean(projectProperties.getProperty(Runner.PROPERTY_VERBOSE, projectProperties.getProperty(Runner.PROPERTY_OLD_DEBUG_MODE, "false"))); + return Boolean.parseBoolean(projectProperties.getProperty(Runner.PROPERTY_VERBOSE, + projectProperties.getProperty(Runner.PROPERTY_OLD_DEBUG_MODE, "false"))); } @VisibleForTesting diff --git a/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java b/impl/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java index 84b8788..af471ce 100644 --- a/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java +++ b/impl/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - Implementation * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/main/java/org/sonar/runner/internal/batch/SonarRunnerUtils.java b/impl/src/main/java/org/sonar/runner/internal/batch/SonarRunnerUtils.java index 64cd3b3..8aa8582 100644 --- a/src/main/java/org/sonar/runner/internal/batch/SonarRunnerUtils.java +++ b/impl/src/main/java/org/sonar/runner/internal/batch/SonarRunnerUtils.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - Implementation * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/main/java/org/sonar/runner/internal/batch/package-info.java b/impl/src/main/java/org/sonar/runner/internal/batch/package-info.java index b06feba..43e1aea 100644 --- a/src/main/java/org/sonar/runner/internal/batch/package-info.java +++ b/impl/src/main/java/org/sonar/runner/internal/batch/package-info.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - Implementation * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/test/java/org/sonar/runner/internal/batch/LauncherTest.java b/impl/src/test/java/org/sonar/runner/internal/batch/LauncherTest.java index b06ba86..b97f6ba 100644 --- a/src/test/java/org/sonar/runner/internal/batch/LauncherTest.java +++ b/impl/src/test/java/org/sonar/runner/internal/batch/LauncherTest.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - Implementation * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java b/impl/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java index 4cb65ab..b9be31f 100644 --- a/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java +++ b/impl/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - Implementation * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/test/java/org/sonar/runner/internal/batch/SonarRunnerUtilsTest.java b/impl/src/test/java/org/sonar/runner/internal/batch/SonarRunnerUtilsTest.java index db00f63..ec00baa 100644 --- a/src/test/java/org/sonar/runner/internal/batch/SonarRunnerUtilsTest.java +++ b/impl/src/test/java/org/sonar/runner/internal/batch/SonarRunnerUtilsTest.java @@ -1,5 +1,5 @@ /* - * Sonar Runner + * Sonar Runner - Implementation * Copyright (C) 2011 SonarSource * dev@sonar.codehaus.org * diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties index 53aacb5..53aacb5 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/groovy/Fake.groovy b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/groovy/Fake.groovy index e69de29..e69de29 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/groovy/Fake.groovy +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/groovy/Fake.groovy diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/java/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/java/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/java/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-language-definitions-all-in-root/src/main/java/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module1/sources/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module1/sources/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module1/sources/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module1/sources/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module2/src/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module2/src/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module2/src/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/module2/src/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/sonar-project.properties index 0f06d31..0f06d31 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-all-in-root/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sonar-project.properties index 7bace22..7bace22 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sources/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sources/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sources/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module1/sources/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/newBaseDir/src/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/newBaseDir/src/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/newBaseDir/src/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/newBaseDir/src/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/sonar-project.properties index d25a9e9..d25a9e9 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/module2/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/sonar-project.properties index 4744284..4744284 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module-inherited/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sonar-project.properties index 0138e27..0138e27 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sources/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sources/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sources/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module1/sources/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/newBaseDir/src/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/newBaseDir/src/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/newBaseDir/src/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/newBaseDir/src/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/sonar-project.properties index d25a9e9..d25a9e9 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/module2/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/sonar-project.properties index df58736..df58736 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-definitions-in-each-module/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/modules/module1/sources/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/modules/module1/sources/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/modules/module1/sources/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/modules/module1/sources/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/sonar-project.properties index 615f5c7..615f5c7 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-basedir/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/generated/any-file.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/generated/any-file.properties index c50d50b..c50d50b 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/generated/any-file.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/generated/any-file.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/sources/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/sources/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/sources/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/any-folder/sources/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/sonar-project.properties index c1640b1..c1640b1 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile-and-overwritten-basedir/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/any-file.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/any-file.properties index 460d349..460d349 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/any-file.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/any-file.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/sources/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/sources/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/sources/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/any-folder/sources/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/sonar-project.properties index e246f8c..e246f8c 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-configfile/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java index e69de29..e69de29 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/module1/src/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties index 8007363..8007363 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-binary-dir/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java index e69de29..e69de29 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/module1/src/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties index d97a18b..d97a18b 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-lib/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/module1/src/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/module1/src/Fake.java index e69de29..e69de29 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/module1/src/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/module1/src/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/sonar-project.properties index 09cb220..09cb220 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-explicit-unexisting-test-dir/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-basedir/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-basedir/sonar-project.properties index 67fbf34..67fbf34 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-basedir/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-basedir/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-file/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-file/sonar-project.properties index e246f8c..e246f8c 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-file/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-file/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/module1/src/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/module1/src/Fake.java index e69de29..e69de29 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/module1/src/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/module1/src/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/sonar-project.properties index 04ea08a..04ea08a 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-source-dir/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java index e69de29..e69de29 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/module1/src/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties index 59b68b3..59b68b3 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/multi-module-with-unexisting-test-bin-lib-dir/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/exclude.txt b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/exclude.txt index e69de29..e69de29 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/exclude.txt +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/exclude.txt diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/include.txt b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/include.txt index e69de29..e69de29 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/include.txt +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldFilterFiles/include.txt diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldGetFile/foo.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldGetFile/foo.properties index 8fbb104..8fbb104 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldGetFile/foo.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/shouldGetFile/foo.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib1.txt b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib1.txt index 81d4e95..81d4e95 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib1.txt +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib1.txt diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib2.txt b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib2.txt index 7dacac0..7dacac0 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib2.txt +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/libs/lib2.txt diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sonar-project.properties index acf3c83..acf3c83 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sources/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sources/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sources/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-deprecated-props/sources/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-unexisting-source-dir/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-unexisting-source-dir/sonar-project.properties index 0b83b11..0b83b11 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-unexisting-source-dir/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project-with-unexisting-source-dir/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib1.txt b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib1.txt index 81d4e95..81d4e95 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib1.txt +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib1.txt diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib2.txt b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib2.txt index 7dacac0..7dacac0 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib2.txt +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/libs/lib2.txt diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sonar-project.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sonar-project.properties index ea8a1b5..ea8a1b5 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sonar-project.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sonar-project.properties diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sources/Fake.java b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sources/Fake.java index 5967658..5967658 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sources/Fake.java +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarProjectBuilderTest/simple-project/sources/Fake.java diff --git a/src/test/resources/org/sonar/runner/internal/batch/SonarRunnerUtilsTest/shouldGetList/foo.properties b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarRunnerUtilsTest/shouldGetList/foo.properties index 8fbb104..8fbb104 100644 --- a/src/test/resources/org/sonar/runner/internal/batch/SonarRunnerUtilsTest/shouldGetList/foo.properties +++ b/impl/src/test/resources/org/sonar/runner/internal/batch/SonarRunnerUtilsTest/shouldGetList/foo.properties @@ -8,7 +8,14 @@ <artifactId>sonar-runner</artifactId> <version>2.1-SNAPSHOT</version> + <packaging>pom</packaging> <name>Sonar Runner</name> + + <modules> + <module>api</module> + <module>impl</module> + <module>distribution</module> + </modules> <url>http://docs.codehaus.org/display/SONAR/Sonar+Standalone+Runner</url> <inceptionYear>2011</inceptionYear> @@ -64,94 +71,4 @@ <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile> </properties> - <dependencies> - <!-- Would be available after bootstrapping --> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>0.9.15</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-batch</artifactId> - <version>${sonar.buildVersion}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-plugin-api</artifactId> - <version>${sonar.buildVersion}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <artifactId>commons-configuration</artifactId> - <groupId>commons-configuration</groupId> - </exclusion> - </exclusions> - </dependency> - <!-- Unit tests --> - <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-testing-harness</artifactId> - <version>${sonar.buildVersion}</version> - <scope>test</scope> - <exclusions> - <exclusion> - <artifactId>commons-configuration</artifactId> - <groupId>commons-configuration</groupId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.easytesting</groupId> - <artifactId>fest-assert</artifactId> - <version>1.4</version> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <resources> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - </resource> - </resources> - - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifest> - <addClasspath>true</addClasspath> - </manifest> - </archive> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <!-- SONARPLUGINS-2573 --> - <version>2.4</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <appendAssemblyId>false</appendAssemblyId> - <escapeString>\</escapeString> - <descriptors> - <descriptor>${basedir}/assembly.xml</descriptor> - </descriptors> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> </project> diff --git a/src/main/assembly/bin/sonar-runner b/src/main/assembly/bin/sonar-runner deleted file mode 100755 index 5470ee0..0000000 --- a/src/main/assembly/bin/sonar-runner +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh -# -# Sonar Runner Startup Script for Unix -# -# Optional ENV vars: -# SONAR_RUNNER_HOME - location of runner's installed home dir -# SONAR_RUNNER_OPTS - parameters passed to the Java VM when running Sonar - -# The following notice only apply to real_path function copied from -# https://sites.google.com/site/jdisnard/realpath -# Copyright 2010 Jon Disnard. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are -# permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list -# of conditions and the following disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY Jon Disnard ``AS IS'' AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are those of the -# authors and should not be interpreted as representing official policies, either expressed -# or implied, of Jon Disnard. -real_path () { - OIFS=$IFS - IFS='/' - for I in $1 - do - # Resolve relative path punctuation. - if [ "$I" = "." ] || [ -z "$I" ] - then continue - elif [ "$I" = ".." ] - then FOO="${FOO%%/${FOO##*/}}" - continue - else FOO="${FOO}/${I}" - fi - - # Dereference symbolic links. - if [ -h "$FOO" ] && [ -x "/bin/ls" ] - then IFS=$OIFS - set `/bin/ls -l "$FOO"` - while shift ; - do - if [ "$1" = "->" ] - then FOO=$2 - shift $# - break - fi - done - fi - done - IFS=$OIFS - echo "$FOO" -} - -if [ -z "$SONAR_RUNNER_HOME" ] ; then - PRG="$0" - - # resolve symlinks - PRG=`real_path "$PRG"` - - SONAR_RUNNER_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - SONAR_RUNNER_HOME=`cd "$SONAR_RUNNER_HOME" && pwd` -fi - -# check that the SONAR_RUNNER_HOME has been correctly set -if [ ! -e "$SONAR_RUNNER_HOME/lib/sonar-runner-${project.version}.jar" ] ; then - echo '$SONAR_RUNNER_HOME' does not point to a valid installation directory: $SONAR_RUNNER_HOME - exit 1 -fi - -JAVA_CMD="`which java`" -JAVA_CLASSPATH="${SONAR_RUNNER_HOME}"/lib/sonar-runner-${project.version}.jar -PROJECT_HOME=`pwd` - -#echo "Info: Using sonar-runner at $SONAR_RUNNER_HOME" -#echo "Info: Using java at $JAVA_CMD" -#echo "Info: Using classpath $JAVA_CLASSPATH" -#echo "Info: Using project $PROJECT_HOME" - -exec "$JAVA_CMD" \ - $SONAR_RUNNER_OPTS \ - -classpath $JAVA_CLASSPATH \ - "-Drunner.home=\${SONAR_RUNNER_HOME}" \ - "-Dproject.home=\${PROJECT_HOME}" \ - org.sonar.runner.Main "$@" - diff --git a/src/main/assembly/bin/sonar-runner.bat b/src/main/assembly/bin/sonar-runner.bat deleted file mode 100644 index 3b444e6..0000000 --- a/src/main/assembly/bin/sonar-runner.bat +++ /dev/null @@ -1,97 +0,0 @@ -@REM Sonar Runner Startup Script for Windows -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars: -@REM SONAR_RUNNER_HOME - location of runner's installed home dir -@REM SONAR_RUNNER_OPTS - parameters passed to the Java VM when running Sonar - -@echo off - -set ERROR_CODE=0 - -@REM set local scope for the variables with windows NT shell -@setlocal - -@REM ==== START VALIDATION ==== -@REM *** JAVA EXEC VALIDATION *** -if not "%JAVA_HOME%" == "" goto foundJavaHome - -for %%i in (java.exe) do set JAVA_EXEC=%%~$PATH:i - -if not "%JAVA_EXEC%" == "" ( - set JAVA_EXEC="%JAVA_EXEC%" - goto OkJava -) - -if not "%JAVA_EXEC%" == "" goto OkJava - -echo. -echo ERROR: JAVA_HOME not found in your environment, and no Java -echo executable present in the PATH. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation, or add "java.exe" to the PATH -echo. -goto error - -:foundJavaHome -if EXIST "%JAVA_HOME%\bin\java.exe" goto foundJavaExeFromJavaHome - -echo. -echo ERROR: JAVA_HOME exists but does not point to a valid Java home -echo folder. No "\bin\java.exe" file can be found there. -echo. -goto error - -:foundJavaExeFromJavaHome -set JAVA_EXEC="%JAVA_HOME%\bin\java.exe" - -@REM *** SONAR RUNNER HOME VALIDATION *** -:OkJava -if NOT "%SONAR_RUNNER_HOME%"=="" goto cleanSonarRunnerHome -set SONAR_RUNNER_HOME=%~dp0.. -goto run - -:cleanSonarRunnerHome -@REM If the property has a trailing backslash, remove it -if %SONAR_RUNNER_HOME:~-1%==\ set SONAR_RUNNER_HOME=%SONAR_RUNNER_HOME:~0,-1% - -@REM Check if the provided SONAR_RUNNER_HOME is a valid install dir -IF EXIST "%SONAR_RUNNER_HOME%\lib\sonar-runner-${project.version}.jar" goto run - -echo. -echo ERROR: SONAR_RUNNER_HOME exists but does not point to a valid install -echo directory: %SONAR_RUNNER_HOME% -echo. -goto error - - - -@REM ==== START RUN ==== -:run -echo %SONAR_RUNNER_HOME% - -set PROJECT_HOME=%CD% - -%JAVA_EXEC% %SONAR_RUNNER_OPTS% -classpath "%SONAR_RUNNER_HOME%\lib\sonar-runner-${project.version}.jar" "-Drunner.home=%SONAR_RUNNER_HOME%" "-Dproject.home=%PROJECT_HOME%" org.sonar.runner.Main %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -@REM ==== END EXECUTION ==== - -:end -@REM set local scope for the variables with windows NT shell -@endlocal & set ERROR_CODE=%ERROR_CODE% - -@REM see http://code-bear.com/bearlog/2007/06/01/getting-the-exit-code-from-a-batch-file-that-is-run-from-a-python-program/ -goto exit - -:returncode -exit /B %1 - -:exit -call :returncode %ERROR_CODE% diff --git a/src/main/java/org/sonar/runner/IOUtils.java b/src/main/java/org/sonar/runner/IOUtils.java deleted file mode 100644 index 248d18d..0000000 --- a/src/main/java/org/sonar/runner/IOUtils.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Sonar Runner - * Copyright (C) 2011 SonarSource - * dev@sonar.codehaus.org - * - * This program 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. - * - * This program 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 02 - */ -package org.sonar.runner; - -import java.io.Closeable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Internal class used only by the Runner as we don't want it to depend on third-party libs. - * This class should not be used by Sonar Runner consumers. - */ -final class IOUtils { - - private IOUtils() { - // only static methods - } - - /** - * The default buffer size to use. - */ - private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; - - private static final Pattern CHARSET_PATTERN = Pattern.compile("(?i)\\bcharset=\\s*\"?([^\\s;\"]*)"); - - /** - * Unconditionally close a <code>Closeable</code>. - */ - static void closeQuietly(Closeable closeable) { - try { - if (closeable != null) { - closeable.close(); - } - } catch (IOException ioe) { - } - } - - /** - * Get the contents of a <code>Reader</code> as a String. - */ - static String toString(Reader input) throws IOException { - StringWriter sw = new StringWriter(); - copyLarge(input, sw); - return sw.toString(); - } - - /** - * Copy bytes from an <code>InputStream</code> to an <code>OutputStream</code>. - */ - static long copyLarge(InputStream input, OutputStream output) throws IOException { - byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; - long count = 0; - int n = 0; - while (-1 != (n = input.read(buffer))) { - output.write(buffer, 0, n); - count += n; - } - return count; - } - - /** - * Copy chars from a <code>Reader</code> to a <code>Writer</code>. - */ - static long copyLarge(Reader input, Writer output) throws IOException { - char[] buffer = new char[DEFAULT_BUFFER_SIZE]; - long count = 0; - int n = 0; - while (-1 != (n = input.read(buffer))) { - output.write(buffer, 0, n); - count += n; - } - return count; - } - - /** - * Duplicated from Commons IO - */ - static boolean deleteQuietly(File file) { - if (file == null) { - return false; - } - try { - if (file.isDirectory()) { - cleanDirectory(file); - } - } catch (Exception ignored) { - } - - try { - return file.delete(); - } catch (Exception ignored) { - return false; - } - } - - private static void cleanDirectory(File directory) throws IOException { - if (!directory.exists()) { - String message = directory + " does not exist"; - throw new IllegalArgumentException(message); - } - - if (!directory.isDirectory()) { - String message = directory + " is not a directory"; - throw new IllegalArgumentException(message); - } - - File[] files = directory.listFiles(); - // null if security restricted - if (files == null) { - throw new IOException("Failed to list contents of " + directory); - } - - IOException exception = null; - for (File file : files) { - try { - forceDelete(file); - } catch (IOException ioe) { - exception = ioe; - } - } - - if (null != exception) { - throw exception; - } - } - - private static void forceDelete(File file) throws IOException { - if (file.isDirectory()) { - deleteDirectory(file); - } else { - boolean filePresent = file.exists(); - if (!file.delete()) { - if (!filePresent) { - throw new FileNotFoundException("File does not exist: " + file); - } - String message = - "Unable to delete file: " + file; - throw new IOException(message); - } - } - } - - private static void deleteDirectory(File directory) throws IOException { - if (!directory.exists()) { - return; - } - - cleanDirectory(directory); - - if (!directory.delete()) { - String message = - "Unable to delete directory " + directory + "."; - throw new IOException(message); - } - } - - /** - * Parse out a charset from a content type header. - * - * @param contentType e.g. "text/html; charset=EUC-JP" - * @return "EUC-JP", or null if not found. Charset is trimmed and uppercased. - */ - static String getCharsetFromContentType(String contentType) { - if (contentType == null) { - return null; - } - - Matcher m = CHARSET_PATTERN.matcher(contentType); - if (m.find()) { - return m.group(1).trim().toUpperCase(); - } - return null; - } - -} diff --git a/src/test/java/org/sonar/runner/BootstrapperTest.java b/src/test/java/org/sonar/runner/BootstrapperTest.java deleted file mode 100644 index 448858c..0000000 --- a/src/test/java/org/sonar/runner/BootstrapperTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Sonar Runner - * Copyright (C) 2011 SonarSource - * dev@sonar.codehaus.org - * - * This program 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. - * - * This program 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 02 - */ -package org.sonar.runner; - -import org.sonar.runner.Bootstrapper; - -import org.junit.Test; - -import java.io.File; -import java.io.IOException; - -import static org.fest.assertions.Assertions.assertThat; - -public class BootstrapperTest { - - @Test - public void shouldRemoveLastUrlSlash() { - Bootstrapper bootstrapper = new Bootstrapper("", "http://test/", new File("target")); - assertThat(bootstrapper.getServerUrl()).isEqualTo("http://test"); - } - - @Test(expected = Exception.class) - public void shouldFailIfCanNotConnectServer() { - Bootstrapper bootstrapper = new Bootstrapper("", "http://unknown.foo", new File("target")); - bootstrapper.getServerVersion(); - } - - @Test - public void shouldReturnUserAgent() { - Bootstrapper bootstrapper = new Bootstrapper("test/0.1", "http://unknown.foo", new File("target")); - String userAgent = bootstrapper.getUserAgent(); - - assertThat(userAgent.length()).isGreaterThan(0); - assertThat(userAgent).startsWith("sonar-bootstrapper/"); - assertThat(userAgent).endsWith(" test/0.1"); - } - - @Test - public void shouldReturnValidVersion() { - Bootstrapper bootstrapper = new Bootstrapper("", "http://test", new File("target")) { - @Override - String remoteContent(String path) throws IOException { - return "2.6"; - } - }; - assertThat(bootstrapper.getServerVersion()).isEqualTo("2.6"); - } - -} |