Search code examples
gradlespring-bootartifactoryspring-io

spring dependency-management gradle plugin with artifactory


I'm trying to get a new project up and running using a private artifactory gradle repo. I was able to get it resolving artifacts through artifactory, but when I try to throw spring io & boot into the mix, the spring dependency management plugin doesn't seem to add the version when requesting the dependency, causing the build to fail:

    FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not find org.springframework.boot:spring-boot-starter-data-rest:.
  Searched in the following locations:
      https://my-website.com/artifactory/gradle-release/org/springframework/boot/spring-boot-starter-data-rest//spring-boot-starter-data-rest-.pom
      https://my-website.com/artifactory/gradle-release/org/springframework/boot/spring-boot-starter-data-rest//spring-boot-starter-data-rest-.jar
      https://my-website.com/artifactory/gradle-release/org.springframework.boot/spring-boot-starter-data-rest/ivy-.xml
      https://my-website.com/artifactory/gradle-release/org.springframework.boot/spring-boot-starter-data-rest//spring-boot-starter-data-rest-.jar

I can see the files at https://my-website.com/artifactory/gradle-release/org/springframework/boot/spring-boot-starter-data-rest/1.5.3.RELEASE/ but looks like the "1.5.3.RELEASE" isn't making it to the URL path or filename.

I'm guessing my problem is in my build script - can someone please help me identify the issue?

build.gradle:

plugins {
    id 'java'
    id 'io.spring.dependency-management' version '1.0.3.RELEASE'
    id 'org.springframework.boot' version '1.5.3.RELEASE'
    id 'com.jfrog.artifactory' version '4.4.18'
}

dependencyManagement {
    imports {
        mavenBom 'io.spring.platform:platform-bom:Brussels-SR2'
    }
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"
    publish {
        repository {
            repoKey = 'gradle-release-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
        }
    }
    resolve {
        repository {
            repoKey = 'gradle-release'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
        }
    }
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-data-rest'
    compile 'org.springframework.boot:spring-boot-starter-hateoas'
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.apache.commons:commons-lang3'

    testCompile'org.springframework.boot:spring-boot-starter-test'
    testCompile'org.springframework.restdocs:spring-restdocs-mockmvc'
}

Solution

  • Figured it out - looks like there was no problem with my build script - it was my artifactory security settings.

    In order to resolve dependencies through artifactory, deploy/cache needs to be enabled for remote repositories (which I didn't think was needed since I wasn't planning on deploying anything to mavencentral); Artifactory trying to cache the new dependencies I added for spring was causing the build to fail). Source: https://www.jfrog.com/knowledge-base/what-are-best-practices-for-using-permissions/

    Hope this helps someone else, I've wasted enough time on it for one day :)