aws-amplify / aws-amplify/docs

Adding a Java function fails to pull deps with Gradle 7

Open
#3,704 3 comments 0 reactions 0 assignees View on GitHub
amplify/cli p4
Dominant language
MDX
Stars
506
Forks
1.1k
Avg merge
3h 14m
Merged PRs (30d)
1

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### How did you install the Amplify CLI?

npm

### If applicable, what version of Node.js are you using?

12

### Amplify CLI Version

5.0

### What operating system are you using?

AL2

### Amplify Categories

function

### Amplify Commands

add, init, push

### Describe the bug

For a fresh Java lambda project, I followed the CLI's suggestions for installing dependencies. When it got to gradle, the gradle website suggests using 7.1 however that version fails to `compile` as the gradle file syntax has changed in 7.

### Expected behavior

Creating a new Java project works with the latest gradle out of the box. Worked around by downgrading to gradle v5.

### Reproduction steps

1. Create a new project folder
2. `amplify init`
3. `amplify add function`
4. Select java and defaults for the rest of the questions
5. `amplify push`
6. Notice build failure

### GraphQL schema(s)

```graphql
# Put schemas below this line

```

### Log output

```
# Put your logs below this line
Command failed with exit code 1: gradle build
FAILURE: Build failed with an exception.
* Where:
Build file '/local/home/srquinn/opensrc/testproject/amplify/backend/function/testproject56617327/build.gradle' line: 13
* What went wrong:
A problem occurred evaluating root project 'testproject56617327'.
> Could not find method compile() for arguments [com.amazonaws:aws-lambda-java-core:1.2.0, com.amazonaws:aws-lambda-java-events:2.2.7] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 516ms
An error occurred during the push operation: Command failed with exit code 1: gradle build
```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.