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

Gradle setup works only with 5.x, 6.x but not with 7.x #146

Closed
pankajagrawal16 opened this issue Oct 22, 2020 · 13 comments
Closed

Gradle setup works only with 5.x, 6.x but not with 7.x #146

pankajagrawal16 opened this issue Oct 22, 2020 · 13 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@pankajagrawal16
Copy link
Contributor

pankajagrawal16 commented Oct 22, 2020

Gradle example provided works only when you are on gradle 5.x.

aspectj.AspectjGradlePlugin has to be pinned to version 0.0.3.

aspectj.AspectjGradlePlugin from version 0.0.4 is compiled on Java 12. Which makes plugin incompatible to use with lambda functions on runtime lower than Java 12.

Also version 0.0.3 had a bug which made it incompatible to work both on gradle versions 5.x and 6.x. Although this is now fixed in version 0.0.5, but the versions above 0.0.4 of plugin can only work with java 12 or above.

Here is the open issue to make plugin work with Java 11 or lower.

What were you trying to accomplish?

Expected Behavior

Should work with gradle 6.x as well.

Current Behavior

Fails with error on gradle 6.x


An exception occurred applying plugin request [id: 'aspectj.AspectjGradlePlugin', version: '0.0.3']
> Failed to apply plugin [id 'aspectj.AspectjGradlePlugin']
   > Could not create task ':compileAspect'.
      > Unnecessarily replacing a task that does not exist is not supported.  Use create() or register() directly instead.  You attempted to replace a task named 'compileAspect', but there is no existing task with that name.


Possible Solution

None as of now. Use gradle 5.x. with gradle 6.x users have to upgrade AWS lambda function runtime to Java 12 or above and use latest version of aspectj.AspectjGradlePlugin plugin.

Environment

  • Powertools version used: latest
  • Packaging format (Layers, Maven/Gradle): Gradle
  • AWS Lambda function runtime: Java 11 or lower
  • Debugging logs
@pankajagrawal16 pankajagrawal16 added the bug Something isn't working label Oct 22, 2020
@pankajagrawal16 pankajagrawal16 changed the title Gradle setup works only with 5.x Gradle setup works only with 5.x and not with 6.x Oct 22, 2020
@pankajagrawal16
Copy link
Contributor Author

Latest version 0.0.6 of AspectjGradlePlugin works with Java 11 and Gradle 6.x.

Unfortunately it wont be supported for Java 8 since java 11 is the current LTS version. Ref issue

@michaelbrewer
Copy link
Contributor

And it does not work at all with Gradle 7+

@pankajagrawal16
Copy link
Contributor Author

And it does not work at all with Gradle 7+

Yeah I need to dive a bit deeper into this and see how we can get it to work with gradle 7+

@pankajagrawal16
Copy link
Contributor Author

All gradle 5 and 6 related issues should now be fixed with using latest version of AspectGradlePlugin with version 0.0.7 https://github.com/awslabs/aws-lambda-powertools-java/releases/tag/v1.9.0

@pankajagrawal16 pankajagrawal16 changed the title Gradle setup works only with 5.x and not with 6.x Gradle setup works only with 5.x, 6.x but not with 7.x Dec 21, 2021
@michaelbrewer
Copy link
Contributor

@pankajagrawal16 still not working for me? Could we try https://docs.freefair.io/gradle-plugins/5.0.1/reference/#_aspectj instead?

@pankajagrawal16
Copy link
Contributor Author

@pankajagrawal16 still not working for me? Could we try https://docs.freefair.io/gradle-plugins/5.0.1/reference/#_aspectj instead?

Hey, this is the plugin which I was going to look into, but i am not working this week, so will check once back.

@michaelbrewer
Copy link
Contributor

@pankajagrawal16 @msailes - i have created a PR to potentially fix the gradle plugin used for AspectJ

@pankajagrawal16
Copy link
Contributor Author

@michaelbrewer It works with freefair gradle plugin. I have validated it and change is pretty simple. Would you mind validating it as well ? I am thinking we can officially update our docs to used free fair instead coz it seems to be actively maintained and works on gradle 5,6 and 7 as well

@pankajagrawal16
Copy link
Contributor Author

pankajagrawal16 commented Jan 5, 2022

This is what my sample build.gradle looks like for a sample hellp world gradle app via

sam init --location gh:aws-samples/cookiecutter-aws-sam-powertools-java

plugins{
    id 'java'

    id "io.freefair.aspectj.post-compile-weaving" version "5.0.1"
}

repositories {
    mavenCentral()
}

aspectj {
    version  = "1.9.7"
}

dependencies {
    aspect "software.amazon.lambda:powertools-logging:1.10.0"
    aspect 'software.amazon.lambda:powertools-tracing:1.10.0'
    aspect 'software.amazon.lambda:powertools-metrics:1.10.0'

    implementation 'com.amazonaws:aws-lambda-java-core:1.2.1'
    implementation 'com.amazonaws:aws-lambda-java-events:3.11.0'

    implementation 'org.apache.logging.log4j:log4j-api:2.17.0'
    implementation 'org.apache.logging.log4j:log4j-core:2.17.0'

    testImplementation 'junit:junit:4.13.2'
}

@pankajagrawal16
Copy link
Contributor Author

Docs and cookiecutter projects are now update to use the new config which should work for all gradle versions 5, 6 and 7.

cc @michaelbrewer Closing this now, Let me know if you face any issues.

@michaelbrewer
Copy link
Contributor

@pankajagrawal16 - FYI my PR for aspectj.AspectjGradlePlugin was merged

@pankajagrawal16
Copy link
Contributor Author

woho.. nice.. then probably we have two ways of configuring gradle project. I am still in favor of keeping freefair now since its much more active.

@michaelbrewer
Copy link
Contributor

Yep, i agree, when i tried freefair initially i could not verify locally it was working (only when deployed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants