mcarleio / konvert

This kotlin compiler plugin is using KSP API and generates kotlin code to map one class to another
https://mcarleio.github.io/konvert/
Apache License 2.0
93 stars 8 forks source link

Conflict with `io.spring.dependency-management` #22

Closed iDevSK closed 1 year ago

iDevSK commented 1 year ago

I used this library for mapping in Kotlin and SpringBoot, Thanks. I saw the error message below when running the build in the project.

Issue

In addition, various tests have found that the error message appears when using the io.spring.dependency-management plug-in.

Below, is my build.gradle.kts

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("org.springframework.boot") version "3.1.4"
    id("io.spring.dependency-management") version "1.1.3"
    kotlin("jvm") version "1.9.10"

    id("com.google.devtools.ksp") version "1.9.10-1.0.13"
}

group = "com.example"
version = "0.0.1-SNAPSHOT"

java {
    sourceCompatibility = JavaVersion.VERSION_17
}

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter:3.1.4")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    testImplementation("org.springframework.boot:spring-boot-starter-test")

    implementation("io.mcarle:konvert-api:2.3.0")
    ksp("io.mcarle:konvert:2.3.0")
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs += "-Xjsr305=strict"
        jvmTarget = "17"
    }
}

tasks.withType<Test> {
    useJUnitPlatform()
}

tasks.bootJar { enabled = false }

konvert-processor-2.3.0.pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.mcarle</groupId>
    <artifactId>konvert-processor</artifactId>
    <version>2.3.0</version>
    <name>konvert-processor</name>
    <description>Konvert is a KSP to generate mapping code between types</description>
    <url>https://github.com/mcarleio/konvert</url>
    <inceptionYear>2023</inceptionYear>
    <licenses>
        <license>
            <name>The Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>
    <developers>
        <developer>
            <name>Marcel Carlé</name>
            <url>https://mcarle.io</url>
        </developer>
    </developers>
    <scm>
        <connection>scm:git:git://github.com/mcarleio/konvert.git</connection>
        <developerConnection>scm:git:ssh://github.com:mcarleio/konvert.git</developerConnection>
        <url>https://github.com/mcarleio/konvert</url>
    </scm>
    <dependencies>
        <dependency>
...
            <groupId>io.mcarle</groupId>
            <artifactId>konvert-processor</artifactId>
            <version>2.3.0</version>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>
...
    </dependencies>
</project>

module.json

...
 {
      "name": "testFixturesApiElements",
      "attributes": {
        "org.gradle.category": "library",
        "org.gradle.dependency.bundling": "external",
        "org.gradle.jvm.version": 17,
        "org.gradle.libraryelements": "jar",
        "org.gradle.usage": "java-api"
      },
      "dependencies": [
        {
          "group": "io.mcarle",
          "module": "konvert-processor",
          "version": {
            "requires": "0.1.0-SNAPSHOT"
          }
        },
...

If i added below scripts in build.gradle.kts in processor module, it seems works fine

(components["java"] as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() }
(components["java"] as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() }