java - 从 ivy 本地存储库中删除的 Ant 任务

标签 java ant ivy

我有一个本地存储库,其中的工件作为 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>

ivy 信息的组织中有“.”。

例如,

<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'

关于java - 从 ivy 本地存储库中删除的 Ant 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53782891/

相关文章:

java - JPanel 未显示

java - 如何使用 XMLDog 从 xml 文件中检索值

dependencies - 版本控制中多模块源项目的声明性依赖处理

Gradle 在 ~/.ivy2/local 中找不到我的依赖项

java - 是否有正则表达式可以读取字符串/html 标记中的电子邮件地址?

java - JPQL 中对象构造函数内的子查询

java.lang.VerifyError : Bad type on operand stack in method com. sun.net.httpserver.spi.HttpServerProvider 错误

android - 在 Cordova v-5.0 CLI 中签名 APK 文件不起作用

未使用的 Javac 配置参数包含警告?

java - 如何在eclipse juno中导入并运行ivy+ant项目