繁体   English   中英

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

[英]How to resolve a Maven dependency of type pom?

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

是它的 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>

这个依赖被解决了(它只能被解析为pom type 。然后我将它添加为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 的链接指向一个裸 POM 工件,没有任何依赖项和/或附加 JARs。

看起来 Kotlin MP 上传了具有不同 artifactId 的 JVM 特定工件 - 在本例中colormath-jvm 请在Maven中查看对应目录。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM