Hello all, I have a particular problem, I want to ...
# gradle
i
Hello all, I have a particular problem, I want to modularize my projects(maybe more than I should, but itโ€™s something personal now, point is I have my features in a library, for this example customerFeature, which has inside 1 lib for each layer(data,domain,presentation and core) till here itโ€™s good, everything works. ๐Ÿ“‚ customerFeature โ”œโ”€โ”€ ๐Ÿ“ .gradle โ”œโ”€โ”€ ๐Ÿ“ฆ core โ”œโ”€โ”€ ๐Ÿ“ฆ data โ”œโ”€โ”€ ๐Ÿ“ฆ domain โ”œโ”€โ”€ ๐Ÿ“ฆ presentation โ”œโ”€โ”€ ๐Ÿ“ src โ”œโ”€โ”€ ๐Ÿ“„ .gitignore โ””โ”€โ”€ ๐Ÿ˜ build.gradle.kts Of course each layer has itโ€™s own build.gradle with their dependencies, and in the src folder seen in the image I have like the โ€œbuilderโ€ and in the build.gradle of customerFeature I have included all the layers as dependencies, so the library customerFeature has everything ready to use outside with all the layers. build.gradle of customerFeature:
Copy code
sourceSets {
        commonMain.dependencies {
            projects.customerFeatureKMP.customerFeature.apply {
                implementation(core)
                implementation(data)
                implementation(presentation)
                implementation(domain)
            }
}
the point is that everything compiles, but the final pom and .module have each layer defined as a dependency with an undefined version:
Copy code
example from .module:
      "dependencies": [
        {
          "group": "CustomerFeatureKMP.customerFeature",
          "module": "presentation",
          "version": {
            "requires": "unspecified"
          },

example from .pom
    <dependency>
      <groupId>CustomerFeatureKMP.customerFeature</groupId>
      <artifactId>presentation</artifactId>
      <version>unspecified</version>
      <scope>runtime</scope>
How can I achieve with this structure a whole thing, customerFeature as a library with the layers just included and not added as dependencies, because when I do this, in the final app I get the error because itโ€™s trying to look for each layer individually(with undefined version btw(I know this is solveable by defining a global version, but still, in the final project it wouldnโ€™t find the layers))
Copy code
Failed to resolve:CustomerFeatureKMP.customerFeature:domain:unspecified
Failed to resolve:CustomerFeatureKMP.customerFeature:data:unspecified 
Failed to resolve:CustomerFeatureKMP.customerFeature:presentation:unspecified 
Failed to resolve:CustomerFeatureKMP.customerFeature:core:unspecified
Thanks in advance for anyone taking the time to read this, Iโ€™ve been with this for days, trying a lot of options and nothing worksโ€ฆ
v
In a clean way?
Not ๐Ÿ™‚
If you feel the need to split things into multiple projects or source sets, you should also publish them as separate jars and use them like that. (that the version are missing is probably because you did not set a version and even if you did, you probably did not configure publishing)
There are ways to do such "half-fat" jars, but they are not really idiomatic. My recommendation usually is, if you want one, jar, have the sources in the same source set, if you want to split, publish each jar individually.
i
Sounds fair enough...... I'll then decide what to do with each one of them..... probably 1 jar and all in the source set(sounds like the fastest and cleaner way) Thank you @Vampire
๐Ÿ‘Œ 1