square / logcat

I CAN HAZ LOGZ?
Apache License 2.0
895 stars 21 forks source link

Split the library in two modules: logcat and logger #5

Open BraisGabin opened 3 years ago

BraisGabin commented 3 years ago

It would be nice to have a pure jvm module with the logcat function so you don't need to pay the compilation time of an Android module only because you want to log something. The AndroidLogcatLogger would be moved to a "logger module" .

This way you just depend on the "logger module" in the :app module. The "logger module" could include the other one as an api dependency so if someone doesn't care about this can only use this dependency everywhere.

pyricau commented 3 years ago

Interesting. I thought about this, but the thing is, the logcat dependency doesn't actually declare any dependency on Android, so you can totally use it from a JVM only module, it should work, even if there's a class that references unknown symbols. Of course you shouldn't load the AndroidLogcatLogger class on a JVM. Am I missing something?

JcMinarro commented 3 years ago

@pyricau As far as you are using com.android.library Plugin the artifact result will be an .aar files that needs to be consumed by an Android Application or Android LIbrary, but can't be consumed by a pure JVM module. Here the error you get if you try to use logcat into a pure JVM module:

Execution failed for task ':stream-chat-android-core:compileKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':stream-chat-android-core:compileKotlin'
   > Could not resolve all files for configuration ':stream-chat-android-core:compileClasspath'.
      > Could not resolve com.squareup.logcat:logcat:0.1.
        Required by:
            project :stream-chat-android-core
         > No matching variant of com.squareup.logcat:logcat:0.1 was found. The consumer was configured to find an API of a library compatible with Java 8, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
             - Variant 'releaseApiPublication' capability com.squareup.logcat:logcat:0.1 declares an API of a library, and its dependencies declared externally:
                 - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
             - Variant 'releaseRuntimePublication' capability com.squareup.logcat:logcat:0.1 declares a runtime of a library, and its dependencies declared externally:
                 - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
pyricau commented 2 years ago

ah, good point, should look at whether we can release a jar instead then.