@Grasshopper 的建议并不完全奏效,但它让我朝着正确的方向前进。
我没有将代码添加为插件,而是通过创建一个副本来设法“破解/加载”辛烷值报告cucumber.api.cli.Main
器,使用它作为运行 cli 命令的基础,并稍微更改run
方法并在运行时添加插件。需要这样做是因为插件在其构造函数中需要相当多的参数。可能不是完美的解决方案,但它让我能够保持gradle
最初的构建过程。
public static byte run(String[] argv, ClassLoader classLoader) throws IOException {
RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<String>(asList(argv)));
ResourceLoader resourceLoader = new MultiLoader(classLoader);
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
//====================Added the following lines ================
//Hardcoded runner(?) class. If its changed, it will need to be changed here also
OutputFile outputFile = new OutputFile(Main.class);
runtimeOptions.addPlugin(new HPEAlmOctaneGherkinFormatter(resourceLoader, runtimeOptions.getFeaturePaths(), outputFile));
//==============================================================
runtime.run();
return runtime.exitStatus();
}