Java Ant、Ivy和Artifactory如何使用设置文件
可能重复:Java Ant、Ivy和Artifactory如何使用设置文件,java,ant,ivy,artifactory,Java,Ant,Ivy,Artifactory,可能重复: 我已在以下位置将Artifactory设置为在我的计算机上本地运行: http://localhost:8080/artifactory/myRepo 该回购协议目前仅为我管理一个依赖项,即Google Guice(3.0): 现在,我已将我的Ant构建配置为在最前面启动Ivy resolve: <project name="myapp-build default="audit" basedir=".." xmlns:ivy="antlib:org.apache.ivy.a
我已在以下位置将Artifactory设置为在我的计算机上本地运行:
http://localhost:8080/artifactory/myRepo
该回购协议目前仅为我管理一个依赖项,即Google Guice(3.0):
现在,我已将我的Ant构建配置为在最前面启动Ivy resolve:
<project name="myapp-build default="audit" basedir=".." xmlns:ivy="antlib:org.apache.ivy.ant">
<path id="ant.lib.path">
<fileset dir="${env.ANT_HOME}/lib" includes="*.jar"/>
</path>
<!-- I have ivy.jar and its dependencies installed under ${ANT_HOME}lib. -->
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ant.lib.path"/>
<target name="resolve">
<!-- Initialize Ivy and connect to host repository. -->
<echo message="Initializing Apache Ivy and connecting to the host repository."/>
<ivy:settings url="${ivy.std.repo.settings.url}" realm="${ivy.std.repo.realm}"
username="${ivy.std.repo.username}" passwd="${ivy.std.repo.password}"/>
<!-- Clear/flush the Ivy cache. -->
<echo message="Cleaning the local Ivy cache for the current build."/>
<ivy:cleancache/>
<!-- Resolve ivy.xml against the standard repository (all configurations) -->
<echo message="Resolving ivy.xml dependencies against the host repository."/>
<ivy:resolve file="./ivy.xml"/>
<!-- Retrieve compile dependencies from local Ivy cache and place them into the gen/lib/main. -->
<echo message="Retrieving compile-time dependencies."/>
<ivy:retrieve ivypattern="${gen.lib.main.dir}/[artifact].[ext]" conf="compile"/>
<!-- Retrieve test dependencies from local Ivy cache and place them into the gen/lib/test. -->
<echo message="Retrieving testing dependencies."/>
<ivy:retrieve ivypattern="${gen.lib.test.dir}/[artifact].[ext]" conf="test"/>
</target>
...
</project>
这部分是
关于身份验证-Artifactory默认方案与基本HTTP身份验证一起工作。谢谢@noamt(+1)-那么你是说我应该把它放在build.xml
旁边?我想我的问题来自两个方面:(1)在某个时候,我需要提供一个用户名/密码来连接到Artifactory。我认为这将通过
任务实现(因为该任务已经有用户名
,密码
属性等)。我说得对吗?如果没有,那么我应该将我的Artifactory repo的凭证放在哪里…在解析器定义中?(2) 如果我需要连接多个具有不同凭据的存储库,该怎么办<代码>
不够…@4herpsand7derpsago 1)是的,通过凭据2)为每个存储库定义一个凭据(主机属性)。谢谢@oers,但看起来您只能为
任务定义一个主机属性。你能用一个具体的例子详细说明一下吗?再次感谢@4herpsand7derpsago没有真正的文档记录,但您是否尝试使用2个凭据?如果那不起作用,我会觉得很糟糕谢谢你@oers(+1)-请看我在noamt答案下面的评论-我有同样的问题要问你!
<project name="myapp-build default="audit" basedir=".." xmlns:ivy="antlib:org.apache.ivy.ant">
<path id="ant.lib.path">
<fileset dir="${env.ANT_HOME}/lib" includes="*.jar"/>
</path>
<!-- I have ivy.jar and its dependencies installed under ${ANT_HOME}lib. -->
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ant.lib.path"/>
<target name="resolve">
<!-- Initialize Ivy and connect to host repository. -->
<echo message="Initializing Apache Ivy and connecting to the host repository."/>
<ivy:settings url="${ivy.std.repo.settings.url}" realm="${ivy.std.repo.realm}"
username="${ivy.std.repo.username}" passwd="${ivy.std.repo.password}"/>
<!-- Clear/flush the Ivy cache. -->
<echo message="Cleaning the local Ivy cache for the current build."/>
<ivy:cleancache/>
<!-- Resolve ivy.xml against the standard repository (all configurations) -->
<echo message="Resolving ivy.xml dependencies against the host repository."/>
<ivy:resolve file="./ivy.xml"/>
<!-- Retrieve compile dependencies from local Ivy cache and place them into the gen/lib/main. -->
<echo message="Retrieving compile-time dependencies."/>
<ivy:retrieve ivypattern="${gen.lib.main.dir}/[artifact].[ext]" conf="compile"/>
<!-- Retrieve test dependencies from local Ivy cache and place them into the gen/lib/test. -->
<echo message="Retrieving testing dependencies."/>
<ivy:retrieve ivypattern="${gen.lib.test.dir}/[artifact].[ext]" conf="test"/>
</target>
...
</project>