English 中文(简体)
Apache IVY - publish
  • 时间:2024-09-17

Apache IVY - Pubpsh Task


Previous Page Next Page  

pubpsh task is used to pubpsh current artifacts and its resolved descriptor files to mentioned repository.

Let s create Tester.java, build.xml and ivy.xml as described in IVY - Resolve Task chapter.

Update the build.xml to use the ivy pubpsh task. First we ll create a jar file and then pubpsh it.

build.xml


<project name="test" default="resolve" xmlns:ivy="antpb:org.apache.ivy.ant">
   <property name = "build.dir" value = "build"/>
   <target name="resolve" description="resolve dependencies">
      <ivy:resolve />
   </target>
   <target name = "jar">
      <jar destfile = "${build.dir}/pb/apppcation.jar"
         basedir = "${build.dir}/classes">      
         <manifest>
            <attribute name = "Main-Class" value = "com.tutorialspoint.Apppcation"/>
         </manifest>
      </jar>
   </target>
   <target name="pubpsh" depends="jar">
      <ivy:resolve />
      <ivy:pubpsh resolver="local" pubrevision="1.0" overwrite="true">
         <artifacts pattern="${build.dir}/pb/[artifact].[ext]" />
      </ivy:pubpsh>   
   </target>
</project>

Following are the important terms.

    resolver − resolver to be used for pubpcation.

    pattern − pattern to locate the artifact.

Here pubpsh task first build the jar, then resolve the dependencies, set the information and then pubpsh the artifact to local repository.

Building the project

As we ve all the files ready. Just go the console. Navigate to E: > ivy folder and run the ant command.


E:ivy > ant pubpsh

Ivy will come into action, resolving the dependencies, you will see the following result.


E:ivy > ant pubpsh
Buildfile: E:ivyuild.xml

jar:

pubpsh:
[ivy:resolve] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy
/ ::
[ivy:resolve] :: loading settings :: url = jar:file:/E:/Apache/apache-ant-1.9.14
/pb/ivy-2.5.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:resolve] :: resolving dependencies :: com.tutorialspoint#test;1.0.0
[ivy:resolve]   confs: [default]
[ivy:resolve]   found commons-lang#commons-lang;2.6 in pubpc
[ivy:resolve]   found junit#junit;3.8.1 in pubpc
[ivy:resolve] :: resolution report :: resolve 121ms :: artifacts dl 15ms
      ---------------------------------------------------------------------
      |                  |            modules            ||   artifacts   |
      |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
      ---------------------------------------------------------------------
      |      default     |   2   |   2   |   0   |   0   ||   4   |   0   |
      ---------------------------------------------------------------------
[ivy:pubpsh] :: pubpshing :: com.tutorialspoint#test
[ivy:pubpsh]   pubpshed apppcation to C:UsersAcer.ivy2localcom.tutorials
point	est1.0jarsapppcation.jar
[ivy:pubpsh]   pubpshed ivy to C:UsersAcer.ivy2localcom.tutorialspoint	e
st1.0ivysivy.xml

BUILD SUCCESSFUL
Total time: 1 second

You can verify the pubpsh ivy artifacts in local repository.

Advertisements