Replace the occurrences of Constants.PRODUCT_NAME for a call to
BlazeRuntime#getProductName() or a reference to TestConstants.PRODUCT_NAME for tests.
This CL prepares the codebase in order to delete the constant.
--
MOS_MIGRATED_REVID=122993568
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandUtils.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandUtils.java
index 3ba6e22..f7bcd1d 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandUtils.java
@@ -15,7 +15,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
-import com.google.devtools.build.lib.Constants;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
import com.google.devtools.build.lib.util.ResourceFileLoader;
import com.google.devtools.common.options.OptionsBase;
@@ -106,12 +105,14 @@
* descriptions, passed to {@link OptionsParser#describeOptions}.
* @param helpVerbosity a tri-state verbosity option selecting between just
* names, names and syntax, and full description.
+ * @param productName the product name
*/
public static final String expandHelpTopic(String topic, String help,
Class<? extends BlazeCommand> commandClass,
Collection<Class<? extends OptionsBase>> options,
Map<String, String> categoryDescriptions,
- OptionsParser.HelpVerbosity helpVerbosity) {
+ OptionsParser.HelpVerbosity helpVerbosity,
+ String productName) {
OptionsParser parser = OptionsParser.newOptionsParser(options);
String template;
@@ -134,9 +135,9 @@
String optionStr =
parser
.describeOptions(categoryDescriptions, helpVerbosity)
- .replace("%{product}", Constants.PRODUCT_NAME);
+ .replace("%{product}", productName);
return template
- .replace("%{product}", Constants.PRODUCT_NAME)
+ .replace("%{product}", productName)
.replace("%{command}", topic)
.replace("%{options}", optionStr)
.trim()
@@ -159,7 +160,8 @@
Map<String, String> categoryDescriptions,
OptionsParser.HelpVerbosity verbosity,
Iterable<BlazeModule> blazeModules,
- ConfiguredRuleClassProvider ruleClassProvider) {
+ ConfiguredRuleClassProvider ruleClassProvider,
+ String productName) {
Command commandAnnotation = commandClass.getAnnotation(Command.class);
return BlazeCommandUtils.expandHelpTopic(
commandAnnotation.name(),
@@ -167,6 +169,7 @@
commandClass,
BlazeCommandUtils.getOptions(commandClass, blazeModules, ruleClassProvider),
categoryDescriptions,
- verbosity);
+ verbosity,
+ productName);
}
}