failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction

154 Views Asked by At

i want to use MapStruct in my Kotlin Ktor project.

I found some project on github which utilze kotlin and mapstruct: https://github.com/dsantarelli/kotlin-ktor-example/tree/main It has dependencies like this:

implementation("org.mapstruct:mapstruct:$mapStructVersion")
kapt("org.mapstruct:mapstruct-processor:$mapStructVersion")

but it doesnt want to compile in my project:

 Task :modules:backend-api:category:category-impl:kaptKotlin FAILED
C:\Users\zwo7a\Desktop\freshood\FreshNearMe\modules\backend-api\category\category-impl\build\tmp\kapt3\stubs\main\application\CategoryApiImpl.java:4: error: cannot find symbol
public final class CategoryApiImpl extends CategoryApi {
                                           ^
  symbol: class CategoryApi

Execution failed for task ':modules:backend-api:category:category-impl:kaptKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
   > java.lang.reflect.InvocationTargetException (no error message)

* 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.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 5s
41 actionable tasks: 36 executed, 5 up-to-date

Some genrated class

package application;

@kotlin.Metadata(mv = {1, 9, 0}, k = 1, xi = 48, d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\b\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u00a2\u0006\u0002\u0010\u0004J\u0016\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\bH\u0096@\u00a2\u0006\u0002\u0010\tR\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004\u00a2\u0006\u0002\n\u0000\u00a8\u0006\n"}, d2 = {"Lapplication/CategoryApiImpl;", "LCategoryApi;", "categoryRepository", "Ldomain/CategoryRepository;", "(Ldomain/CategoryRepository;)V", "getCategoryById", "Ldto/CategoryApiDto;", "id", "", "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "category-impl"})
public final class CategoryApiImpl extends CategoryApi {
    @org.jetbrains.annotations.NotNull
    private final domain.CategoryRepository categoryRepository = null;
    
    public CategoryApiImpl(@org.jetbrains.annotations.NotNull
    domain.CategoryRepository categoryRepository) {
        super();
    }
    
    @java.lang.Override
    @org.jetbrains.annotations.Nullable
    public java.lang.Object getCategoryById(@org.jetbrains.annotations.NotNull
    java.lang.String id, @org.jetbrains.annotations.NotNull
    kotlin.coroutines.Continuation<? super dto.CategoryApiDto> $completion) {
        return null;
    }
}

and here is a kotlin class

internal class CategoryApiImpl(private val categoryRepository: CategoryRepository) :
    CategoryApi {
    override suspend fun getCategoryById(id: String): CategoryApiDto {

        return categoryRepository.getCategoryById(id) as CategoryApiDto //Temporary cast, until mapping isnt finished
    }
}

interface CategoryApi {
    suspend fun getCategoryById(id: String): CategoryApiDto
}

data class CategoryApiDto(
    val id: String,
    val name: String,
    val parentId: String? = null,
    val path: String
)

repo: https://github.com/Lycan7hropus/FreshNearMe/tree/develop_refactor_into_modules_SO

this is how the folder structure looks like: enter image description here

#EDIT i have commented all Category related stuff, and on new pull it started working, but when I add and any KOTLIN interface to category-api it stops compiling, java interfaces works fine, but Kotlin one lead to

WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by org.jetbrains.kotlin.kapt3.util.ModuleManipulationUtilsKt (file:/C:/Users/zwo7a/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-annotation-processing-gradle/1.9.0/7ae0dcc344b9775e08289a9f925e90348fce0cd1/kotlin-annotation-processing-gradle-1.9.0.jar) to constructor com.sun.tools.javac.util.Context()
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.kapt3.util.ModuleManipulationUtilsKt
WARNING: Illegal reflective access by org.jetbrains.kotlin.kapt3.util.ModuleManipulationUtilsKt (file:/C:/Users/zwo7a/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-annotation-processing-gradle/1.9.0/7ae0dcc344b9775e08289a9f925e90348fce0cd1/kotlin-annotation-processing-gradle-1.9.0.jar) to constructor com.sun.tools.javac.util.Context()

WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.kapt3.util.ModuleManipulationUtilsKt

WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: All illegal access operations will be denied in a future release
WARNING: An illegal reflective access operation has occurred
WARNING: All illegal access operations will be denied in a future release

WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by org.jetbrains.kotlin.kapt3.util.ModuleManipulationUtilsKt (file:/C:/Users/zwo7a/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-annotation-processing-gradle/1.9.0/7ae0dcc344b9775e08289a9f925e90348fce0cd1/kotlin-annotation-processing-gradle-1.9.0.jar) to constructor com.sun.tools.javac.util.Context()
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.kapt3.util.ModuleManipulationUtilsKt
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: Illegal reflective access by org.jetbrains.kotlin.kapt3.util.ModuleManipulationUtilsKt (file:/C:/Users/zwo7a/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-annotation-processing-gradle/1.9.0/7ae0dcc344b9775e08289a9f925e90348fce0cd1/kotlin-annotation-processing-gradle-1.9.0.jar) to constructor com.sun.tools.javac.util.Context()

WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.kapt3.util.ModuleManipulationUtilsKt

WARNING: All illegal access operations will be denied in a future release
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: All illegal access operations will be denied in a future release

Execution failed for task ':modules:backend-api:category:category-api:kaptGenerateStubsTestKotlin'.
> java.io.IOException: The system cannot find the path specified
0

There are 0 best solutions below