【发布时间】:2015-07-14 15:21:31
【问题描述】:
我正在使用这些目标将我的 Artifacts 从 Ant 构建部署到 Artifactory:
<project name="myApp" default="main" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
.
.
.
<path id="maven-ant-tasks.classpath">
<fileset refid="maven-ant-tasks.fileset" />
</path>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />
<target name="define-artifact-properties">
<property name="artifact.group" value="my.org" />
<property name="artifact.name" value="myApp" />
<property name="artifact.version" value="1.9.0-devel.SNAPSHOT" />
<property name="artifact.type" value="jar" />
<property name="artifact.dir" value="${build.dir}/artifacts" />
<property name="artifact.pom" value="${artifact.dir}/${artifact.name}-${artifact.version}.pom" />
</target>
<target name="copy-artifacts" depends="init, define-artifact-properties">
<copy file="${server.jar}" tofile="${artifact.dir}/${artifact.name}-${artifact.version}-server.jar" overwrite="true" preservelastmodified="true" />
<copy file="${dist.ear.dir}/${application.name}.depl" tofile="${artifact.dir}/${artifact.name}-${artifact.version}.depl" overwrite="true" preservelastmodified="true" />
<copy file="${server.ear}" tofile="${artifact.dir}/${artifact.name}-${artifact.version}.ear" overwrite="true" preservelastmodified="true" />
<copy file="${client.jar}" tofile="${artifact.dir}/${artifact.name}-${artifact.version}-client.jar" overwrite="true" preservelastmodified="true" />
<copy file="${server.interfaces.jar}" tofile="${artifact.dir}/${artifact.name}-${artifact.version}-interfaces.jar" overwrite="true" preservelastmodified="true" />
<copy file="${prozess.jar}" tofile="${artifact.dir}/${artifact.name}-${artifact.version}-prozess.jar" overwrite="true" preservelastmodified="true" />
<copy file="${src.zip}" tofile="${artifact.dir}/${artifact.name}-${artifact.version}-sources.jar" overwrite="true" preservelastmodified="true" />
</target>
<!-- deploy-task for creating and writing a temporary pom-file and deploying the artifact beside this pom-file -->
<target name="release-artifacts" depends="init, define-artifact-properties, copy-artifacts">
<fail message="Property 'artifactory.publish.url' muss fuer das Releasen ins Artifactory gesetzt sein!" unless="artifactory.publish.url" />
<fail message="Property 'artifactory.publish.username' muss fuer das Releasen ins Artifactory gesetzt sein!" unless="artifactory.publish.username" />
<fail message="Property 'artifactory.publish.password' muss fuer das Releasen ins Artifactory gesetzt sein!" unless="artifactory.publish.password" />
<mkdir dir="${artifact.dir}" />
<artifact:pom id="tmp.pom" groupid="${artifact.group}" artifactid="${artifact.name}" version="${artifact.version}" packaging="${artifact.type}" name="${artifact.name}" />
<artifact:writepom pomRefId="tmp.pom" file="${artifact.pom}" />
<artifact:deploy file="${artifact.dir}/${artifact.name}-${artifact.version}-server.jar">
<remoteRepository url="${artifactory.publish.url}">
<authentication username="${artifactory.publish.username}" password="${artifactory.publish.password}" />
</remoteRepository>
<attach file="${artifact.dir}/${artifact.name}-${artifact.version}.depl" type="depl" />
<attach file="${artifact.dir}/${artifact.name}-${artifact.version}.ear" type="ear" />
<attach file="${artifact.dir}/${artifact.name}-${artifact.version}-client.jar" classifier="client" type="jar" />
<attach file="${artifact.dir}/${artifact.name}-${artifact.version}-interfaces.jar" classifier="interfaces.jar" type="jar" />
<attach file="${artifact.dir}/${artifact.name}-${artifact.version}-prozess.jar" classifier="prozess.jar" type="jar" />
<attach file="${artifact.dir}/${artifact.name}-${artifact.version}-sources.jar" classifier="sources" type="jar" />
<pom file="${artifact.pom}" />
</artifact:deploy>
</target>
这适用于普通版本。我可以按预期在 Artifactory 上找到工件。甚至像“1.9.0-devel-SNAPSHOT”这样的版本也可以正常工作。
但如果我使用包含“.SNAPSHOT”的版本(例如“1.9.0-devel.SNAPSHOT”),Artifactory 会添加一个时间戳。这可能看起来没什么大不了的,但出于这个原因,Artifactory 会填满快照,并且旧的快照不会被删除。 Artifactory 上的 Maven 快照版本行为设置为 Nonunique,这样应该可以防止时间戳,但它不会!
真的很奇怪,当使用“.SNAPSHOT”版本时,工件如何最终出现在存储库中,因为版本文件夹是正确的,但工件名称是错误的:
这是我的存储库配置:
到目前为止我发现的唯一主题是这个 (Artifactory Snapshot filename handling),但 ist 并不直接适用于我的问题,因为我不想要任何时间戳。
我正在使用 Artifactory 3.8.0
任何帮助和解释将不胜感激
【问题讨论】:
标签: maven ant artifactory