如何解决 pom 类型的 Maven 依赖项?

How to resolve a Maven dependency of type pom?

我正在尝试在 Maven 中导入一个库,它是 Kotlin Multiplatform

This 是 Github 回购协议(当然实际上并不重要)

要点是,它说可以使用此依赖项导入 Gradle:

dependencies {
   implementation("com.github.ajalt.colormath:colormath:2.0.0")
}

显然,仅仅将其转换为 Maven 是行不通的:

    <dependencies>
        ...

        <dependency>
            <groupId>com.github.ajalt.colormath</groupId>
            <artifactId>colormath</artifactId>
            <version>2.0.0</version>
            <type>jar</type>
        </dependency>
    </dependencies>

所以我将它的 pom 添加到项目中,正如 解释的那样:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.github.ajalt.colormath</groupId>
                <artifactId>colormath</artifactId>
                <version>2.0.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

这个依赖被解析了(只能解析为pomtype。那我加为dependency:

    <dependencies>
        ...

        <dependency>
            <groupId>com.github.ajalt.colormath</groupId>
            <artifactId>colormath</artifactId>
            <version>2.0.0</version>
            <type>jar</type>
        </dependency>
    </dependencies>

还是找不到。

我还添加了 repo1,因为我没有看到 Maven 在哪里寻找这个神器:

    <repositories>
        <repository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo1.maven.org/maven2</url>
        </repository>
    </repositories>

但是还是没有成功。我不明白为什么它不起作用。

代码可以在repo1中找到,但是Maven无法解决。

这一定是一个很简单的事情,我在这里没有理解,请帮助。

GitHub 到 Maven Central 的 link 指向一个裸 POM 工件,没有任何依赖项 and/or 附加的 JAR。

看起来 Kotlin MP 使用不同的 artifactId 上传特定于 JVM 的工件 - 在本例中为 colormath-jvm。请查看Maven Central.

中对应的目录

我建议在 POM 中使用以下依赖声明:

<groupId>com.github.ajalt.colormath</groupId>
<artifactId>colormath-jvm</artifactId>
<version>2.0.0</version>