代码之家  ›  专栏  ›  技术社区  ›  John Mercier

要从常春藤本地回购中删除的Ant任务

  •  1
  • John Mercier  · 技术社区  · 6 年前

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

    1 回复  |  直到 6 年前
        1
  •  2
  •   Lolo    6 年前

    它可以通过调用一些脚本来完成 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'