如何在IVY中使用通配符:<artifacts pattern =“...”>

时间:2018-02-09 09:07:26

标签: ivy

我想用常春藤发布我的工件,但我的构建路径是动态的而不是静态的,因为它包含TAG版本,即:&#34; build_02.14Test3&#34;。

这是来自我的build.xml:

<target name="go" depends="install-ivy" 
            description="--> create and publish">
            <property environment="env"/>   
            <fail unless="env.PUBREVISION" message="no publish revision set!"/>
        <ivy:resolve/>  
        <ivy:publish resolver="components" pubrevision="${env.PUBREVISION}">
            <artifacts pattern="../Java/build_*/Release/[artifact].[ext]"/>
        </ivy:publish>
    </target>

整个build.xml文件:

<!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.    
-->
<project name="build-ivy" default="go" xmlns:ivy="antlib:org.apache.ivy.ant">
    <!-- 

        More information can be found at http://ant.apache.org/ivy/
        -->

    <!-- here is the version of ivy we will use. change this property to try a newer 
         version if you want -->
    <property name="ivy.install.version" value="2.4.0" />
    <property name="ivy.jar.dir" value="${basedir}/ivy" />
    <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />

    <property name="build.dir" value="build" />
    <property name="src.dir" value="src" />


    <target name="download-ivy" unless="skip.download">
        <mkdir dir="${ivy.jar.dir}"/>
        <!-- download Ivy from artifactory so that it can be used even without any special installation -->
        <echo message="installing ivy..."/>
        <get src="https://artifactory.company.com/artifactory/virtual-maven/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
             dest="${ivy.jar.file}" usetimestamp="true" username="svcbuild" password="**********************"/>
    </target>

    <!-- ================================= 
          target: install-ivy         
            this target is not necessary if you put ivy.jar in your ant lib directory
            if you already have ivy in your ant lib, you can simply remove this
            target and the dependency the 'go' target has on it
         ================================= -->
    <target name="install-ivy" depends="download-ivy" description="--> install ivy">
        <!-- try to load ivy here from local ivy dir, in case the user has not already dropped
              it into ant's lib dir (note that the latter copy will always take precedence).
              We will not fail as long as local lib dir exists (it may be empty) and
              ivy is in at least one of ant's lib dir or the local lib dir. -->
        <path id="ivy.lib.path">
            <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
        </path>
        <taskdef resource="org/apache/ivy/ant/antlib.xml"
                  uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
    </target>    

    <!-- ================================= 
          target: go
                    Go ivy, go!
         ================================= -->
   <target name="go" depends="install-ivy" 
            description="--> create and publish">
            <property environment="env"/>   
            <fail unless="env.PUBREVISION" message="no publish revision set!"/>
        <ivy:resolve/>  
        <ivy:publish resolver="components" pubrevision="${env.PUBREVISION}">
            <artifacts pattern="../Java/build_*/Release/[artifact].[ext]"/>
        </ivy:publish>
    </target>


    <!-- ================================= 
          target: clean              
         ================================= -->
    <target name="clean" description="--> clean the project">
        <delete includeemptydirs="true" quiet="true">
            <fileset dir="${src.dir}" />
            <fileset dir="${build.dir}" />
        </delete>
    </target>

    <!-- ================================= 
          target: clean-ivy              
         ================================= -->
    <target name="clean-ivy" description="--> clean the ivy installation">
        <delete dir="${ivy.jar.dir}"/>
    </target>

    <!-- ================================= 
          target: clean-cache              
         ================================= -->
    <target name="clean-cache" depends="install-ivy" 
            description="--> clean the ivy cache">
        <ivy:cleancache />
    </target>
</project>

基本上我只想知道为什么我的通配符&#34; *&#34;不工作以及如何解决它。

运行我的管道时遇到了无法识别通配符的问题:

[ivy:publish] :: delivering :: COMPANY#some.product;working@BUILD_PC :: 02.14Test11 :: integration :: Fri Feb 09 09:13:36 CET 2018
[ivy:publish]   options = status=integration pubdate=Fri Feb 09 09:13:36 CET 2018 validate=true resolveDynamicRevisions=true merge=true resolveId=null pubBranch=null
[ivy:publish]   delivering ivy file to D:\gr\builds\3d9e5594\0\plast\products\some.product\Java\build_*\Release\ivy.xml

BUILD FAILED
D:\gr\builds\3d9e5594\0\plast\products\some.product\ivy\build.xml:70: COMPANY#some.product;working@BUILD_PC: java.io.FileNotFoundException: D:\gr\builds\3d9e5594\0\plast\products\some.product\Java\build_*\Release\ivy.xml (The filename, directory name, or volume label syntax is incorrect)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
    at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorUpdater.update(XmlModuleDescriptorUpdater.java:135)
    at org.apache.ivy.core.deliver.DeliverEngine.deliver(DeliverEngine.java:207)
    at org.apache.ivy.Ivy.deliver(Ivy.java:607)
    at org.apache.ivy.ant.IvyDeliver.doExecute(IvyDeliver.java:420)
    at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:271)
    at org.apache.ivy.ant.IvyPublish.doExecute(IvyPublish.java:308)
    at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:271)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
    at org.apache.tools.ant.Main.runBuild(Main.java:857)
    at org.apache.tools.ant.Main.startAnt(Main.java:236)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)

根据要求提供Ivy.xml (注意我更换了公司和产品名称!):

<ivy-module version="2.0">
    <info organisation="MyOrganisation" module="Organisation.product" />
    <publications>

<artifact name="Data1" ext="cab" type="binaries" />
<artifact name="Organisation product" ext="msi" type="binaries" />
<artifact name="setup" ext="exe" type="binaries" />
<artifact name="splash" ext="bmp" type="binaries" />
<artifact name="Java/jre-8u131-windows-i586" ext="exe" type="binaries" />
<artifact name="ProdA RemTool/Data1" ext="cab" type="binaries" />
<artifact name="ProdA RemTool/ProdA RemTool 01.36" ext="msi" type="binaries" />
<artifact name="ProdA RemTool/setup" ext="exe" type="binaries" />
<artifact name="ProdA RemTool/splash" ext="png" type="binaries" />
<artifact name="ProdA RemTool/viewsimba.splash" ext="bmp" type="binaries" />

 </publications>

</ivy-module>

1 个答案:

答案 0 :(得分:0)

我的问题的解决方案是修复这样的构建路径:

<artifacts pattern="../Java/build_${env.PUBREVISION}/Release/[artifact].[ext]"/>

因为${env.PUBREVISION}/包含TAG,这是我的构建文件夹:)