首页 > 解决方案 > Ivy 将 pom.xml-Package-Tag 转换为 ivy.xml-Extension

问题描述

问题

使用 Jenkins 共享库时,我尝试使用@Grab('com.atlassian.jira:jira-rest-java-client-core:4.0.0'). 当 ivy 尝试获取依赖项时,这悲惨地失败了:

General error during conversion: Error grabbing Grapes -- [download failed: com.atlassian.sal#sal-api;3.0.3!sal-api.atlassian-plugin, download failed: com.atlassian.httpclient#atlassian-httpclient-plugin;0.23.0!atlassian-httpclient-plugin.atlassian-plugin]

据我了解,发生这种情况的原因如下:Ivy 下载依赖项的 pom.xml 文件,将它们转换为 ivy 文件并下载相应的工件。这些依赖<packaging>atlassian-plugin</packaging>项在它们的 pom.xml 中声明 a,然后将其转换为<artifact name="atlassian-httpclient-plugin" type="atlassian-plugin" ext="atlassian-plugin" conf="master"/>. Ivy 现在尝试下载*.atlassian-plugin文件而不是*.jar.

这是常春藤中的错误,应该报告吗?或者 atlassian 是否使用了 -Tag packageing

复制的最小示例

我可以通过以下文件在本地使用 ant/ivy 独立于 jenkins 重现该问题。

[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve]          [NOT FOUND  ] com.atlassian.sal#sal-api;3.0.3!sal-api.atlassian-plugin (1041ms)
[ivy:retrieve]  ==== atlassian: tried
[ivy:retrieve]    https://packages.atlassian.com/mvn/maven-external/com/atlassian/sal/sal-api/3.0.3/sal-api-3.0.3.atlassian-plugin
[ivy:retrieve]          [NOT FOUND  ] com.atlassian.httpclient#atlassian-httpclient-plugin;0.23.0!atlassian-httpclient-plugin.atlassian-plugin (147ms)
[ivy:retrieve]  ==== atlassian: tried
[ivy:retrieve]    https://packages.atlassian.com/mvn/maven-external/com/atlassian/httpclient/atlassian-httpclient-plugin/0.23.0/atlassian-httpclient-plugin-0.23.0.atlassian-plugin
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]          ::              FAILED DOWNLOADS            ::
[ivy:retrieve]          :: ^ see resolution messages for details  ^ ::
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]          :: com.atlassian.sal#sal-api;3.0.3!sal-api.atlassian-plugin
[ivy:retrieve]          :: com.atlassian.httpclient#atlassian-httpclient-plugin;0.23.0!atlassian-httpclient-plugin.atlassian-plugin
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::

构建.xml

<project xmlns:ivy="antlib:org.apache.ivy.ant" name="hello-ivy" default="ivy-get-binaries">
  <target name="ivy-get-binaries">
   <ivy:settings file="ivysettings.xml" />
   <echoproperties prefix="ivy."/>
   <ivy:retrieve />
</target>
</project>

常春藤.xml

<ivy-module version="2.0">
    <info organisation="foo" module="bar"/>
    <dependencies>
        <dependency org="com.atlassian.jira" name="jira-rest-java-client-core" rev="4.0.0"/>
    </dependencies>
</ivy-module>

常春藤设置.xml

<ivysettings>
<settings defaultResolver="atlassian"/>
  <resolvers>
    <ibiblio name="atlassian" m2compatible="true" root="https://packages.atlassian.com/mvn/maven-external" />
  </resolvers>
</ivysettings>

使用 Maven 检查

使用 Maven 解决 jira-rest-java-client-core 的依赖关系可以正常工作:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>foo</groupId>
    <artifactId>bar</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>minimal-pom</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-java-client-core</artifactId>
            <version>4.0.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    
    <repositories>
        <repository>
          <id>atlassian</id>
          <layout>default</layout>
          <url>https://packages.atlassian.com/mvn/maven-external</url>
        </repository>
      </repositories>

</project>

标签: ivyjira-plugin

解决方案


推荐阅读