Jorge Domínguez
02/16/2023, 3:18 PMproject
|____ libraries
|____ client-specific
| |____ some-library
|____ some-library
There are two versions of some-library
, one for client-specific
and another one for the whole project. When I try to use both versions of the library in a demo app I have by doing this:
implementation(project(":project:libraries:client-specific:some-library")
implementation(project(":project:libraries:some-library")
it seems that whatever library is declared first is prioritized, so in this case if I try to use the classes in project:libraries:some-library
I get all kinds of errors about missing resources that exist in there but not in :project:libraries:client-specific:some-library
. But if I use the classes in :project:libraries:client-specific:some-library
there are no complains. These classes have same names but different packages. Is there a way to work around this? I need to use both versions (edited)Sam
02/16/2023, 3:21 PMSam
02/16/2023, 3:23 PMallprojects {
extensions.findByType<BasePluginExtension>()?.apply {
archivesName.set(path.replace(":", "-"))
}
}
The default is to just use the name, so both jars end up being called some-library.jar
. With this fix, you’d get libraries-client-specific-some-library.jar
and libraries-some-library.jar
.Jorge Domínguez
02/16/2023, 3:25 PMSam
02/16/2023, 3:25 PMbuild.gradle.kts
. (It’s possible your problem isn’t exactly the same as mine was, but it does sound similar)Jorge Domínguez
02/16/2023, 3:26 PMJorge Domínguez
02/16/2023, 3:26 PMSam
02/16/2023, 3:27 PMAdam S
02/16/2023, 3:31 PMThere are two versions ofGradle subprojects shouldn’t have the same name, even if the paths are different https://stackoverflow.com/a/74607687/4161471some-library
ephemient
02/16/2023, 3:34 PMephemient
02/16/2023, 3:34 PMephemient
02/16/2023, 3:34 PMSam
02/16/2023, 3:35 PMGradle subprojects shouldn’t have the same nameI’d argue that they should and Gradle should not have bugs, but point taken 😄
Adam S
02/16/2023, 3:36 PMephemient
02/16/2023, 3:37 PMinclude(":client-specific-some-library")
project(":client-specific-some-library").projectDir = file("libraries/project-specific/some-library")
ephemient
02/16/2023, 3:39 PM"$group:$name:$version"
, and that conflicts if you reuse project namesephemient
02/16/2023, 3:39 PMJorge Domínguez
02/16/2023, 3:42 PMsettings.gradle
right?Vampire
02/16/2023, 3:43 PMI’d argue that they should and Gradle should not have bugs, but point takeniirc they can, if you use different
group
values.
Because if the projects have same group and name, then as @ephemient said, they produce the same artifact and thus are conflict-resolved.ephemient
02/16/2023, 3:48 PMephemient
02/19/2023, 12:10 PMproject.group
, if you use the same project.name
then by default the output JARs will have the same names, and that will lead to problems with distribution