2

我创建了一个Maven 扩展,现在我尝试使用它而不在本地安装它。所以我已经将它部署到我们自己的存储库(还不是 maven Central),但由于某种原因,maven 试图从https://repo.maven.apache.org/maven2下载它,它当然失败了:

[警告] 无法读取扩展描述符 /home/my-user/git/my-project/.mvn/extensions.xml:插件 com.blalablablah:kompile-maven-extension:1.0 或其依赖项之一无法解析:在中央找不到工件 com.blablablah:kompile-maven-extension:jar:1.0 ( https://repo.maven.apache.org/maven2 )

我怎样才能告诉 maven 从我们的存储库下载它呢?

我的~/.m2/settings.xml配置了<repositories><pluginRepositories>用于指向我的仓库的快照和发布,它适用于所有依赖项,但显然不适用于此扩展。

我在 maven 文档上没有发现任何有用的东西,因为扩展似乎仍然“太新”。

我的{project-root}/.mvn/extensions.xml看起来像这样:

<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
    <extension>
        <groupId>com.blablablah</groupId>
        <artifactId>kompile-maven-extension</artifactId>
        <version>1.0</version>
    </extension>
</extensions>

我没有修改项目pom.xml
我一直在寻找整个项目的有效 pom 并且中央存储库在那里,当然,作为每个模块的普通 repo 和插件 repo,但总是作为最后一个条目,在我自己的 repos 之后。我还没有找到任何可以解释为什么 maven 只在 maven Central 中寻找我的扩展的东西。

我错过了什么?

Maven 版本是 3.3.9。我也在 maven 3.5.0 上测试过它。

谢谢!

4

1 回答 1

1

唯一对我有用的是将存储库添加到 settings.xml 并将其添加到活动配置文件中:

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

    <profiles>
        <profile>
            <id>tycho-stage</id>
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>oss</id>
                    <url>https://oss.sonatype.org/content/repositories/orgeclipsetycho-1056</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>oss</id>
                    <url>https://oss.sonatype.org/content/repositories/orgeclipsetycho-1056</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>tycho-stage</activeProfile>
    </activeProfiles>
</settings>
于 2019-10-16T13:22:25.177 回答