Skip to content

Commit 4be971a

Browse files
author
Haroon Sheikh
authored
Revert "[Core] Remove the deprecated -f/--format option. (#1260)" (#1294)
1 parent 9a0ed2b commit 4be971a

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

core/src/main/java/cucumber/api/CucumberOptions.java

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
*/
3737
String[] tags() default {};
3838

39+
/**
40+
* @return what formatter(s) to use
41+
* @deprecated use {@link #plugin()}
42+
*/
43+
@Deprecated
44+
String[] format() default {};
45+
3946
/**
4047
* @return what plugins(s) to use
4148
*/

core/src/main/java/cucumber/runtime/RuntimeOptions.java

+3
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ private void parse(List<String> args) {
155155
parsedTagFilters.add(args.remove(0));
156156
} else if (arg.equals("--plugin") || arg.equals("--add-plugin") || arg.equals("-p")) {
157157
parsedPluginData.addPluginName(args.remove(0), arg.equals("--add-plugin"));
158+
} else if (arg.equals("--format") || arg.equals("-f")) {
159+
System.err.println("WARNING: Cucumber-JVM's --format option is deprecated. Please use --plugin instead.");
160+
parsedPluginData.addPluginName(args.remove(0), true);
158161
} else if (arg.equals("--no-dry-run") || arg.equals("--dry-run") || arg.equals("-d")) {
159162
dryRun = !arg.startsWith("--no-");
160163
} else if (arg.equals("--no-strict") || arg.equals("--strict") || arg.equals("-s")) {

core/src/main/java/cucumber/runtime/RuntimeOptionsFactory.java

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ private void addTags(CucumberOptions options, List<String> args) {
8787
private void addPlugins(CucumberOptions options, List<String> args) {
8888
List<String> plugins = new ArrayList<String>();
8989
plugins.addAll(asList(options.plugin()));
90+
plugins.addAll(asList(options.format()));
9091
for (String plugin : plugins) {
9192
args.add("--plugin");
9293
args.add(plugin);

core/src/main/resources/cucumber/api/cli/USAGE.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Options:
1414
registration of 3rd party plugins.
1515
--add-plugin does not clobber plugins of that
1616
type defined from a different source.
17+
-f, --format FORMAT[:PATH_OR_URL] Deprecated. Use --plugin instead.
1718
-t, --tags TAG_EXPRESSION Only run scenarios tagged with tags matching
1819
TAG_EXPRESSION.
1920
-n, --name REGEXP Only run scenarios whose names match REGEXP.

examples/java-calculator-testng/src/test/java/cucumber/examples/java/calculator/RunCukesByCompositionTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* AbstractTestNGCucumberTests but still executes each scenario as a separate
1515
* TestNG test.
1616
*/
17-
@CucumberOptions(strict = true, plugin = "json:target/cucumber-report-feature-composite.json")
17+
@CucumberOptions(strict = true, format = "json:target/cucumber-report-feature-composite.json")
1818
public class RunCukesByCompositionTest extends RunCukesByCompositionBase {
1919
private TestNGCucumberRunner testNGCucumberRunner;
2020

0 commit comments

Comments
 (0)