Skip to content

Removed Guava (left in tests), bump Gradle and all deps. (this is 2nd part of https://github.com/java-json-tools/jackson-coreutils/pull/3) #47

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
52 changes: 28 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,29 @@ apply(plugin: "eclipse");

group = "com.github.java-json-tools";
version = "1.11-SNAPSHOT";
sourceCompatibility = "1.6";
targetCompatibility = "1.6"; // defaults to sourceCompatibility
sourceCompatibility = JavaVersion.VERSION_1_6;
targetCompatibility = JavaVersion.VERSION_1_6; // defaults to sourceCompatibility

/*
* List of dependencies
*/
dependencies {
provided(group: "com.google.code.findbugs", name: "jsr305", version: "2.0.1");
compile(group: "com.github.java-json-tools", name: "jackson-coreutils", version: "1.9");
testCompile(group: "org.testng", name: "testng", version: "6.8.7") {
provided(group: "com.google.code.findbugs", name: "jsr305", version: "3.0.2");
implementation(group: "com.github.java-json-tools", name: "jackson-coreutils", version: "1.10-SNAPSHOT");
testImplementation(group: "com.google.guava", name: "guava", version: "16.0.1");
testImplementation(group: "org.testng", name: "testng", version: "7.0.0-beta1") {
exclude(group: "junit", module: "junit");
exclude(group: "org.beanshell", module: "bsh");
exclude(group: "org.yaml", module: "snakeyaml");
};
testCompile(group: "org.mockito", name: "mockito-core", version: "1.9.5");
testCompile(group: "org.assertj", name: "assertj-core", version: "1.7.0");
testImplementation(group: "org.mockito", name: "mockito-core", version: "2.23.4");
testImplementation(group: "org.assertj", name: "assertj-core", version: "3.11.1");
}

javadoc.options.links("http://docs.oracle.com/javase/6/docs/api/");
javadoc.options.links("http://jsr-305.googlecode.com/svn/trunk/javadoc/");
javadoc.options.links("http://fasterxml.github.com/jackson-databind/javadoc/2.2.0/");
javadoc.options.links("http://fasterxml.github.com/jackson-core/javadoc/2.2.0/");
javadoc.options.links("http://fasterxml.github.com/jackson-annotations/javadoc/2.2.0/");
javadoc.options.links("http://docs.guava-libraries.googlecode.com/git-history/v16.0.1/javadoc/");
javadoc.options.links("http://fge.github.io/msg-simple/");
javadoc.options.links("http://fge.github.io/jackson-coreutils/");

Expand All @@ -75,6 +74,7 @@ javadoc.options.links("http://fge.github.io/jackson-coreutils/");
*/
repositories {
mavenCentral();
mavenLocal()
}

/*
Expand Down Expand Up @@ -115,13 +115,15 @@ artifacts {
archives javadocJar;
}

task wrapper(type: Wrapper) {
gradleVersion = "3.5";
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
wrapper {
gradleVersion = "5.0";
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
}

task pom << {
pom {}.writeTo("${projectDir}/pom.xml");
task pom {
doLast {
pom {}.writeTo("${projectDir}/pom.xml");
}
}

/*
Expand All @@ -136,18 +138,20 @@ project.ext {
sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/";
};

task checkSigningRequirements << {
def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
def noDice = false;
requiredProperties.each {
if (project.properties[it] == null) {
noDice = true;
System.err.printf("property \"%s\" is not defined!")
task checkSigningRequirements {
doLast {
def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
def noDice = false;
requiredProperties.each {
if (project.properties[it] == null) {
noDice = true;
System.err.printf("property \"%s\" is not defined!")
}
}
if (noDice)
throw new IllegalStateException("missing required properties for " +
"upload");
}
if (noDice)
throw new IllegalStateException("missing required properties for " +
"upload");
}

uploadArchives {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri May 11 21:07:09 PDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-3.5-all.zip
78 changes: 43 additions & 35 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand All @@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
Expand All @@ -40,31 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
Expand All @@ -90,7 +89,7 @@ location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
Expand All @@ -114,6 +113,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
Expand Down Expand Up @@ -154,11 +154,19 @@ if $cygwin ; then
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"
14 changes: 4 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

Expand Down Expand Up @@ -46,10 +46,9 @@ echo location of your Java installation.
goto fail

:init
@rem Get command-line arguments, handling Windowz variants
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
Expand All @@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line
Expand Down
Empty file added settings.gradle
Empty file.
7 changes: 5 additions & 2 deletions src/main/java/com/github/fge/jsonpatch/AddOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import com.github.fge.jackson.jsonpointer.JsonPointer;
import com.github.fge.jackson.jsonpointer.ReferenceToken;
import com.github.fge.jackson.jsonpointer.TokenResolver;
import com.google.common.collect.Iterables;

import java.util.NoSuchElementException;


/**
Expand Down Expand Up @@ -105,6 +106,7 @@ private JsonNode addToArray(final JsonPointer path, final JsonNode node)
{
final JsonNode ret = node.deepCopy();
final ArrayNode target = (ArrayNode) path.parent().get(ret);

final TokenResolver<JsonNode> token = Iterables.getLast(path);

if (token.getToken().equals(LAST_ARRAY_ELEMENT)) {
Expand All @@ -131,9 +133,10 @@ private JsonNode addToArray(final JsonPointer path, final JsonNode node)

private JsonNode addToObject(final JsonPointer path, final JsonNode node)
{
final TokenResolver<JsonNode> token = Iterables.getLast(path);
final JsonNode ret = node.deepCopy();
final ObjectNode target = (ObjectNode) path.parent().get(ret);
target.put(Iterables.getLast(path).getToken().getRaw(), value);
target.set(token.getToken().getRaw(), value);
return ret;
}
}
29 changes: 29 additions & 0 deletions src/main/java/com/github/fge/jsonpatch/Iterables.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.github.fge.jsonpatch;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
* @author <a href="mailto:[email protected]">Sergey Nazin</a> on 30-Nov-18
*/
public final class Iterables {

private Iterables() {}

/**
* Returns the last element of {@code iterable}.
*
* @param iterable type of iterable
* @return the last element of {@code iterable}
* @throws NoSuchElementException if the iterable is empty
*/
public static <T> T getLast(Iterable<T> iterable) {
Iterator<T> iterator = iterable.iterator();
while (true) {
T current = iterator.next();
if (!iterator.hasNext()) {
return current;
}
}
}
}
7 changes: 4 additions & 3 deletions src/main/java/com/github/fge/jsonpatch/JsonPatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
import com.google.common.collect.ImmutableList;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
Expand Down Expand Up @@ -111,7 +112,7 @@ public final class JsonPatch
@JsonCreator
public JsonPatch(final List<JsonPatchOperation> operations)
{
this.operations = ImmutableList.copyOf(operations);
this.operations = Collections.unmodifiableList(new ArrayList<JsonPatchOperation>(operations));
}

/**
Expand All @@ -126,7 +127,7 @@ public static JsonPatch fromJson(final JsonNode node)
throws IOException
{
BUNDLE.checkNotNull(node, "jsonPatch.nullInput");
return JacksonUtils.getReader().withType(JsonPatch.class)
return JacksonUtils.getReader().forType(JsonPatch.class)
.readValue(node);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.fasterxml.jackson.databind.node.MissingNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import com.google.common.collect.Iterables;

import java.io.IOException;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/github/fge/jsonpatch/ReplaceOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import com.google.common.collect.Iterables;

/**
* JSON Patch {@code replace} operation
Expand Down Expand Up @@ -73,7 +72,7 @@ public JsonNode apply(final JsonNode node)
final JsonNode parent = path.parent().get(ret);
final String rawToken = Iterables.getLast(path).getToken().getRaw();
if (parent.isObject())
((ObjectNode) parent).put(rawToken, replacement);
((ObjectNode) parent).set(rawToken, replacement);
else
((ArrayNode) parent).set(Integer.parseInt(rawToken), replacement);
return ret;
Expand Down
Loading