mapstruct / mapstruct

An annotation processor for generating type-safe bean mappers
https://mapstruct.org/
Other
7.09k stars 948 forks source link

Mapstruct not works in Android Kotlin with Ksp #3511

Closed jlmos25 closed 8 months ago

jlmos25 commented 9 months ago

I have added to my Android application mapstruct with kapt. When I migrate kapt to ksp its produce this error and not compile `> Task :app:kspDebugKotlin e: [ksp] No providers found in processor classpath. e: Error occurred in KSP, check log for detail

Task :app:kspDebugKotlin FAILED Task :app:mergeLibDexDebug UP-TO-DATE Task :app:mergeExtDexDebug

FAILURE: Build failed with an exception.

BUILD FAILED in 11s`

This is my top level gradle configuration:

`// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { id("com.android.application") version "8.1.1" apply false id("org.jetbrains.kotlin.android") version "1.9.10" apply false id("org.jetbrains.kotlin.jvm") version "1.9.10" apply false id("com.google.devtools.ksp") version "1.9.10-1.0.13" apply false

}`

and gradle module configuration

plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("com.google.devtools.ksp") }

android { namespace = "com.app" compileSdk = 34

defaultConfig {
    applicationId = "com.app"
    minSdk = 28
    targetSdk = 34
    versionCode = 1
    versionName = "1.0"

    testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    vectorDrawables {
        useSupportLibrary = true
    }
}

buildTypes {
    release {
        isMinifyEnabled = false
        proguardFiles(
            getDefaultProguardFile("proguard-android-optimize.txt"),
            "proguard-rules.pro"
        )
    }
}
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_20
    targetCompatibility = JavaVersion.VERSION_20
}
kotlinOptions {
    jvmTarget = "20"
}
buildFeatures {
    compose = true
}
composeOptions {
    kotlinCompilerExtensionVersion = "1.5.3"
}

}

dependencies {

implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.activity:activity-compose:1.7.2")
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.navigation:navigation-compose:2.5.3")
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.ui:ui-graphics-android:1.5.1")

implementation("androidx.compose.runtime:runtime-livedata:1.5.4")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2")

// https://mvnrepository.com/artifact/org.mapstruct/mapstruct
implementation("org.mapstruct:mapstruct:1.5.5.Final")
annotationProcessor("org.mapstruct:mapstruct-processor:1.5.5.Final")
ksp("org.mapstruct:mapstruct-processor:1.5.5.Final")

implementation("com.google.devtools.ksp:symbol-processing-api:1.9.10-1.0.13")

}

MapStruct is available for ksp or only works with kapt? Maybe exists and update for MapStruct Works with ksp?

Zegveld commented 8 months ago

Currently mapstruct only works with kapt. see #2522 for progress on ksp support.

closing this as a duplicate.