Skip to content

Commit 8ee4880

Browse files
authored
[Core] Extract Plugin module (#1774)
## Summary With the introduction of v5 we will break the plugin API by moving packages from `cucumber.core` to `io.cucumber.core`. We can use this as an opportunity to extract the plugin and event classes to separate modules. This change moves `io.cucumber.core.plugin` to `io.cucumber.plugin` and `io.cucumber.core.event` to `io.cucumber.plugin.event`. While on its own this change provides little value it will allow us in the future to provide better support for plugins. With the introduction of JPMS we will want to expose these classes for plugin developers. However we also want to avoid the use of core by most end users. By moving these classes to their own modules we can avoid the use of core and future proof the introduction of JPMS. Closes #1773.
1 parent 735eab4 commit 8ee4880

File tree

129 files changed

+704
-485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+704
-485
lines changed

core/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
<groupId>io.cucumber</groupId>
3838
<artifactId>datatable</artifactId>
3939
</dependency>
40+
<dependency>
41+
<groupId>io.cucumber</groupId>
42+
<artifactId>cucumber-plugin</artifactId>
43+
</dependency>
4044
<dependency>
4145
<groupId>io.cucumber</groupId>
4246
<artifactId>docstring</artifactId>

core/src/main/java/io/cucumber/core/backend/ParameterInfo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package io.cucumber.core.backend;
22

3+
import org.apiguardian.api.API;
4+
35
import java.lang.reflect.Type;
46

7+
@API(status = API.Status.STABLE)
58
public interface ParameterInfo {
69

710
/**

core/src/main/java/io/cucumber/core/backend/Scenario.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.cucumber.core.backend;
22

3-
import io.cucumber.core.event.Status;
43
import org.apiguardian.api.API;
54

65
import java.util.Collection;
@@ -10,7 +9,7 @@
109
* It allows writing text and embedding media into reports, as well as inspecting results (in an After block).
1110
* <p>
1211
* Note: This class is not intended to be used to create reports. To create custom reports use
13-
* the {@code io.cucumber.core.plugin.Plugin} class. The plugin system provides a much richer access to Cucumbers then
12+
* the {@code io.cucumber.plugin.Plugin} class. The plugin system provides a much richer access to Cucumbers then
1413
* hooks after could provide. For an example see {@code io.cucumber.core.plugin.PrettyFormatter}.
1514
*/
1615
@API(status = API.Status.STABLE)
@@ -86,4 +85,5 @@ public interface Scenario {
8685
* the Scenario Outline.
8786
*/
8887
Integer getLine();
88+
8989
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.cucumber.core.backend;
2+
3+
import org.apiguardian.api.API;
4+
5+
@API(status = API.Status.STABLE)
6+
public enum Status {
7+
PASSED,
8+
SKIPPED,
9+
PENDING,
10+
UNDEFINED,
11+
AMBIGUOUS,
12+
FAILED,
13+
UNUSED;
14+
15+
public boolean is(Status status) {
16+
return this == status;
17+
}
18+
19+
public boolean isOk(boolean isStrict) {
20+
return hasAlwaysOkStatus() || !isStrict && hasOkWhenNotStrictStatus();
21+
}
22+
23+
private boolean hasAlwaysOkStatus() {
24+
return is(PASSED) || is(SKIPPED);
25+
}
26+
27+
private boolean hasOkWhenNotStrictStatus() {
28+
return is(UNDEFINED) || is(PENDING);
29+
}
30+
31+
}

core/src/main/java/io/cucumber/core/backend/StepDefinition.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import java.util.List;
66

77
@API(status = API.Status.STABLE)
8-
public interface StepDefinition extends io.cucumber.core.event.StepDefinition {
8+
public interface StepDefinition {
9+
910
/**
1011
* Invokes the step definition. The method should raise a Throwable
1112
* if the invocation fails, which will cause the step to fail.
@@ -27,4 +28,17 @@ public interface StepDefinition extends io.cucumber.core.event.StepDefinition {
2728
*/
2829
List<ParameterInfo> parameterInfos();
2930

31+
/**
32+
* The source line where the step definition is defined.
33+
* Example: com/example/app/Cucumber.test():42
34+
*
35+
* @return The source line of the step definition.
36+
*/
37+
String getLocation();
38+
39+
/**
40+
* @return the pattern associated with this instance. Used for error reporting only.
41+
*/
42+
String getPattern();
43+
3044
}

core/src/main/java/io/cucumber/core/eventbus/AbstractEventBus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.cucumber.core.eventbus;
22

3-
import io.cucumber.core.event.Event;
3+
import io.cucumber.plugin.event.Event;
44

55
public abstract class AbstractEventBus extends AbstractEventPublisher implements EventBus {
66

core/src/main/java/io/cucumber/core/eventbus/AbstractEventPublisher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.cucumber.core.eventbus;
22

3-
import io.cucumber.core.event.Event;
4-
import io.cucumber.core.event.EventHandler;
5-
import io.cucumber.core.event.EventPublisher;
3+
import io.cucumber.plugin.event.Event;
4+
import io.cucumber.plugin.event.EventHandler;
5+
import io.cucumber.plugin.event.EventPublisher;
66

77
import java.util.ArrayList;
88
import java.util.HashMap;

core/src/main/java/io/cucumber/core/eventbus/EventBus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.time.Instant;
44

5-
import io.cucumber.core.event.Event;
6-
import io.cucumber.core.event.EventPublisher;
5+
import io.cucumber.plugin.event.Event;
6+
import io.cucumber.plugin.event.EventPublisher;
77

88
public interface EventBus extends EventPublisher {
99

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.cucumber.core.feature;
22

3-
public interface Argument extends io.cucumber.core.event.StepArgument {
3+
import io.cucumber.plugin.event.StepArgument;
4+
5+
public interface Argument extends StepArgument {
46

57
}

core/src/main/java/io/cucumber/core/feature/CucumberStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import gherkin.pickles.PickleString;
77
import gherkin.pickles.PickleTable;
88

9-
public final class CucumberStep implements io.cucumber.core.event.CucumberStep {
9+
public final class CucumberStep implements io.cucumber.plugin.event.CucumberStep {
1010

1111
private final PickleStep pickleStep;
1212
private final String keyWord;

0 commit comments

Comments
 (0)