Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions resolver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,17 @@ java_test(
],
)

java_test(
name = "rule_test",
size = "small",
srcs = ["src/test/java/com/google/devtools/bazel/workspace/maven/RuleTest.java"],
test_class = "com.google.devtools.bazel.workspace.maven.RuleTest",
deps = [
":graph_resolver_lib",
"@mvn//junit/junit",
],
)

java_test(
name = "sources_locator_test",
size = "small",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.devtools.bazel.workspace.maven;

import com.google.common.base.CharMatcher;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
Expand All @@ -35,6 +36,9 @@ public class Rule implements Comparable<Rule> {

private static final String DEFAULT_PACKAGING = "jar";

// Pre-compiled matcher for performance optimization over String.replaceAll
private static final CharMatcher DOT_OR_DASH_MATCHER = CharMatcher.anyOf(".-");

private final Artifact artifact;
private final Set<String> parents;
private final Map<String, Set<Rule>> dependencies;
Expand Down Expand Up @@ -66,7 +70,7 @@ static String generateFullName(String groupId, String artifactId, String version
}

private static String normalizedWorkspaceName(final String name) {
return name.replaceAll("[.-]", "_");
return DOT_OR_DASH_MATCHER.replaceFrom(name, '_');
}

private static String normalizeMavenName(final String name) {
Expand Down
Loading