opendevstack / opendevstack/ods-quickstarters

Download Gradle Plugins from Nexus

Open
#785 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Shell
Stars
39
Forks
50
PR merge metrics
No merged PRs in 30d

Description

EDIT: This issue was named "Can't locally pull gradle plugins from inside corporate network" beforehand but the plugin URL seems to be whitelisted by now and hence it is not a blocking bug anymore but rather a improvement request.

Describe the bug
It is not possible anymore for us to build locally via gradle because the gradle repository is being blocked by our corporate network (or a service that is being used for security on top). A service application was recently installed on our laptops that adds further security on top of the VPN connection and it might be happening since then, but that is just a guess.

To be more precise, if I use gradle and have a plugin version in my build.gradle that is NOT already locally (cached) on my machine, I get with this part in my build.gradle

plugins {
    id 'org.springframework.boot' version '2.6.6'
    ...
}

the following error:

> Could not resolve all files for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-buildpack-platform:2.6.6.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:2.6.6 > org.springframework.boot:spring-boot-gradle-plugin:2.6.6
      > Could not resolve org.springframework.boot:spring-boot-buildpack-platform:2.6.6.
         > Could not get resource 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-buildpack-platform/2.6.6/spring-boot-buildpack-platform-2.6.6.module'.
            > Could not GET 'https://repo.gradle.org/artifactory/jcenter/org/springframework/boot/spring-boot-buildpack-platform/2.6.6/spring-boot-buildpack-platform-2.6.6.module'. Received status code 403 from server: Forbidden
   > Could not resolve org.springframework.boot:spring-boot-loader-tools:2.6.6.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:2.6.6 > org.springframework.boot:spring-boot-gradle-plugin:2.6.6
      > Could not resolve org.springframework.boot:spring-boot-loader-tools:2.6.6.
         > Could not get resource 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-loader-tools/2.6.6/spring-boot-loader-tools-2.6.6.module'.
            > Could not GET 'https://repo.gradle.org/artifactory/jcenter/org/springframework/boot/spring-boot-loader-tools/2.6.6/spring-boot-loader-tools-2.6.6.module'. Received status code 403 from server: Forbidden
   > Could not resolve org.springframework:spring-core:5.3.18.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:2.6.6 > org.springframework.boot:spring-boot-gradle-plugin:2.6.6
      > Could not resolve org.springframework:spring-core:5.3.18.
         > Could not get resource 'https://plugins.gradle.org/m2/org/springframework/spring-core/5.3.18/spring-core-5.3.18.module'.
            > Could not GET 'https://repo.gradle.org/artifactory/jcenter/org/springframework/spring-core/5.3.18/spring-core-5.3.18.module'. Received status code 403 from server: Forbidden

This issue was raised by a colleague who also found a way to deal with it by not using the public gradle plugin portal but rather going via the corporates nexus. For this to work the repositories have to be added to settings.gradle as described here:
https://docs.gradle.org/current/userguide/plugins.html#sec:custom_plugin_repositories

For this to understand it is important to know that the gradle plugin repositories are different (they are used just for the plugins) than the repositories that are being used by gradle for pulling the application's dependencies and that we already configure in our quickstarter to use nexus (see https://github.com/opendevstack/ods-quickstarters/blob/master/be-java-springboot/templates/gradle-repositories.template)

A solution (next to asking the IT to unblock the public repo) could be to add the nexus plugin repos to settings.gradle if nexus vars are set (analogous to like we do it here) while provisioning.

To Reproduce
Steps to reproduce the behavior:

  1. Be behind a network that blocks the public gradle plugin portal
  2. Don't have any plugins cached locally that you are going to need for building the blank spring boot qs
  3. Provision the spring boot qs component
  4. in the projects root folder type: ./gradlew

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with be-java-springboot/templates/gradle-repositories.template and the generated settings.gradle configuration described in the issue. Check how Nexus variables are exposed during provisioning, then run ./gradlew for a blank Spring Boot quickstarter without cached plugins. Done means plugin resolution uses the configured Nexus repositories when those variables are set, allowing builds behind a blocked public Gradle portal.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.