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

WIP: upgrade to Gradle 7 #1198

Closed
Closed
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- "11.0"
- "12.0"
- "13.0"
- "16.0"

steps:
- uses: actions/checkout@master
Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ buildscript {

plugins {
id "java"
id "maven"
id "maven-publish"
id "jacoco"
id "io.freefair.lombok" version "5.2.1"
id "com.diffplug.spotless" version "5.7.0"
id "net.ltgt.errorprone" version "1.3.0"
//id "net.ltgt.errorprone" version "1.3.0"
id "com.github.kt3k.coveralls" version "2.10.2"
id "biz.aQute.bnd.builder" version "5.2.0"
id "org.ajoberstar.git-publish" version "3.0.0"
Expand All @@ -30,7 +30,7 @@ version = VERSION_NAME
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all" << "-Xlint:-options" << "-Xlint:-processing"
options.encoding = "UTF-8"

/*
options.errorprone {
// This check causes warnings with autogenerated Javadoc strings.
check("InvalidParam", net.ltgt.gradle.errorprone.CheckSeverity.OFF)
Expand All @@ -45,7 +45,7 @@ tasks.withType(JavaCompile) {
// com.stripe.param.AccountUpdateParams.Individual.Address] within this file.)
// We should fix this by having autogen use the fully-qualified class to eliminate ambiguity.
check("SameNameButDifferent", net.ltgt.gradle.errorprone.CheckSeverity.OFF)
}
}*/
}

compileJava {
Expand All @@ -60,8 +60,8 @@ repositories {
}

dependencies {
errorprone group: "com.google.errorprone", name: "error_prone_core", version: "2.4.0"
errorproneJavac group: "com.google.errorprone", name: "javac", version:"9+181-r4173-1"
//errorprone group: "com.google.errorprone", name: "error_prone_core", version: "2.4.0"
//errorproneJavac group: "com.google.errorprone", name: "javac", version:"9+181-r4173-1"
implementation group: "com.google.code.gson", name: "gson", version:"2.8.6"
testImplementation group: "com.google.guava", name: "guava", version:"30.0-jre"
testImplementation group: "com.squareup.okhttp3", name: "mockwebserver", version: "4.9.0"
Expand All @@ -84,7 +84,7 @@ jar {
}

lombok {
version = "1.18.16"
version = "1.18.20"
config['lombok.addLombokGeneratedAnnotation'] = 'true'
config['lombok.getter.noIsPrefix'] = 'true'
}
Expand All @@ -95,7 +95,7 @@ delombok {
format = [:]
}

apply from: "deploy.gradle"
// apply from: "deploy.gradle"

test {
useJUnitPlatform()
Expand Down
4 changes: 2 additions & 2 deletions deploy.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle
*/

apply plugin: "maven"
apply plugin: "maven-publish"
apply plugin: "signing"
apply plugin: "io.codearte.nexus-staging"

Expand Down Expand Up @@ -42,7 +42,7 @@ afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
beforeDeployment { deployment -> signing.signPom(deployment) }

pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

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


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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
Expand Down
22 changes: 4 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,28 +64,14 @@ echo location of your Java installation.

goto fail

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

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/stripe/model/StripeCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public abstract class StripeCollection<T extends HasId> extends StripeObject

@Getter(onMethod_ = {@Override})
@Setter(onMethod = @__({@Override}))
private RequestOptions requestOptions;
private transient RequestOptions requestOptions;

@Getter(onMethod_ = {@Override})
@Setter(onMethod = @__({@Override}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class ApiResourceTypeAdapterFactoryProvider {
factories.add(new BalanceTransactionSourceTypeAdapterFactory());
factories.add(new ExternalAccountTypeAdapterFactory());
factories.add(new PaymentSourceTypeAdapterFactory());
factories.add(new ReflectionCheckingTypeAdapterFactory());
}

public static List<TypeAdapterFactory> getAll() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.stripe.net;

import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.bind.ReflectiveTypeAdapterFactory;
import com.google.gson.reflect.TypeToken;

/**
* {@link TypeAdapterFactory} that checks that we don't use {@link ReflectiveTypeAdapterFactory}
* accidentally for classes outside {@code com.stripe} packages. This usually happens when we forget
* to mark a field {@code transient}.
*/
class ReflectionCheckingTypeAdapterFactory implements TypeAdapterFactory {
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if (!type.getType().getTypeName().startsWith("com.stripe.")) {
TypeAdapter<T> adapter = gson.getDelegateAdapter(this, type);
if (adapter instanceof ReflectiveTypeAdapterFactory.Adapter) {
throw new IllegalArgumentException(
"Refusing to create type reflection-based type adapter for external class: " + type);
}
}
return null;
}
}