I am new with gradle and I started working on migrating my maven project to gradle, I have used the gradle init task to do the initial phase and create the elementary skeleton then I started adding manually the missing parts, my project is a Spring boot application and when I have tried running the app using gradle run, I encountered the following exception:
Hi @christianGen , although running the bootRun task will give me the same error, here are the plugins I used:
plugins {
id 'java'
id 'org.springframework.boot' version '2.4.2'
// id 'com.ebay.build.assembler' version '0.1.0-RC6'
id 'application'
id 'pmd'
// id 'checkstyle'
}
Spring boot added their own run task: bootRun which adds (very little) additional functionality.
The BOM is used to control the versions of a spring boot’s dependencies and provide a central place to define and update those versions. Baeldung: Spring with Maven BOM
In a nutshell it specifies which versions of dependencies are acceptable for the spring boot version you are using.
Is the brave-opentracing jar included in the build/libs/xxx.jar file? (BOOT-INF/lib)?
yes, we use the same environment and the same development branch , also tried to remove the dependency above and the project was built successfully, I feel that this is something related to the IDE or the dependency indexes and not related to gradle but not sure
Actually whether the brave-opentracing jar is present is only marginally interesting.
The missing class is in the brave jar that is a transitive dependency of the former:
@Vampire when building the gradle project on another pc which has the same setup, the build succeeds only my local pc it always gets this exception of the missing missing file, tried to remove the dependency directory on my loacl m2 repository and build again but the dependency was not resolved or downloaded again which is so strange…
@Vampire@christianGen , ok when deleted the .m2/io directory didn’t see that the dependency was resolved and when inspected the maven POM found this:
the scope here is compile but in my gradle project the transitive dependency that brings it was defined as implementation would this affect the way it is handled by gradle?
I didn’t really understand what you say. compile is the same as having nothing in the POM, as compile is the default scope.
As you are talking about your local maven repository, I assume you are using mavenLocal() and then my advise is, don’t do it. This is a broken-by-design directory that is a mixture of local repository and download cache. If you for example also use Maven on that box and resolve only the POM of a dependency, then only the POM is in maven local and when Gradle sees that, it sees a broken repository entry that in the best case throws an error, in worst case just behaves strangely. If you actually need to use maven local because you need a snapshot build of a non-Gradle project, then at least use mavenLocal as last entry in your list of repositories and use a repository content filter to only pull the exact defined dependency from that repository.