如何将AWS CodeArtifact与Apache Ivy一起使用? [英] How do I use AWS CodeArtifact with Apache Ivy?

查看:64
本文介绍了如何将AWS CodeArtifact与Apache Ivy一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个AWS CodeArtifact存储库,并使用Maven向其发布了一个jar.

I have set up an AWS CodeArtifact repository, and used Maven to publish a jar to it.

我想在Ant任务中使用该jar,并且尝试使用Apache Ivy下载依赖项.

I want to use that jar in an Ant task, and I'm trying to use Apache Ivy to download the dependency.

我已经成功地使用Ivy从Maven中央存储库下载公共库,但是我不知道如何将我的AWS CodeArtifact存储库添加到Ivy.常春藤的官方教程让我很难理解.

I've successfully used Ivy to download public libraries from the Maven central repository, but I don't know how to add my AWS CodeArtifact repository to Ivy. The official Ivy tutorials are very hard for me to understand.

推荐答案

解决方案是从Ivy切换到Maven Resolver Ant任务-记录得更好,更容易理解.

The solution was to switch from Ivy to the Maven Resolver Ant Tasks - much better documented and easier to understand.

我现在可以使用以下内容从我的ant任务加载AWS CodeArtifact依赖项(在完成了AWS CodeArtifact的Maven设置说明之后).这将下载Maven解析器jar作为该过程的一部分:

I can now load AWS CodeArtifact dependencies from my ant task with something like this (after doing the Maven setup instructions from AWS CodeArtifact). This downloads the Maven resolver jar as part of the process:

<property name="maven.install.version" value="1.3.0"/>
<property name="ant.jar.dir" value="${user.home}/.ant/lib"/>
<property name="maven.jar.file" value="${ant.jar.dir}/maven-resolver-ant-tasks.jar"/>

<target name="load-maven-dependencies" depends="init-maven">
    <resolver:resolve>
        <dependencies>
            <dependency coords="group:artifact:version"/>
        </dependencies>
        <path refid="main.classpath" classpath="compile"/>
    </resolver:resolve>
</target>

<target name="init-maven" depends="download-maven">
    <path id="maven.lib.path">
        <fileset dir="${ant.jar.dir}" includes="${maven.jar.file}"/>
    </path>
    <taskdef resource="org/apache/maven/resolver/ant/antlib.xml" uri="antlib:org.apache.maven.resolver.ant" classpathref="maven.lib.path"/>
</target>

<target name="download-maven" unless="offline">
    <mkdir dir="${ant.jar.dir}" />
    <get src="https://search.maven.org/remotecontent?filepath=org/apache/maven/resolver/maven-resolver-ant-tasks/${maven.install.version}/maven-resolver-ant-tasks-${maven.install.version}-uber.jar" dest="${maven.jar.file}" usetimestamp="true"/>
</target>

然后您可以在taskdef中使用main.claspath,如下所示:

You can then use main.claspath in your taskdef, like this:

<taskdef name="customTask" classname="com.prosc.CustomAntTask" classpathref="main.classpath" />

这篇关于如何将AWS CodeArtifact与Apache Ivy一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