mcarleio/konvert

Conflict with `io.spring.dependency-management`

iDevSK opened this issue · 0 comments

iDevSK commented

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

  • Got error like below
BUILD SUCCESSFUL in 83ms
1 actionable task: 1 up-to-date
Errors occurred while building effective model from /Users/user/.gradle/caches/modules-2/files-2.1/io.mcarle/konvert-processor/2.3.0/c87d25b0cc2ad1b119ddd09996f7b71361f8a1e5/konvert-processor-2.3.0.pom:
	'dependencies.dependency[io.mcarle:konvert-processor:2.3.0]' for io.mcarle:konvert-processor:2.3.0 is referencing itself. in io.mcarle:konvert-processor:2.3.0
3:57:45 PM: Execution finished 'kspKotlin'.

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 }
  • If you look at the pom file generated by publishToMavenLocal, you can see that the konvert-processor has been added. and when the plug-in in io.spring.dependency-management works, it seems to send an error message that io.mcarle:konvert-processor:2.3.0 is referencing itself. in io.mcarle:konvert-processor:2.3.0.
  • And this is the dependence, as i see in module.json, added by java-test-fixes plugin. It seems to be related to the issue.

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() }