Remove dependency on commons-io library This dependency was added in Id12780948a4 to support remoteNameStyle "basenameOnly". The only reason for this dependency is to translate project name from "foo/bar/myrepo" to myrepo. It seems to be overkill to add 169 KB to the plugin distribution for one single method. Another disadvantage is that the version of common-io library used for this is 2.2 from 2012. If gerrit installation site is using some other plugins in addition to replication plugin, then it can easily lead to classpath collision, when different versions of commons-io libraries are included as transitive dependencies of different plugins. To rectify, use a replacement method from guava library. Change-Id: Id254dc38831832a9855bd204e4c2129ec64b88ae
diff --git a/BUILD b/BUILD index 9fb9a49..df6a2c0 100644 --- a/BUILD +++ b/BUILD
@@ -14,9 +14,6 @@ "Gerrit-SshModule: com.googlesource.gerrit.plugins.replication.SshModule", ], resources = glob(["src/main/resources/**/*"]), - deps = [ - "//lib/commons:io", - ], ) junit_tests(
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java index 8054eb4..78c8130 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Lists; +import com.google.common.io.Files; import com.google.gerrit.entities.AccountGroup; import com.google.gerrit.entities.BranchNameKey; import com.google.gerrit.entities.GroupReference; @@ -78,7 +79,6 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.function.Function; -import org.apache.commons.io.FilenameUtils; import org.apache.http.impl.client.CloseableHttpClient; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Ref; @@ -698,7 +698,7 @@ } else if (remoteNameStyle.equals("underscore")) { name = name.replace("/", "_"); } else if (remoteNameStyle.equals("basenameOnly")) { - name = FilenameUtils.getBaseName(name); + name = Files.getNameWithoutExtension(name); } else if (!remoteNameStyle.equals("slash")) { repLog.atFine().log("Unknown remoteNameStyle: %s, falling back to slash", remoteNameStyle); }