Skip to content

Commit

Permalink
Merge branch 'release/1.0.0-preview.20230409' into master/1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 9, 2023
2 parents d43dc93 + 09b2fad commit 77cc11e
Show file tree
Hide file tree
Showing 27 changed files with 263 additions and 99 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
- develop/1.x
jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3.0.2
- uses: actions/checkout@v3.3.0
- name: Set up JDK 1.8
uses: actions/setup-java@v3.4.0
uses: actions/setup-java@v3.10.0
with:
java-version: '8'
distribution: 'temurin'
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: 'release'
on:
workflow_dispatch:
inputs:
release_version:
description: 'release version; e.g. 0.0.1'
required: true
next_snapshot_version:
description: 'next snapshot version; e.g. 0.0.2-SNAPSHOT'
required: true

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0

- name: Set up JDK 1.8
uses: actions/[email protected]
with:
java-version: '8'
distribution: 'temurin'

- name: Download jq-1.5 and jq-1.6
run: |
mkdir -p $HOME/bin
wget -O $HOME/bin/jq-1.5 https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
wget -O $HOME/bin/jq-1.6 https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
chmod +x $HOME/bin/jq-1.5 $HOME/bin/jq-1.6
- name: Configure Maven
env:
M2_SETTINGS_XML: ${{ secrets.M2_SETTINGS_XML }}
run: |
set -euo pipefail
mkdir -p $HOME/.m2
echo "$M2_SETTINGS_XML" > $HOME/.m2/settings.xml
- name: Configure Git
run: |
set -euo pipefail
# https://github.com/orgs/community/discussions/26560
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Release
run: |
set -euo pipefail
PATH="$HOME/bin:$PATH" scripts/release.sh ${{ github.event.inputs.release_version }} ${{ github.event.inputs.next_snapshot_version }}
- name: Configure GPG
env:
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
run: |
set -euo pipefail
echo "$GPG_SECRET_KEY" | gpg --batch --import
gpg --list-secret-keys
- name: Build & Deploy
run: |
set -euo pipefail
git checkout master/1.x
PATH="$HOME/bin:$PATH" mvn -Prelease clean deploy
- name: Git Push
run: |
set -euo pipefail
git push --tags
git push --all
6 changes: 3 additions & 3 deletions .github/workflows/test-pull-requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:
- develop/1.x
jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3.0.2
- uses: actions/checkout@v3.3.0
- name: Set up JDK 1.8
uses: actions/setup-java@v3.4.0
uses: actions/setup-java@v3.10.0
with:
java-version: '8'
distribution: 'temurin'
Expand Down
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Usage

First, you need Java 8 or later.

