diff --git a/README.md b/README.md index 271f69f9..b7bf1c25 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ If you would like to use a tool that creates a graphql spring boot server using ```groovy dependencies { - compile "io.github.graphql-java:graphql-java-annotations:8.0.1" + compile "io.github.graphql-java:graphql-java-annotations:8.1" } ``` @@ -47,7 +47,7 @@ dependencies { io.github.graphql-java graphql-java-annotations - 8.0.1 + 8.1 ``` @@ -250,7 +250,7 @@ public String field(@GraphQLDefaultValue(DefaultValue.class) String value) { The `DefaultValue` class can define a `getInstance` method that will be called instead of the default constructor. `@GraphQLDeprecate` and Java's `@Deprecated` can be used to specify a deprecated -field. +field or method. ### Custom data fetcher diff --git a/build.gradle b/build.gradle index 100e075e..580bde5d 100644 --- a/build.gradle +++ b/build.gradle @@ -6,19 +6,18 @@ buildscript { mavenCentral() } dependencies { - classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:3.1.0' + classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:5.1.2' } } plugins { - id "com.jfrog.bintray" version "1.8.4" - id 'net.researchgate.release' version '2.3.4' - id "com.github.hierynomus.license" version "0.14.0" + id 'com.jfrog.bintray' version '1.8.5' + id 'net.researchgate.release' version '2.8.1' + id 'com.github.hierynomus.license' version '0.15.0' } apply plugin: 'java' apply plugin: 'idea' -apply plugin: 'osgi' apply plugin: 'biz.aQute.bnd.builder' apply plugin: 'com.jfrog.bintray' apply plugin: 'maven-publish' @@ -43,12 +42,6 @@ release { failOnCommitNeeded = false } -jar { - manifest { - instruction 'Import-Package', 'javax.validation.constraints', '*' - } -} - repositories { mavenCentral() } @@ -182,7 +175,6 @@ task bundle(type: Bundle) { bndfile = file('bundle.bnd') } -task wrapper(type: Wrapper) { - gradleVersion = '2.0' +wrapper { + gradleVersion = '6.5.1' } - diff --git a/gradle.properties b/gradle.properties index 23a92e9e..4ce8d4f0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ org.gradle.daemon=true org.gradle.parallel=true org.gradle.jvmargs=-Dfile.encoding=UTF-8 -version = 8.0.1 +version = 8.1 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 6ffa2378..f3d88b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c5e1301f..bb8b2fc2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu Jun 22 22:50:08 AEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip diff --git a/gradlew b/gradlew index 9aa616c2..2fe81a7d 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,20 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## ## @@ -28,16 +44,16 @@ 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="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,32 +154,30 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 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 "$@"` -# 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 +# 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" -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f9553162..9618d8d9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -14,7 +30,7 @@ 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= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/src/main/java/graphql/annotations/annotationTypes/GraphQLDeprecate.java b/src/main/java/graphql/annotations/annotationTypes/GraphQLDeprecate.java index fbbb91c6..25a2ae5f 100644 --- a/src/main/java/graphql/annotations/annotationTypes/GraphQLDeprecate.java +++ b/src/main/java/graphql/annotations/annotationTypes/GraphQLDeprecate.java @@ -19,7 +19,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -@Target(ElementType.METHOD) +@Target({ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface GraphQLDeprecate { String value() default ""; diff --git a/src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DeprecateBuilderTest.java b/src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DeprecateBuilderTest.java index cc47e32e..c2b3cda7 100644 --- a/src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DeprecateBuilderTest.java +++ b/src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DeprecateBuilderTest.java @@ -17,6 +17,7 @@ import graphql.annotations.annotationTypes.GraphQLDeprecate; import org.testng.annotations.Test; +import java.lang.reflect.Field; import java.lang.reflect.Method; import static org.testng.AssertJUnit.assertEquals; @@ -24,6 +25,14 @@ public class DeprecateBuilderTest { + @GraphQLDeprecate("test field deprecated") + public String testField; + + @GraphQLDeprecate + public String testField1; + + public String testField2; + @GraphQLDeprecate("test deprecated") public int testMethod() { return 1; @@ -56,7 +65,6 @@ public void build_graphQLDeprecateAnnotationExistsWithValue_returnAnnotationValu assertEquals(deprecate, "test deprecated"); } - @Test public void build_graphQLDeprecateAnnotationExistsWithNoValue_returnEmptyString() throws NoSuchMethodException { // arrange @@ -95,4 +103,43 @@ public void build_noDeprecatedAnnotation_returnNull() throws NoSuchMethodExcepti // assert assertNull(deprecate); } + + @Test + public void build_deprecatedAnnotationDoesNotExistsOnField_returnNull() throws NoSuchFieldException { + // arrange + Field field = getClass().getField("testField2"); + DeprecateBuilder deprecateBuilder = new DeprecateBuilder(field); + + // act + String deprecate = deprecateBuilder.build(); + + // assert + assertNull(deprecate); + } + + @Test + public void build_graphQLDeprecateAnnotationExistsOnFieldWithNoValue_returnEmptyString() throws NoSuchFieldException { + // arrange + Field field = getClass().getField("testField1"); + DeprecateBuilder deprecateBuilder = new DeprecateBuilder(field); + + // act + String deprecate = deprecateBuilder.build(); + + // assert + assertEquals(deprecate, "Deprecated"); + } + + @Test + public void build_graphQLDeprecateAnnotationExistsOnFieldWithValue_returnAnnotationValue() throws NoSuchFieldException { + // arrange + Field field = getClass().getField("testField"); + DeprecateBuilder deprecateBuilder = new DeprecateBuilder(field); + + // act + String deprecate = deprecateBuilder.build(); + + // assert + assertEquals(deprecate, "test field deprecated"); + } }