Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the Java Gherkin parser. Rely on Go binary/protobuf #424

Merged
merged 7 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gherkin/java/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ acceptance/
.built
.compared
dependency-reduced-pom.xml
gherkin-go/
3 changes: 0 additions & 3 deletions gherkin/java/.rsync
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
../../.templates/java/ .
../../.templates/gpg/ .
../testdata/ testdata/
../gherkin.berp gherkin.berp
../bin/ berp/
../gherkin-languages.json src/main/resources/gherkin/gherkin-languages.json
../proto/ src/main/protobuf/
59 changes: 28 additions & 31 deletions gherkin/java/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ SHELL := /usr/bin/env bash
GOOD_FEATURE_FILES = $(shell find testdata/good -name "*.feature")
BAD_FEATURE_FILES = $(shell find testdata/bad -name "*.feature")

TOKENS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.tokens,$(GOOD_FEATURE_FILES))
ASTS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.ast.ndjson,$(GOOD_FEATURE_FILES))
PICKLES = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.pickles.ndjson,$(GOOD_FEATURE_FILES))
SOURCES = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.source.ndjson,$(GOOD_FEATURE_FILES))
Expand All @@ -12,30 +11,38 @@ ERRORS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.error

JAVA_FILES = $(shell find . -name "*.java")

ifdef TRAVIS_TAG
DOWNLOAD_BINARIES_TARGET=gherkin-go
else
DOWNLOAD_BINARIES_TARGET=no-gherkin-go
endif

.DELETE_ON_ERROR:

default: .compared
.PHONY: default

protobins: $(PROTOBUFBINS)
protos: $(PROTOBUFS)

.compared: $(PROTOBUFS) $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES)
.compared: $(PROTOBUFS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES)
touch $@

.built: src/main/java/gherkin/Parser.java src/main/resources/gherkin/gherkin-languages.json $(JAVA_FILES) LICENSE pom.xml
.built: $(JAVA_FILES) LICENSE pom.xml $(DOWNLOAD_BINARIES_TARGET)
mvn install
touch $@

# # Generate
# acceptance/testdata/%.feature.tokens: testdata/%.feature .built
# mkdir -p `dirname $@`
# bin/gherkin-generate-tokens $< > $<.tokens

acceptance/testdata/%.feature.tokens: testdata/%.feature testdata/%.feature.tokens .built
mkdir -p `dirname $@`
bin/gherkin-generate-tokens $< > $@
diff --unified $<.tokens $@
# Downloads the most common platform binaries, which will be included in the jar
# The jar will download other binaries at runtime if they are not bundles
gherkin-go:
mkdir -p $@
curl https://s3.eu-west-2.amazonaws.com/io.cucumber/gherkin-go/${TRAVIS_TAG}/gherkin-darwin-amd64 -o gherkin-go/gherkin-darwin-amd64
curl https://s3.eu-west-2.amazonaws.com/io.cucumber/gherkin-go/${TRAVIS_TAG}/gherkin-darwin-386 -o gherkin-go/gherkin-darwin-386
curl https://s3.eu-west-2.amazonaws.com/io.cucumber/gherkin-go/${TRAVIS_TAG}/gherkin-linux-amd64 -o gherkin-go/gherkin-linux-amd64
curl https://s3.eu-west-2.amazonaws.com/io.cucumber/gherkin-go/${TRAVIS_TAG}/gherkin-linux-386 -o gherkin-go/gherkin-linux-386
curl https://s3.eu-west-2.amazonaws.com/io.cucumber/gherkin-go/${TRAVIS_TAG}/gherkin-windows-amd64.exe -o gherkin-go/gherkin-windows-amd64.exe
curl https://s3.eu-west-2.amazonaws.com/io.cucumber/gherkin-go/${TRAVIS_TAG}/gherkin-windows-386.exe -o gherkin-go/gherkin-windows-386.exe

no-gherkin-go:
echo "Not downloading binaries, because TRAVIS_TAG is not defined"
.PHONY: no-gherkin-go

# # Generate
# acceptance/testdata/%.feature.ast.ndjson: testdata/%.feature .built
Expand All @@ -44,7 +51,7 @@ acceptance/testdata/%.feature.tokens: testdata/%.feature testdata/%.feature.toke

