Building Developer Cloud Applications Using Gradle

The Spring Boot Getting Started application includes build files for both Maven and Gradle. Given that the Oracle Developer Cloud Service also supports Gradle I thought this would be a good opportunity to demonstrate it in action.

I’m going to pick up where I left off in my previous entry, simply creating a new build that will use Gradle instead of Maven.

Step 1: Configure for Deployment to the Application Container Cloud Service (ACCS)


This file already exists and doesn’t need to change.

Deployment Archive

Just like with Maven, we need to instruct Gradle to package our application into a zip file for deployment to ACCS. With Gradle, this is achieved using the Zip plugin.

Edit build.gradle and add the following:

apply plugin: 'spring-boot'

task zip(type: Zip) {
    from jar.outputs.files   
    from( 'manifest.json' ) 

Step 2: Commit and Push the Changes

You know the drill.

Step 3: Create the Build

I could modify the existing Maven build, but instead I’m going to create a new build from the existing build.

Create a new Build Job by copying the Spring Boot GS. Name it something like Spring Boot GS (Gradle).


Switch to the Build Steps tab, delete the Invoke Maven 3 step and add a Gradle build step. Set the Tasks to build zip. Everything else can remain as is:


Switch to the Post Build tab select Archive the Artifacts. Change the Files to Archive to build/distributions/*.zip:


Save the configuration and click Build Now.

The build fails with the following:

> Connect to [] failed: Connection timed out

The Gradle plug-in doesn’t (yet) pick up the proxy settings from the build engine so we need to provide this information to Gradle. The Developer Cloud Service exposes environment variables that include proxy information:


Using these variables we can dynamically create a file as follows (see Accessing the web via a proxy):

# Generate a file for the DevCS environment running the build...
echo "systemProp.http.proxyHost="$HTTPS_PROXY_HOST >>
echo "systemProp.http.proxyPort="$HTTP_PROXY_PORT >>
echo "systemProp.http.nonProxyHosts="$NO_PROXY >>
echo "systemProp.https.proxyHost="$HTTPS_PROXY_HOST >>
echo "systemProp.https.proxyPort="$HTTPS_PROXY_PORT >>
echo "systemProp.http.nonProxyHosts="$NO_PROXY >>

I’m going to add these commands to a shell script,, which I will execute before I call the Gradle build.

Once the script is created and pushed to the repository, return to the Build Steps tab. Unfortunately, there’s not a way to insert a step before an existing step, so delete the Invoke Gradle build step and add an Execute shell step. Set the Command to sh Then add back the Invoke Gradle step as we did before:


Click Save and Build Now (if the Build Now button is disabled, click the Enable Build button).

Yikes, another failed build. It seems Gradle is configured to run an additional integration test which Maven was not. So wee also need to update the with our new greeting:

    public void getHello() throws Exception {
        ResponseEntity<String> response = template.getForEntity(base.toString(),
        assertThat(response.getBody(), equalTo("Greetings from Spring Boot running on ACCS!"));

Commit and push to GitHub, which should trigger the build again (third time’s a charm, right?).



2 thoughts on “Building Developer Cloud Applications Using Gradle

  1. S Das

    Dear Brian,
    I am still getting an error in connecting to maven central repo (both https ans http) even after setting the proxy params for gradle using sh as you described. Any suggestions please?
    Thanks in advance.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s