diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..19d513b
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,5 @@
+*
+!/src/
+!/pom.xml
+!/settings.xml
+!/gpg-params
diff --git a/.gitignore b/.gitignore
index 9f97022..f3c48b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
-target/
\ No newline at end of file
+/target/
+/settings.xml
+/gpg-params
+/gpg-home
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..0dedba4
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,44 @@
+FROM alpine:3.8 AS download-maven
+RUN apk add --no-cache curl
+ARG MAVEN_VERSION=3.5.4
+ARG SHA=ce50b1c91364cb77efe3776f756a6d92b76d9038b0a0782f7d53acf1e997a14d
+ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
+RUN mkdir -p /app /app/ref \
+ && curl -fsSL -o /maven.tar.gz ${BASE_URL}/apache-maven-"${MAVEN_VERSION}"-bin.tar.gz \
+ && echo "${SHA} /maven.tar.gz" | sha256sum -c - \
+ && tar -xzf /maven.tar.gz -C /app --strip-components=1
+
+FROM alpine:3.8 AS generate-gpg-key
+RUN apk add --no-cache gnupg1
+ENV GNUPGHOME=/key
+RUN mkdir -p "${GNUPGHOME}"
+COPY gpg-params /gpg-params
+RUN gpg --batch --gen-key /gpg-params
+
+FROM openjdk:9-jdk-slim AS build-jar
+RUN ln -s /etc/java-9-openjdk /usr/lib/jvm/java-9-openjdk-$(dpkg --print-architecture)/conf
+ENV MAVEN_HOME /usr/share/maven
+ENV MAVEN_CONFIG "${HOME}/.m2"
+COPY --from=download-maven /app "${MAVEN_HOME}"
+RUN ln -s "${MAVEN_HOME}"/bin/mvn /usr/bin/mvn
+# Build app
+ENV APP_SOURCE /app
+WORKDIR /app
+COPY pom.xml pom.xml
+RUN mvn validate dependency:go-offline
+COPY src src
+RUN mvn clean compile test
+RUN mvn -DskipTests=true package
+
+FROM build-jar AS build-signed-jar
+RUN apt-get update && apt-get install -y gnupg1 && rm -rf /var/lib/apt/lists/*
+ENV GNUPGHOME=/key
+COPY --from=generate-gpg-key /key "${GNUPGHOME}"
+COPY settings.xml /root/.m2/
+RUN mvn -o -DskipTests=true verify
+
+FROM build-signed-jar AS deploy-snapshot
+RUN mvn -DskipTests=true deploy
+
+FROM build-signed-jar AS deploy-release
+RUN mvn -DskipTests=true deploy
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0eec8be
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,22 @@
+.PHONY: jar signed-jar export-gpg-key deploy-release deploy-snapshot publish-gpg-key
+
+jar:
+ mkdir -p target
+ docker-compose build build-jar
+ docker-compose run --rm build-jar
+deploy-release: publish-gpg-key
+ docker-compose build deploy-release
+deploy-snapshot: publish-gpg-key
+ docker-compose build deploy-snapshot
+signed-jar: export-gpg-key
+ mkdir -p target
+ docker-compose build build-signed-jar
+ docker-compose run --rm build-signed-jar
+publish-gpg-key: export-gpg-key
+ docker-compose build publish-gpg-key
+ docker-compose run --rm publish-gpg-key
+export-gpg-key: gpg-home
+gpg-home:
+ mkdir -p gpg-home
+ docker-compose build export-gpg-key
+ docker-compose run --rm export-gpg-key
diff --git a/README.md b/README.md
index edeeea4..482de6b 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,9 @@
Write regexes as **plain Java code**. Unlike opaque regex strings, commenting your expressions and reusing regex fragments is straightforward.
-The **regex-builder** library is implemented as a light-weight wrapper around `java.util.regex`. It consists of three main components: the expression builder `Re`, its fluent API equivalent `FluentRe`, and the character class builder `CharClass`. The components are introduced in the examples below as well as in the API overview tables at the end of this document.
+The **regex-builder** library is implemented as a light-weight wrapper around `java.util.regex`. It consists of three main components: the expression builder `Re`, its fluent API equivalent `FluentRe`, and the character class builder `CharClass`. The components are introduced in the examples below as well as in the API overview tables at the end of this document.
-There's a [discussion](https://www.reddit.com/r/java/comments/4tyk90/github_sgrebenregexbuilder_write_regular/) of this project over on the Java reddit.
+There's a [discussion](https://www.reddit.com/r/java/comments/4tyk90/github_sgrebenregexbuilder_write_regular/) of this project over on the Java subreddit.
- [Installation / Maven dependency](#maven-dependency)
- [Examples](#examples)
@@ -24,7 +24,7 @@ There's a [discussion](https://www.reddit.com/r/java/comments/4tyk90/github_sgre
com.github.sgreben
regex-builder
- 1.0.1-SNAPSHOT
+ 1.0.1
```
@@ -94,7 +94,7 @@ The above example can also be expressed using the fluent API implemented in `Flu
```java
import static com.github.sgreben.regex_builder.CharClass.*;
import com.github.sgreben.regex_builder.FluentRe;
-```
+```
```java
CaptureGroup ip, client, user, dateTime, method, request, protocol, responseCode, size;
@@ -168,7 +168,7 @@ assertEquals("22", m.group(second));
```java
Expression threeHexDigits = repeat(hexDigit(), 3);
CaptureGroup hexValue = capture(
- threeHexDigits, // #FFF
+ threeHexDigits, // #FFF
optional(threeHexDigits) // #FFFFFF
);
Expression hexColor = sequence(
@@ -190,7 +190,7 @@ assertEquals("1bf", m.group(hexValue));
To reuse an expression cleanly, it should be packaged as a class. To access the capture groups contained in the expression,
each capture group should be exposed as a final field or method.
-
+
To allow the resulting object to be used as an expression, `regex-builder` provides a utility class `ExpressionWrapper`,
which exposes a method `setExpression(Expression expr)` and implements the `Expresssion` interface.
@@ -198,11 +198,11 @@ which exposes a method `setExpression(Expression expr)` and implements the `Expr
import com.github.sgreben.regex_builder.ExpressionWrapper;
```
-To use the class, simply extend it and call `setExpression` in your constructor or initialization block.
+To use the class, simply extend it and call `setExpression` in your constructor or initialization block.
You can then pass it to any `regex-builder` method that expects an `Expression`.
### Reusable Apache log expression
-Using `ExpressionWrapper`, we can package the Apache log
+Using `ExpressionWrapper`, we can package the Apache log
example above as follows:
```java
public class ApacheLog extends ExpressionWrapper {
@@ -305,4 +305,4 @@ public static boolean sameIP(String twoLogs) {
| verticalWhitespaceChar() | \v |
| nonVerticalWhitespaceChar() | \V |
| horizontalWhitespaceChar() | \h |
-| nonHorizontalWhitespaceChar()| \H |
\ No newline at end of file
+| nonHorizontalWhitespaceChar()| \H |
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..a8297ca
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,67 @@
+version: '3.4'
+services:
+ export-gpg-key:
+ image: regex-builder:export-gpg-key
+ build:
+ context: .
+ target: generate-gpg-key
+ volumes:
+ - type: bind
+ source: ./gpg-home
+ target: /output
+ entrypoint: /bin/sh
+ command:
+ - -euxc
+ - cd "$$GNUPGHOME" && cp -rv . /output
+ publish-gpg-key:
+ image: regex-builder:export-gpg-key
+ build:
+ context: .
+ target: generate-gpg-key
+ entrypoint: /bin/sh
+ command:
+ - -euxc
+ - |
+ KEY_ID=$$(gpg --list-keys --with-colons | awk -F: '/^pub:/ { print $$5 }');
+ gpg --keyserver hkp://pool.sks-keyservers.net --send-keys "$$KEY_ID" &
+ gpg --keyserver hkp://eu.pool.sks-keyservers.net --send-keys "$$KEY_ID" &
+ gpg --keyserver hkp://na.pool.sks-keyservers.net --send-keys "$$KEY_ID" &
+ gpg --keyserver hkp://oc.pool.sks-keyservers.net --send-keys "$$KEY_ID" &
+ gpg --keyserver hkp://keyserver.ubuntu.com --send-keys "$$KEY_ID" &
+ wait
+ build-jar:
+ image: regex-builder:build-jar
+ build:
+ context: .
+ target: build-jar
+ volumes:
+ - type: bind
+ source: ./target
+ target: /output
+ entrypoint: /bin/sh
+ command:
+ - -euxc
+ - cp -rv target/*.jar /output
+ build-signed-jar:
+ image: regex-builder:build-signed-jar
+ build:
+ context: .
+ target: build-signed-jar
+ volumes:
+ - type: bind
+ source: ./target
+ target: /output
+ entrypoint: /bin/sh
+ command:
+ - -euxc
+ - cp -rv target/*.jar /output
+ deploy-release:
+ image: regex-builder:release
+ build:
+ context: .
+ target: deploy-release
+ deploy-snapshot:
+ image: regex-builder:snapshot
+ build:
+ context: .
+ target: deploy-snapshot
diff --git a/gpg-params.template b/gpg-params.template
new file mode 100644
index 0000000..cbba1a3
--- /dev/null
+++ b/gpg-params.template
@@ -0,0 +1,6 @@
+Key-Type: default
+Subkey-Type: default
+Name-Real: TODO: NAME
+Name-Email: TODO: EMAIL
+Expire-Date: 0
+Passphrase: TODO: PASSPHRASE
diff --git a/pom.xml b/pom.xml
index 045b23a..36309c0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.github.sgreben
regex-builder
jar
- 1.0.1-SNAPSHOT
+ 1.0.1
${project.groupId}:${project.artifactId}
Construct regular expressions as pure Java code.
https://github.com/sgreben/regex-builder/
@@ -26,9 +26,6 @@
http://www.opensource.org/licenses/mit-license.php
-
- 3.0
-
ossrh
@@ -68,6 +65,19 @@
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.9.1
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
org.sonatype.plugins
nexus-staging-maven-plugin
@@ -95,4 +105,4 @@
-
\ No newline at end of file
+
diff --git a/settings.xml.template b/settings.xml.template
new file mode 100644
index 0000000..f2add15
--- /dev/null
+++ b/settings.xml.template
@@ -0,0 +1,21 @@
+
+
+
+ ossrh
+ TODO: USERNAME
+ TODO: PASSWORD
+
+
+
+
+ ossrh
+
+ true
+
+
+ gpg1
+ TODO: PASSPHRASE
+
+
+
+