How to force gradle to look for plugins and dependencies in company's nexus server

Hi

I am trying to use my company’s nexus server to download plugins and dependencies instead of gradle.org when I build my project. Here is my build.gradle file:

plugins {
    id 'java'
    id 'war'
    id 'org.akhikhl.gretty' version '1.4.2'
}

repositories {
      maven { url "https://nexus.mycompany.com/nexus" }
}

dependencies {
    providedCompile 'javax.servlet:javax.servlet-api:3.1.0' 
    testCompile 'junit:junit:4.12'
}

When I build using gradlew.bat it shows the following error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'webdemo'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve org.akhikhl.gretty:gretty-core:1.4.2.
     Required by:
         project : > gradle.plugin.org.akhikhl.gretty:gretty:1.4.2
      > Could not resolve org.akhikhl.gretty:gretty-core:1.4.2.
         > Could not get resource 'https://plugins.gradle.org/m2/org/akhikhl/gre
tty/gretty-core/1.4.2/gretty-core-1.4.2.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/akhikhl/gretty/gr
etty-core/1.4.2/gretty-core-1.4.2.pom'.
               > sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target
   > Could not resolve org.springframework.boot:spring-boot-loader-tools:1.2.3.R
ELEASE.
     Required by:
         project : > gradle.plugin.org.akhikhl.gretty:gretty:1.4.2
      > Could not resolve org.springframework.boot:spring-boot-loader-tools:1.2.
3.RELEASE.
         > Could not get resource 'https://plugins.gradle.org/m2/org/springframe
work/boot/spring-boot-loader-tools/1.2.3.RELEASE/spring-boot-loader-tools-1.2.3.
RELEASE.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/springframework/b
oot/spring-boot-loader-tools/1.2.3.RELEASE/spring-boot-loader-tools-1.2.3.RELEAS
E.pom'.
               > sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target
   > Could not resolve org.springframework.boot:spring-boot-dependency-tools:1.2
.3.RELEASE.
     Required by:
         project : > gradle.plugin.org.akhikhl.gretty:gretty:1.4.2
      > Could not resolve org.springframework.boot:spring-boot-dependency-tools:
1.2.3.RELEASE.
         > Could not get resource 'https://plugins.gradle.org/m2/org/springframe
work/boot/spring-boot-dependency-tools/1.2.3.RELEASE/spring-boot-dependency-tool
s-1.2.3.RELEASE.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/springframework/b
oot/spring-boot-dependency-tools/1.2.3.RELEASE/spring-boot-dependency-tools-1.2.
3.RELEASE.pom'.
               > sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target
   > Could not resolve org.eclipse.jetty:jetty-util:8.1.8.v20121106.
     Required by:
         project : > gradle.plugin.org.akhikhl.gretty:gretty:1.4.2
      > Could not resolve org.eclipse.jetty:jetty-util:8.1.8.v20121106.
         > Could not get resource 'https://plugins.gradle.org/m2/org/eclipse/jet
ty/jetty-util/8.1.8.v20121106/jetty-util-8.1.8.v20121106.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/eclipse/jetty/jet
ty-util/8.1.8.v20121106/jetty-util-8.1.8.v20121106.pom'.
               > sun.security.validator.ValidatorException: PKIX path building f
ailed: sun.security.provider.certpath.SunCertPathBuilderException: unable to fin
d valid certification path to requested target

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 4.968 secs

It seems that gradle tries to download the plugins from https://plugins.gradle.org but I want to force it to look for everything, i.e. plugins and dependencies, in my company’s nexus server. How could I do that?

I am using gradle 3.5 and JDK 1.8.0_66 x64

Ferez