0

我是常春藤的新手。

  1. 我正在使用打包器解析器,该打包器解析器解析 zip 文件,解压缩它,在临时构建文件中从中提取 jar 文件,但它暂时保留,只有我指定为模块名称的 jar 文件被复制到目标其余部分都被忽略了。有没有办法我可以得到所有的 jar 文件?我使用 preseverBuildDirectories 但有更好的方法吗?

  2. 我也可以使用普通的常春藤将工件发布到 svn 吗?当我尝试使用 ant 1.8.0 java.illegalArguementException 在 XP 上使用 ivy 2.1.0 时出现错误,提示授权失败。有没有办法通过 ivy:publish 工作?

  3. 有没有办法可以在 packager.xml 中使用 ivy 变量?

在此先感谢,阿尔马斯

4

1 回答 1

2

1) 打包解析器

您需要为重新打包的模块包含一个 ivy 文件,其中列出了所有工件。

这是我下载与 Solr 发行版关联的文件的示例

常春藤设置.xml

<ivysettings>
    <settings defaultResolver="maven2"/>

    <caches defaultCacheDir="${user.home}/.ivy2/cache"/>

    <resolvers>
        <ibiblio name="maven2" m2compatible="true"/>

        <packager name="repackage" buildRoot="${user.home}/.ivy2/packager/build" resourceCache="${user.home}/.ivy2/packager/cache" preserveBuildDirectories="false">
            <ivy pattern="file:///${ivy.settings.dir}/packager/[organisation]/[module]/ivy-[revision].xml"/>
            <artifact pattern="file:///${ivy.settings.dir}/packager/[organisation]/[module]/packager-[revision].xml"/>
        </packager>
    </resolvers>

    <modules>
        <module organisation="org.apache.solr" name="solr" resolver="repackage"/>
    </modules>
</ivysettings>

请注意打包程序解析器如何指定 ivy 和打包程序文件的路径。

ivy 文件在发布部分指定作为包一部分的工件。

packager/org.apache.solr/solr/ivy-1.4.0.xml

<ivy-module version="2.0">
    <info organisation="org.apache.solr" module="solr" revision="1.4.0"/>
    <configurations>
        <conf name="jars"    description="Jars released with SOLR distribution"/>
        <conf name="webapps" description="Web applications"/>
    </configurations>
    <publications>
        <!-- jars -->
        <artifact name="solr-cell" conf="jars"/>
        <artifact name="solr-clustering" conf="jars"/>
        <artifact name="solr-core" conf="jars"/>
        <artifact name="solr-dataimporthandler" conf="jars"/>
        <artifact name="solr-dataimporthandler-extras" conf="jars"/>

        <!-- webapps -->
        <artifact name="solr" type="war" conf="webapps"/>
    </publications>
</ivy-module>

打包程序文件包含为solr模块复制 ivy 文件中列出的每个工件的逻辑。

packager/org.apache.solr/solr/packager-1.4.0.xml

<packager-module version="1.0">

    <property name="name" value="${ivy.packager.module}"/>
    <property name="version" value="${ivy.packager.revision}"/>

    <resource dest="archive" url="http://ftp.heanet.ie/mirrors/www.apache.org/dist/lucene/solr/1.4.0/apache-solr-1.4.0.tgz" sha1="521d4d7ce536dd16c424a11ae8837b65e6b7bd2d">
        <url href="http://www.apache.org/dist/lucene/solr/1.4.0/apache-solr-1.4.0.tgz"/>
    </resource>

    <build>
        <!-- Jar artifacts -->
        <move file="archive/apache-${name}-${version}/dist/apache-${name}-cell-${version}.jar" tofile="artifacts/jars/${name}-cell.jar"/>
        <move file="archive/apache-${name}-${version}/dist/apache-${name}-clustering-${version}.jar" tofile="artifacts/jars/${name}-clustering.jar"/>
        <move file="archive/apache-${name}-${version}/dist/apache-${name}-core-${version}.jar" tofile="artifacts/jars/${name}-core.jar"/>
        <move file="archive/apache-${name}-${version}/dist/apache-${name}-dataimporthandler-${version}.jar" tofile="artifacts/jars/${name}-dataimporthandler.jar"/>
        <move file="archive/apache-${name}-${version}/dist/apache-${name}-dataimporthandler-extras-${version}.jar" tofile="artifacts/jars/${name}-dataimporthandler-extras.jar"/>

        <!-- War artifacts -->
        <move file="archive/apache-${name}-${version}/dist/apache-${name}-${version}.war" tofile="artifacts/wars/${name}.war"/>
    </build>

</packager-module>

2)发布到颠覆

我自己从未使用过它,但我认为您需要配置颠覆解析器并使用它来发布您的工件

3) 在打包程序文件中使用常春藤变量

上面列出的打包程序文件使用两个 ivy 变量。不确定你的问题是什么。

更新:支持 3rd 方罐子

ivy 文件的 Publications 部分包含以第 3 方 jar 名称命名的版本号:

常春藤文件

..
<publications>
    <artifact name="abc-1.0" conf="jars"/>
    <artifact name="pqr-2.0" conf="jars"/>
</publications>
..

打包程序文件

..
<build>
    <move file="archive/apache-${name}-${version}/dist/abc-1.0.jar" tofile="artifacts/jars/abc-1.0.jar"/>
    <move file="archive/apache-${name}-${version}/dist/pqr-2.0.jar" tofile="artifacts/jars/pqr-2.0.jar"/>
</build>
..
于 2010-05-20T21:54:11.990 回答