Gradle build not using jar files from local projects

42 Views Asked by At

I'm currently collaborating on a codebase developed by someone else, which includes multiple sub-projects, each with its own set of JAR files. My objective is to leverage these pre-built JAR files within my Spring application for testing purposes. The codebase I'm working with is hosted on GitHub at https://github.com/spring-cloud/spring-cloud-netflix, which I made no changes to. In my separate Spring project, I aim to utilize these JARs for testing purposes. In my gradle.build I tested out one path to my JARs in spring-cloud-starter-netflix-eureka-server however that did not work.

The error I get when I try to build the application. I also checked the dependencies and they also do not show up.

error: cannot find symbol @EnableEurekaServer

Here is my build.gradle file for my local spring application

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.2.4'
    id 'io.spring.dependency-management' version '1.1.4'
}

group = 'com.spring-cloud-netflix'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation fileTree(dir: '../../../spring-cloud-netflix/spring-cloud-starter-netflix-eureka-server/target/', include:  '*.jar')
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

I tried changing implementation to compile but then I get the error from gradle.build 'compile does not exist on ...'

1

There are 1 best solutions below

2
Martin Zeitler On

If you don't know how to build the *.jar, maybe just load it from Maven Central instead:

// implementation fileTree(dir: '../../../spring-cloud-netflix/spring-cloud-starter-netflix-eureka-server/target/', include:  '*.jar')
implementation "org.springframework.cloud:spring-cloud-netflix-eureka-server:4.1.1"

For reference: https://mvnrepository.com/artifact/org.springframework.cloud