acceptance/testdata/%.feature.ast.ndjson: testdata/%.feature testdata/%.feature.ast.ndjson .built
mkdir -p `dirname $@`
bin/gherkin --no-source --no-pickles $< | jq --sort-keys --compact-output "." > $@
bin/gherkin --no-source --no-pickles --json $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.ast.ndjson) <(jq "." $@)

# # Generate - we only do this in the Java project, then rsync to others
Expand All @@ -59,7 +66,7 @@ acceptance/testdata/%.feature.ast.ndjson: testdata/%.feature testdata/%.feature.

acceptance/testdata/%.feature.protobuf.bin.ndjson: testdata/%.feature.protobuf.bin .built
mkdir -p `dirname $@`
cat $< | bin/gherkin | jq --sort-keys --compact-output "." > $@
cat $< | bin/gherkin --json | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.ndjson) <(jq "." $@)

# # Generate
Expand All @@ -69,7 +76,7 @@ acceptance/testdata/%.feature.protobuf.bin.ndjson: testdata/%.feature.protobuf.b

acceptance/testdata/%.feature.pickles.ndjson: testdata/%.feature testdata/%.feature.pickles.ndjson .built
mkdir -p `dirname $@`
bin/gherkin --no-source --no-ast $< | jq --sort-keys --compact-output "." > $@
bin/gherkin --no-source --no-ast --json $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.pickles.ndjson) <(jq "." $@)

# # Generate
Expand All @@ -79,7 +86,7 @@ acceptance/testdata/%.feature.pickles.ndjson: testdata/%.feature testdata/%.feat

acceptance/testdata/%.feature.source.ndjson: testdata/%.feature testdata/%.feature.source.ndjson .built
mkdir -p `dirname $@`
bin/gherkin --no-ast --no-pickles $< | jq --sort-keys --compact-output "." > $@
bin/gherkin --no-ast --no-pickles --json $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.source.ndjson) <(jq "." $@)

# # Generate
Expand All @@ -89,19 +96,9 @@ acceptance/testdata/%.feature.source.ndjson: testdata/%.feature testdata/%.featu

acceptance/testdata/%.feature.errors.ndjson: testdata/%.feature testdata/%.feature.errors.ndjson .built
mkdir -p `dirname $@`
bin/gherkin --no-source $< | jq --sort-keys --compact-output "." > $@
bin/gherkin --no-source --json $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@)

src/main/java/gherkin/Parser.java: gherkin.berp gherkin-java.razor berp/berp.exe
-mono berp/berp.exe -g gherkin.berp -t gherkin-java.razor -o $@
# Remove BOM
awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' < $@ > [email protected]
mv [email protected] $@

clean:
rm -rf .compared .built acceptance target
rm -rf .compared .built acceptance target gherkin-go
.PHONY: clean

clobber: clean
rm -rf src/main/java/gherkin/Parser.java
.PHONY: clobber
24 changes: 24 additions & 0 deletions gherkin/java/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">

<id>gherkin-jar-with-executables</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<useTransitiveDependencies>false</useTransitiveDependencies>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>gherkin-go</directory>
</fileSet>
</fileSets>
</assembly>
Binary file removed gherkin/java/berp/CommandLine.dll
Binary file not shown.
Binary file removed gherkin/java/berp/RazorEngine.dll
Binary file not shown.
Binary file removed gherkin/java/berp/RazorEngine.pdb
Binary file not shown.
Binary file removed gherkin/java/berp/System.Web.Razor.dll
Binary file not shown.
Binary file removed gherkin/java/berp/berp.exe
Binary file not shown.
Binary file removed gherkin/java/berp/berp.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion gherkin/java/bin/gherkin
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

java \
-classpath $DIR/../target/gherkin-6.0.0-SNAPSHOT.jar:$HOME/.m2/repository/io/cucumber/messages/1.0.0-SNAPSHOT/messages-1.0.0-SNAPSHOT.jar \
gherkin.cli.Main $*
io.cucumber.gherkin.Main $*
6 changes: 0 additions & 6 deletions gherkin/java/bin/gherkin-generate-tokens

This file was deleted.

Loading