从 ivy 本地仓库中删除的 Ant 任务
Ant task to delete from ivy local repo
我有一个本地存储库,其中的工件作为 m2 兼容存储库发布。
<filesystem name="local" m2compatible="true" local="true">
<ivy pattern="${ivy.local.default.root}/[organization]/[module]/[revision]/[module]-[revision](-[classifier]).pom" />
<artifact pattern="${ivy.local.default.root}/[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]" />
</filesystem>
常春藤信息在组织中有'.'。
例如,
<info organization="com.github.org" module="module" rev="0.1" status="release"/>
发布工件时,它们最终会出现在这样的目录中:
/.ivy2/local/com/github/org/module/0.1/*
删除任务设置如下:
<delete dir="${ivy.local.default.root}/${ivy.organization}/${ivy.module}/${ivy.revision}"/>
我认为这行不通,因为 ivy.organization
没有为删除任务拆分到单独的目录中。
如何设置项目以正确删除已发布的 jar 文件?
可以通过一些脚本来完成,以在要转换为文件路径片段的字符串上调用 String.replaceAll()
。例如使用以下 macrodef
:
<!-- =============================================================================
Replaces all '.' in groupId with '/' and put the result in a property
Attributes:
- groupId: maven groupId
- result: name of the property in which to put the result
============================================================================== -->
<macrodef name="pathFrom">
<attribute name="groupId"/>
<attribute name="result" default="path"/>
<sequential>
<local name="g"/>
<property name="g" value="@{groupId}"/>
<script language="javascript">
project.setProperty("@{result}", project.getProperty("g").replaceAll("\.", "/"));
</script>
</sequential>
</macrodef>
这是一个用法示例:
<target name="test">
<property name="myGroup" value="com.github.org"/>
<pathFrom groupId="${myGroup}" result="tmp.path"/>
<echo message="converted from '${myGroup}' to '${tmp.path}'"/>
</target>
使用 ant test
调用时具有以下输出:
test:
[echo] converted from 'com.github.org' to 'com/github/org'
我有一个本地存储库,其中的工件作为 m2 兼容存储库发布。
<filesystem name="local" m2compatible="true" local="true">
<ivy pattern="${ivy.local.default.root}/[organization]/[module]/[revision]/[module]-[revision](-[classifier]).pom" />
<artifact pattern="${ivy.local.default.root}/[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]" />
</filesystem>
常春藤信息在组织中有'.'。
例如,
<info organization="com.github.org" module="module" rev="0.1" status="release"/>
发布工件时,它们最终会出现在这样的目录中:
/.ivy2/local/com/github/org/module/0.1/*
删除任务设置如下:
<delete dir="${ivy.local.default.root}/${ivy.organization}/${ivy.module}/${ivy.revision}"/>
我认为这行不通,因为 ivy.organization
没有为删除任务拆分到单独的目录中。
如何设置项目以正确删除已发布的 jar 文件?
可以通过一些脚本来完成,以在要转换为文件路径片段的字符串上调用 String.replaceAll()
。例如使用以下 macrodef
:
<!-- =============================================================================
Replaces all '.' in groupId with '/' and put the result in a property
Attributes:
- groupId: maven groupId
- result: name of the property in which to put the result
============================================================================== -->
<macrodef name="pathFrom">
<attribute name="groupId"/>
<attribute name="result" default="path"/>
<sequential>
<local name="g"/>
<property name="g" value="@{groupId}"/>
<script language="javascript">
project.setProperty("@{result}", project.getProperty("g").replaceAll("\.", "/"));
</script>
</sequential>
</macrodef>
这是一个用法示例:
<target name="test">
<property name="myGroup" value="com.github.org"/>
<pathFrom groupId="${myGroup}" result="tmp.path"/>
<echo message="converted from '${myGroup}' to '${tmp.path}'"/>
</target>
使用 ant test
调用时具有以下输出:
test:
[echo] converted from 'com.github.org' to 'com/github/org'