Skip to content

Conversation

oguzkocer
Copy link
Contributor

This PR updates the Kotlin & Android projects to use Kotlin DSL for build scripts and version catalog to keep its dependencies and versions.

I wanted to do use this modern setup from the very start, but during the prototype, it was slowing me down as I was more familiar with Groovy build scripts. With version catalog, I don't even have a justification, I don't know why I didn't use it 🤦‍♂️

Hopefully this is a one to one change from Groovy build script to Kotlin DSL. I had to make some minor changes to get things working, such as removing common.gradle and combining it to :api:android, which probably is a good thing, because that logic is unlikely to be used elsewhere.

Looking at the PR now, I can see that there is a lot of room for improvement for the Kotlin DSL, and I think I have a couple unused versions in the version catalog, but polishing all that has a very low priority for me at the moment.


The main reason I am doing this at the moment is because I'd like to add a multiplatform example app to the project and the Kotlin Multiplatform Wizard uses Kotlin DSL and version catalog. Either I have to convert everything from that generated project to Groovy script and regular versions, or I have to update the current implementation. I guess we could also use a mixed approach, but that's even more of a headache. So, I bit the bullet and updated the current build scripts.


To Test

  • make test-server && make dump-mysql && make backup-wp-content-plugins
  • cd native/kotlin && ./gradlew :api:kotlin:integrationTest cAT

oguzkocer and others added 27 commits June 3, 2024 18:54
@oguzkocer oguzkocer added this to the 0.1 milestone Jun 5, 2024
@oguzkocer oguzkocer requested review from jkmassel and wzieba June 5, 2024 18:15
@oguzkocer
Copy link
Contributor Author

I've tested this in WPAndroid and it kind of works, but there is a regression. Notice how the dependency was added:

implementation('rs.wordpress.api:android:138-16641d758a6a1b3a395bb3714068d213afc9aca3') {
    exclude group: "net.java.dev.jna"
}
implementation 'net.java.dev.jna:jna:5.13.0@aar'

Using the current trunk, I am able to add it as such, without having to deal with the jna dependency exclusion:

implementation 'rs.wordpress.api:android:trunk-34643da14aa561776630421335566daade2a9698'

I don't quite understand the reason behind this. I compared the pom files for :api:android and found that the exclusion is stated both before and after and after the change:

<dependency>
  <groupId>rs.wordpress.api</groupId>
  <artifactId>kotlin</artifactId>
  <version>{published_version}</version>
  <scope>compile</scope>
  <exclusions>
    <exclusion>
      <groupId>net.java.dev.jna</groupId>
      <artifactId>*</artifactId>
    </exclusion>
  </exclusions>
</dependency>

However, there is a change at the very end of the pom:

       <version>5.13.0</version>
       <type>aar</type>
       <scope>runtime</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>*</groupId>
-          <artifactId>*</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
   </dependencies>
 </project>

I guess that might be the reason behind it, but jna seems to be excluded the same way in both Groovy build script and Kotlin DSL. I am probably missing something here. @wzieba Do you know what's going on by any chance?


For anyone who might be unfamiliar with jna, the reason we have to exclude it in :api:android is that the Android dependency for jna uses the @aar type. Whereas in a JVM library/client, you'd use the regular jna dependency. So, :api:kotlin is adding this as a regular dependency, then :api:android is excluding it and then adding the @aar variant. That makes it a drop in dependency for the clients and not have to worry about which jna to use.


This is not a blocker for us, so I am going to proceed with merging the PR and address the issue as a follow up. If we can't address it in the next couple days, I'll open an issue to track it.

@oguzkocer oguzkocer merged commit 216604f into trunk Jun 5, 2024
@oguzkocer oguzkocer deleted the kotlin-version-catalog-and-kotlin-dsl branch June 5, 2024 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants