From: Julien HENRY Date: Tue, 19 Jan 2016 08:54:46 +0000 (+0100) Subject: Cut dependency between sonar-server and sonar-home X-Git-Tag: 5.4-M9~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7c875ec6e08cbd09f1965a882fd0190f695d1526;p=sonarqube.git Cut dependency between sonar-server and sonar-home --- diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml index 9cdec318a9c..e03b5d89805 100644 --- a/server/sonar-server/pom.xml +++ b/server/sonar-server/pom.xml @@ -71,10 +71,6 @@ ${project.groupId} sonar-batch-protocol - - ${project.groupId} - sonar-home - ${project.groupId} sonar-markdown diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/BatchIndex.java b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchIndex.java index 83757dadee1..451ab800945 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/BatchIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchIndex.java @@ -19,19 +19,19 @@ */ package org.sonar.server.batch; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Collection; +import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; import org.apache.commons.io.filefilter.HiddenFileFilter; import org.apache.commons.lang.CharUtils; import org.apache.commons.lang.StringUtils; import org.picocontainer.Startable; -import org.sonar.api.server.ServerSide; import org.sonar.api.platform.Server; -import org.sonar.home.cache.FileHashes; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; +import org.sonar.api.server.ServerSide; /** * JAR files to be downloaded by sonar-runner. @@ -56,7 +56,11 @@ public class BatchIndex implements Startable { for (File file : files) { String filename = file.getName(); if (StringUtils.endsWith(filename, ".jar")) { - sb.append(filename).append('|').append(new FileHashes().of(file)).append(CharUtils.LF); + try (FileInputStream fis = new FileInputStream(file)) { + sb.append(filename).append('|').append(DigestUtils.md5Hex(fis)).append(CharUtils.LF); + } catch (IOException e) { + throw new IllegalStateException("Fail to compute hash", e); + } } } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/JdbcDriverDeployer.java b/server/sonar-server/src/main/java/org/sonar/server/startup/JdbcDriverDeployer.java index 0181d298c4a..af48fb77df5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/JdbcDriverDeployer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/startup/JdbcDriverDeployer.java @@ -20,11 +20,12 @@ package org.sonar.server.startup; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import javax.annotation.Nullable; +import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FileUtils; import org.sonar.api.config.Settings; -import org.sonar.home.cache.FileHashes; import org.sonar.process.ProcessProperties; import org.sonar.server.platform.DefaultServerFileSystem; @@ -66,8 +67,12 @@ public class JdbcDriverDeployer { private static String driverIndexContent(@Nullable File deployedDriver) { if (deployedDriver != null) { - String hash = new FileHashes().of(deployedDriver); - return deployedDriver.getName() + "|" + hash; + try (FileInputStream fis = new FileInputStream(deployedDriver)) { + String hash = DigestUtils.md5Hex(fis); + return deployedDriver.getName() + "|" + hash; + } catch (IOException e) { + throw new IllegalStateException("Fail to compute hash", e); + } } return ""; }