If you use Maven, add the following snippet to the `<dependencies>` section of your POM. For instructions for other build tools (Gradle, etc.), visit [jackson-jq](https://search.maven.org/artifact/net.thisptr/jackson-jq/1.0.0-preview.20220705/jar) on search.maven.org.
If you use Maven, add the following snippet to the `<dependencies>` section of your POM. For instructions for other build tools (Gradle, etc.), visit [jackson-jq](https://search.maven.org/artifact/net.thisptr/jackson-jq/1.0.0-preview.20230409/jar) on search.maven.org.

```xml
<dependency>
<groupId>net.thisptr</groupId>
<artifactId>jackson-jq</artifactId>
<version>1.0.0-preview.20220705</version>
<version>1.0.0-preview.20230409</version>
</dependency>
```

Expand All @@ -32,29 +32,29 @@ To test a query quickly, we provide jackson-jq CLI.
*Please note that jackson-jq is a Java library and the CLI is provided solely for debugging/testing purpose (and not for production). The command-line options might change without notice.*

```sh
$ curl -LO https://repo1.maven.org/maven2/net/thisptr/jackson-jq-cli/1.0.0-preview.20220705/jackson-jq-cli-1.0.0-preview.20220705.jar
$ curl -LO https://repo1.maven.org/maven2/net/thisptr/jackson-jq-cli/1.0.0-preview.20230409/jackson-jq-cli-1.0.0-preview.20230409.jar

$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar --help
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar --help
usage: jackson-jq [OPTIONS...] QUERY
-c,--compact compact instead of pretty-printed output
-h,--help print this message
--jq <arg> specify jq version
-n,--null-input use `null` as the single input value
-r,--raw output raw strings, not JSON texts

$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar '.foo'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar '.foo'
{"foo": 42}
42
```

To test a query with a specific jq version,

```sh
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar --jq 1.5 'join("-")'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar --jq 1.5 'join("-")'
["1", 2]
jq: error: string ("-") and number (2) cannot be added

$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar --jq 1.6 'join("-")' # jq-1.6 can join any values, not only strings
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar --jq 1.6 'join("-")' # jq-1.6 can join any values, not only strings
["1", 2]
"1-2"
```
Expand Down Expand Up @@ -236,9 +236,9 @@ $ jq -n '1 + 3 as $a | ($a * 2)' # interpreted as 1 + (3 as $a | ($a * 2))
whereas jackson-jq consistently interprets them as `(1 + 3)` whether `as $a` is used or not:

```console
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n '1 + 3 | (. * 2)' # interpreted as (1 + 3) | (. * 2)
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar -n '1 + 3 | (. * 2)' # interpreted as (1 + 3) | (. * 2)
8
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n '1 + 3 as $a | ($a * 2)' # interpreted as (1 + 3) as $a | ($a * 2)
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar -n '1 + 3 as $a | ($a * 2)' # interpreted as (1 + 3) as $a | ($a * 2)
8
```

Expand All @@ -247,7 +247,7 @@ $ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n '1 + 3 as $a | ($a * 2)
```console
$ jq -n '1 + 3 as $a | ($a * 2)' # interpreted as 1 + (3 as $a | ($a * 2))
7
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n '1 + 3 as $a | ($a * 2)' # interpreted as (1 + 3) as $a | ($a * 2)
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar -n '1 + 3 as $a | ($a * 2)' # interpreted as (1 + 3) as $a | ($a * 2)
8
```

Expand All @@ -274,7 +274,7 @@ If the function with the same is defined more than once at the same scope, jacks
```console
$ jq -n 'def f: 1; def g: f; def f: 2; g'
1
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n 'def f: 1; def g: f; def f: 2; g'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar -n 'def f: 1; def g: f; def f: 2; g'
2
```

Expand All @@ -283,7 +283,7 @@ $ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n 'def f: 1; def g: f; de
Avoid using the duplicate function name.

```console
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n 'def f1: 1; def g: f1; def f2: 2; g'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar -n 'def f1: 1; def g: f1; def f2: 2; g'
1
```

Expand Down Expand Up @@ -353,7 +353,7 @@ jq: error: Division by zero? at <top-level>, line 1:
jq: 1 compile error
$ jq '. / 0' <<< 0
jq: error (at <stdin>:1): number (0) and number (0) cannot be divided because the divisor is zero
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n '0 / 0'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar -n '0 / 0'
jq: error: number (0) and number (0) cannot be divided because the divisor is zero
```

Expand Down Expand Up @@ -386,9 +386,9 @@ $ jq-1.2 -n '[1,2,3] | ((.[] | select(. > 1)) |= empty)'
2,
3
]
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar --jq 1.6 -n '[1,2,3] | ((.[] | select(. > 1)) |= empty)'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar --jq 1.6 -n '[1,2,3] | ((.[] | select(. > 1)) |= empty)'
jq: error: `|= empty` is undefined. See https://github.com/stedolan/jq/issues/897
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar --jq 1.5 -n '[1,2,3] | ((.[] | select(. > 1)) |= empty)'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar --jq 1.5 -n '[1,2,3] | ((.[] | select(. > 1)) |= empty)'
jq: error: `|= empty` is undefined. See https://github.com/stedolan/jq/issues/897
```

Expand All @@ -397,9 +397,9 @@ jq: error: `|= empty` is undefined. See https://github.com/stedolan/jq/issues/89
You can use `_modify/2` if you really want to the original behavior.

```console
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar --jq 1.6 -n '[1,2,3] | _modify((.[] | select(. > 1)); empty)'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar --jq 1.6 -n '[1,2,3] | _modify((.[] | select(. > 1)); empty)'
[ 1, 3 ]
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar --jq 1.5 -n '[1,2,3] | _modify((.[] | select(. > 1)); empty)'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar --jq 1.5 -n '[1,2,3] | _modify((.[] | select(. > 1)); empty)'
null
```

Expand All @@ -419,7 +419,7 @@ jq 1.5
```console
$ jq-1.5 -c 'path(.foo as $a | $a)' <<< '{"foo": 1}'
["foo"]
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar --jq 1.5 -c 'path(.foo as $a | $a)' <<< '{"foo": 1}'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar --jq 1.5 -c 'path(.foo as $a | $a)' <<< '{"foo": 1}'
jq: error: Invalid path expression with result 1
```

Expand All @@ -428,7 +428,7 @@ jq 1.6
```console
$ jq-1.6 -c 'path(.foo as $a | $a)' <<< '{"foo": 1}'
jq: error (at <stdin>:1): Invalid path expression with result 1
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar --jq 1.6 -c 'path(.foo as $a | $a)' <<< '{"foo": 1}'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar --jq 1.6 -c 'path(.foo as $a | $a)' <<< '{"foo": 1}'
jq: error: Invalid path expression with result 1
```

Expand All @@ -452,7 +452,7 @@ $ jq -n 'label $a | label $b | try (break $b) catch .'
{
"__jq": 1
}
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n 'label $a | label $b | try (break $b) catch .'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar -n 'label $a | label $b | try (break $b) catch .'
{
"__jq" : 0
}
Expand Down Expand Up @@ -482,7 +482,7 @@ $ jq-1.6 -n '"x" | indices("")' # stuck in infinite loop
^C
$ jq-1.6-83-gb52fc10 -n '"x" | indices("")'
[]
$ java -jar jackson-jq-cli-1.0.0-preview.20220705.jar -n '"x" | indices("")'
$ java -jar jackson-jq-cli-1.0.0-preview.20230409.jar -n '"x" | indices("")'
[ ]
```

Expand All @@ -499,7 +499,7 @@ To use this module, you need to add the following Maven dependency and set `Buil
<dependency>
<groupId>net.thisptr</groupId>
<artifactId>jackson-jq-extra</artifactId>
<version>1.0.0-preview.20220705</version>
<version>1.0.0-preview.20230409</version>
</dependency>
```

Expand Down
13 changes: 7 additions & 6 deletions bin/jackson-jq
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash
set -euo pipefail

scriptpath=`readlink -f $0`
scriptdir=`dirname $scriptpath`
scriptpath=$(readlink -f -- "${BASH_SOURCE[0]}")
scriptdir=$(dirname -- "$scriptpath")

jarpath=`find $scriptdir/../jackson-jq-cli -name "jackson-jq-cli-*.jar" | grep -v sources | grep -v javadoc`
if [ -z $jarpath ]; then
echo "ERROR: jackson-jar-cli-\${version}.jar does not exist; please run 'mvn package' first." 1>&2
jarpath=$(find "$scriptdir/../jackson-jq-cli" -name "jackson-jq-cli-*.jar" -not -name "*sources*" -not -name "*javadoc*")
if [[ -z "$jarpath" ]]; then
echo "ERROR: jackson-jar-cli-\${version}.jar does not exist; please run 'mvn package' first." >&2
exit 1
fi

java -jar $jarpath "$@"
exec java -jar "$jarpath" "$@"
4 changes: 2 additions & 2 deletions jackson-jq-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<parent>
<groupId>net.thisptr</groupId>
<artifactId>jackson-jq-parent</artifactId>
<version>1.0.0-preview.20220705</version>
<version>1.0.0-preview.20230409</version>
</parent>

<dependencies>
<dependency>
<groupId>net.thisptr</groupId>
<artifactId>jackson-jq-extra</artifactId>
<version>1.0.0-preview.20220705</version>
<version>1.0.0-preview.20230409</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,23 @@
import net.thisptr.jackson.jq.Versions;
import net.thisptr.jackson.jq.exception.JsonQueryException;
import net.thisptr.jackson.jq.internal.functions.EnvFunction;
import net.thisptr.jackson.jq.internal.misc.JsonQueryJacksonModule;
import net.thisptr.jackson.jq.module.ModuleLoader;
import net.thisptr.jackson.jq.module.loaders.BuiltinModuleLoader;
import net.thisptr.jackson.jq.module.loaders.ChainedModuleLoader;
import net.thisptr.jackson.jq.module.loaders.FileSystemModuleLoader;

public class Main {
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final ObjectMapper MAPPER = new ObjectMapper()
.registerModule(JsonQueryJacksonModule.getInstance());

private static final Option OPT_COMPACT = Option.builder("c")
.longOpt("compact")
.desc("compact instead of pretty-printed output")
.build();

private static final Option OPT_RAW = Option.builder("r")
.longOpt("raw")
private static final Option OPT_RAW_OUTPUT = Option.builder("r")
.longOpt("raw-output")
.desc("output raw strings, not JSON texts")
.build();

Expand All @@ -66,7 +68,7 @@ public class Main {
public static void main(String[] args) throws IOException, ParseException {
final Options options = new Options();
options.addOption(OPT_COMPACT);
options.addOption(OPT_RAW);
options.addOption(OPT_RAW_OUTPUT);
options.addOption(OPT_NULL_INPUT);
options.addOption(OPT_VERSION);
options.addOption(OPT_HELP);
Expand Down Expand Up @@ -126,7 +128,7 @@ public static void main(String[] args) throws IOException, ParseException {
continue;
try {
jq.apply(scope, tree, (out) -> {
if (out.isTextual() && command.hasOption(OPT_RAW.getOpt())) {
if (out.isTextual() && command.hasOption(OPT_RAW_OUTPUT.getOpt())) {
System.out.println(out.asText());
} else {
try {
Expand Down
4 changes: 2 additions & 2 deletions jackson-jq-extra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<parent>
<groupId>net.thisptr</groupId>
<artifactId>jackson-jq-parent</artifactId>
<version>1.0.0-preview.20220705</version>
<version>1.0.0-preview.20230409</version>
</parent>

<dependencies>
<dependency>
<groupId>net.thisptr</groupId>
<artifactId>jackson-jq</artifactId>
<version>1.0.0-preview.20220705</version>
<version>1.0.0-preview.20230409</version>
</dependency>
</dependencies>

Expand Down
4 changes: 2 additions & 2 deletions jackson-jq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<parent>
<groupId>net.thisptr</groupId>
<artifactId>jackson-jq-parent</artifactId>
<version>1.0.0-preview.20220705</version>
<version>1.0.0-preview.20230409</version>
</parent>

<dependencies>
<dependency>
<groupId>org.jruby.joni</groupId>
<artifactId>joni</artifactId>
<version>2.1.43</version>
<version>2.1.48</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Loading

0 comments on commit 77cc11e

Please sign in to comment.