humawork / compose-charts

Jetpack Compose charts for Android
Apache License 2.0
77 stars 6 forks source link

Unable to import the library into my Compose Desktop project #8

Open Genie23 opened 3 years ago

Genie23 commented 3 years ago

Hello,

I try to import your library in my project to make graphics, but without success.

My build.gradle.kts :

import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version "1.5.21"
    id("org.jetbrains.compose") version "1.0.0-alpha4-build310"
}

group = "fr.genie23"
version = "1.0.0"

repositories {
    mavenCentral()
    maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
    google()
}

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.21")
    implementation(compose.desktop.currentOs)
    implementation("ma.hu:compose-charts:0.3.1")
    implementation("org.apache.pdfbox:pdfbox:2.0.24")
    implementation("org.apache.pdfbox:fontbox:2.0.24")
    implementation("org.apache.pdfbox:jempbox:1.8.16")
    implementation("org.apache.pdfbox:xmpbox:2.0.24")
    implementation("org.apache.pdfbox:preflight:2.0.24")
    implementation("org.apache.pdfbox:pdfbox-tools:2.0.24")
    implementation("org.bouncycastle:bcprov-jdk15on:1.69")
    implementation("org.bouncycastle:bcmail-jdk15on:1.69")
    implementation("org.bouncycastle:bcpkix-jdk15on:1.69")
}

tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "11"
}

tasks.withType<KotlinCompile>().configureEach {
    kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}

tasks.register<Copy>("copyRelease") {
    group = "compose desktop"
    description = "Copy release builded executable into out folder."
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
    from(
        "build/compose/binaries/main/deb",
        "build/compose/binaries/main/dmg",
        "build/compose/binaries/main/exe",
        "build/compose/binaries/main/rpm"
    )
    into("out")
}

compose.desktop {
    application {
        mainClass = "MainKt"
        nativeDistributions {
            packageName = "Free CoManagement"
            description = "Logiciel de fusion de documents PDF"
            targetFormats(TargetFormat.Dmg, TargetFormat.Exe, TargetFormat.Deb, TargetFormat.Rpm)
            windows {
                iconFile.set(project.file("src/main/resources/icons/logo.64x64.ico"))
                dirChooser = true
                menuGroup = "Genie23.fr"
            }
            macOS {
                iconFile.set(project.file("src/main/resources/icons/logo.64x64.icns"))
            }
            linux {
                iconFile.set(project.file("src/main/resources/icons/logo.64x64.png"))
                menuGroup = "Genie23.fr"
            }
        }
    }
}

And the error it generates for me when I run the gradle task runDistributable:

Execution failed for task ':compileKotlin'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve ma.hu:compose-charts:0.3.1.
     Required by:
         project :
      > No matching variant of ma.hu:compose-charts:0.3.1 was found. The consumer was configured to find an API of a library compatible with Java 16, 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 ma.hu:compose-charts:0.3.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 16)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'releaseRuntimePublication' capability ma.hu:compose-charts:0.3.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 16)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

The version number, I got it here. How do I do it?

steelahhh commented 3 years ago

Thank you for reporting this!

Only Jetpack Compose is supported at the moment because of some reliance on Android's Canvas

Unfortunately, support for JetBrains Compose is not planned for now

Genie23 commented 3 years ago

Oh, it's not the same thing? I missed it

olonho commented 2 years ago

Would you accept contribution making the library multiplatform?

steelahhh commented 2 years ago

Absolutely, all contrubitions are welcome!

gsteckman commented 2 years ago

I'm also interested in multiplatform. I was able to convert PieChartRenderer to use only Compose Canvas without difficulty. I'll take a look at the other charts and if I don't run into any stumbling blocks submit a PR.