aws / aws-msk-iam-auth

Enables developers to use AWS Identity and Access Management (IAM) to connect to their Amazon Managed Streaming for Apache Kafka (Amazon MSK) clusters.
Apache License 2.0
141 stars 66 forks source link

Gradle build failing - Lombok & tests #78

Open chrisaddams opened 2 years ago

chrisaddams commented 2 years ago

I'm hitting an issue when cloning the repo and running either gradle clean build or gradle clean shadowJar.

The output I'm getting is as follows:

Starting a Gradle Daemon (subsequent builds will be faster)
> Task :clean UP-TO-DATE
> Task :generateLombokConfig

> Task :compileJava
/aws/aws-msk-iam-auth/src/main/java/software/amazon/msk/auth/iam/internals/AuthenticationResponse.java:28: error: cannot find symbol
@Getter(onMethod = @__(@JsonIgnore))
                    ^
  symbol: class __
1 error

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x469ee170) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x469ee170

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> 3 actionable tasks: 2 executed, 1 up-to-date
Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 6s

This is running using Java:17, and Gradle 7.3

I am able to get passed this stage by upgrading Lombok in build.gradle to id "io.freefair.lombok" version "6.5.0.3"

However, then I hit another error when running gradle clean build

35 tests completed, 13 failed

> Task :test FAILED

FAILURE: Build failed with an exception.

Whereas gradle clean shadowJar now outputs a successful build

strokyl commented 1 year ago

Made it compile with more recent JDK using this diff:

diff --git a/build.gradle b/build.gradle
index ab06c53..5b60204 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,6 @@
 plugins {
     id 'java-library'
-    id "io.freefair.lombok" version "5.3.0"
+    id "io.freefair.lombok" version "6.4.0"
     id 'com.github.johnrengelman.shadow' version '6.1.0'
     id 'maven-publish'
     id 'signing'
diff --git a/src/main/java/software/amazon/msk/auth/iam/internals/AuthenticationResponse.java b/src/main/java/software/amazon/msk/auth/iam/internals/AuthenticationResponse.java
index e60eb83..fc35c16 100644
--- a/src/main/java/software/amazon/msk/auth/iam/internals/AuthenticationResponse.java
+++ b/src/main/java/software/amazon/msk/auth/iam/internals/AuthenticationResponse.java
@@ -25,7 +25,7 @@ import lombok.ToString;
 /**
  * This class is used to model the authentication response sent by the broker.
  */
-@Getter(onMethod = @__(@JsonIgnore))
+@Getter(onMethod_ = {@JsonIgnore})
 @ToString
 public class AuthenticationResponse {
     private static final String VERSION_1 = "2020_10_22";

But still got test failures:

MSKCredentialProviderTest > testEc2CredsWithSixRetriableErrorsCustomRetry_ThrowsException() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:519
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:519
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:519
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:519

MSKCredentialProviderTest > testAwsRoleArn() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:160
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:160
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:160
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:160

MSKCredentialProviderTest > testRoleCredsWithThreeRetriableErrors() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:504
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:504
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:504
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:504

MSKCredentialProviderTest > testAwsRoleArnAndSessionName() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:250
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:250
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:250
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:250

MSKCredentialProviderTest > testEc2CredsWithDebuCredsNoAccessToSts_Succeed() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:217
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:217
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:217
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:217

MSKCredentialProviderTest > testProfileNameAndRoleArn() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:305
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:305
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:305
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:305

MSKCredentialProviderTest > testEc2CredsWithFiveRetriableErrorsCustomRetry() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:519
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:519
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:519
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:519

MSKCredentialProviderTest > testAwsRoleArnSessionNameAndStsRegion() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:273
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:273
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:273
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:273

MSKCredentialProviderTest > testEc2CredsWithOnrRetriableErrorsCustomZeroRetry_ThrowsException() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:519
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:519
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:519
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:519

MSKCredentialProviderTest > testRoleCredsWithFourRetriableErrors_ThrowsException() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:504
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:504
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:504
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:504

MSKCredentialProviderTest > testAwsRoleArnWithDebugCreds() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:182
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:182
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:182
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:182

MSKCredentialProviderTest > testEc2CredsWithTwoRetriableErrorsCustomRetry() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:519
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:519
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:519
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:519

MSKCredentialProviderTest > testRoleCredsWithTwoRetriableErrors() FAILED
    org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:504
        Caused by: org.mockito.exceptions.base.MockitoException at MSKCredentialProviderTest.java:504
            Caused by: java.lang.IllegalStateException at MSKCredentialProviderTest.java:504
                Caused by: java.lang.IllegalArgumentException at MSKCredentialProviderTest.java:504
s-ifti commented 1 year ago

For anyone facing a similar issue with test as noted by strokyl, this is likely related to gradle version requiring compatible io.freefair.lombok version and mockito-inline version.

I am able to build and test latest main branch using following versions :

Gradle version 7.3.3
io.freefair.lombok version 6.6.3  (build.gradle file)
org.mockito:mockito-inline:5.2.0

openjdk 17.0.7 2023-04-18