简体   繁体   中英

Gradle dependency groupId removed from repo url

A have a gradle project which has some dependencies hosted in an internal maven repo. The url to the repo is http://code.company.com/api/v4/groups/myApp/-/packages/maven/

Gradle fails to download the dependencies if all except the last part of a group id is included in the url of the maven repo.

Working example:

api: 'org.stuff.myApp.utils:core:1.0.0'
-> Gradle tries to download 
 https://code.company.com/api/v4/groups/myApp/-/packages/maven/org/stuff/myApp/utils/core/1.0.0/core-1.0.0.pom
-> This URL is correct

Bad example:

api: 'com.company.myApp.utils:core:1.0.0'
-> Gradle tries to download 
 https://code.company.com/api/v4/groups/myApp/-/packages/maven/utils/core/1.0.0/core-1.0.0.pom
-> This URL is wrong, most parts of the group id are mising from the path.
It should be 
 https://code.company.com/api/v4/groups/myApp/-/packages/maven/com/company/myApp/utils/core/1.0.0/core-1.0.0.pom

I've tried this in a couple of gradle versions (including the latest 6.7.1) and couldn't find anything related in the docs. Does anyone know if this is the expected behavior and how to force gradle to always append the full group id?

After debugging for hours I found the root cause: The library I was trying to use had a dependency to another gradle project:

com.company.myApp.utils
|-- core
|-- other

core is depending on other by declaring implementation project(':other') but the root project didn't have a name associated. Therefore the generated pom contained the wrong group id.

The solution was to add

rootProject.name = 'com.company.myApp'

to the settings.gradle file of the library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM