3
3
import io .cucumber .core .exception .CucumberException ;
4
4
import io .cucumber .core .feature .FeatureWithLines ;
5
5
import io .cucumber .core .feature .GluePath ;
6
+ import io .cucumber .core .logging .Logger ;
7
+ import io .cucumber .core .logging .LoggerFactory ;
6
8
import io .cucumber .tagexpressions .TagExpressionParser ;
7
9
8
10
import java .nio .file .Path ;
24
26
import static io .cucumber .core .options .Constants .FILTER_TAGS_PROPERTY_NAME ;
25
27
import static io .cucumber .core .options .Constants .GLUE_PROPERTY_NAME ;
26
28
import static io .cucumber .core .options .Constants .OBJECT_FACTORY_PROPERTY_NAME ;
29
+ import static io .cucumber .core .options .Constants .OPTIONS_PROPERTY_NAME ;
27
30
import static io .cucumber .core .options .Constants .PLUGIN_PROPERTY_NAME ;
28
31
import static io .cucumber .core .options .Constants .PLUGIN_PUBLISH_ENABLED_PROPERTY_NAME ;
29
32
import static io .cucumber .core .options .Constants .PLUGIN_PUBLISH_QUIET_PROPERTY_NAME ;
32
35
import static io .cucumber .core .options .Constants .WIP_PROPERTY_NAME ;
33
36
import static io .cucumber .core .options .OptionsFileParser .parseFeatureWithLinesFile ;
34
37
import static java .util .Arrays .stream ;
38
+ import static java .util .function .Function .identity ;
35
39
import static java .util .stream .Collectors .toList ;
36
40
37
41
public final class CucumberPropertiesParser {
38
42
43
+ private static final Logger log = LoggerFactory .getLogger (CucumberPropertiesParser .class );
44
+
39
45
public RuntimeOptionsBuilder parse (Map <String , String > properties ) {
40
46
return parse (properties ::get );
41
47
}
@@ -96,14 +102,19 @@ public RuntimeOptionsBuilder parse(CucumberPropertiesProvider properties) {
96
102
ObjectFactoryParser ::parseObjectFactory ,
97
103
builder ::setObjectFactoryClass );
98
104
105
+ parse (properties ,
106
+ OPTIONS_PROPERTY_NAME ,
107
+ identity (),
108
+ warnWhenCucumberOptionsIsUsed ());
109
+
99
110
parseAll (properties ,
100
111
PLUGIN_PROPERTY_NAME ,
101
- splitAndMap (Function . identity ()),
112
+ splitAndMap (identity ()),
102
113
builder ::addPluginName );
103
114
104
115
parse (properties ,
105
116
PLUGIN_PUBLISH_TOKEN_PROPERTY_NAME ,
106
- s -> s , // No validation - validated on server
117
+ identity () , // No validation - validated on server
107
118
builder ::setPublishToken );
108
119
109
120
parse (properties ,
@@ -129,6 +140,16 @@ public RuntimeOptionsBuilder parse(CucumberPropertiesProvider properties) {
129
140
return builder ;
130
141
}
131
142
143
+ private static Consumer <String > warnWhenCucumberOptionsIsUsed () {
144
+ // Quite a few old blogs still recommend the use of cucumber.options
145
+ // This should take care of recurring question involving this property.
146
+ return commandLineOptions -> log .warn (() -> String .format ("" +
147
+ "Passing commandline options via the property '%s' is no longer supported. " +
148
+ "Please use individual properties instead. " +
149
+ "See the java doc on %s for details." ,
150
+ OPTIONS_PROPERTY_NAME , Constants .class .getName ()));
151
+ }
152
+
132
153
private <T > void parse (
133
154
CucumberPropertiesProvider properties , String propertyName , Function <String , T > parser , Consumer <T > setter
134
155
) {
0 commit comments