Search code examples
javaamazon-web-servicesgradleintellij-ideaamazon-polly

How to setup Amazon Polly SDK with Gradle in IntetlliJ


I am trying to setup AWS Polly Java SDK with Gradle in IntelliJ by following this. I have already created a simple Spring Boot application using the spring intializr, so I added the items specified in the tutorial to my build.gradle file. When try to import

import com.amazonaws.services.polly.AmazonPollyClient

IntelliJ fails to resolve name polly.

This is my full build.gradle file

buildscript {
    ext {
        springBootVersion = '2.0.4.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'io.ai.vivid'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencyManagement {
    imports {
        mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.228'
    }
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    compile 'com.amazonaws:aws-java-sdk-s3'
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

Also IntelliJ complains that it can't resolve the name manvenBom in my build.gradle. I have already tried SO solutions to this like invalidate cache/restart but could not resolve the issue.


Solution

  • I used your build.gradle file to replicate the issue and was able to import AmazonPollyClient after making the following changes to the dependencies

    dependencies {
    compile 'com.amazonaws:aws-java-sdk-s3'
    compile group: 'com.amazonaws', name: 'aws-java-sdk-polly', version: '1.11.67'
    

    The Gradle version used 4.8