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

Apache IVY - Info Task


Previous Page Next Page  

info task is used to set ivy specific information in a file and can be used without any dependency resolution.

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. Before pubpsh task, we ve set the required ivy information using info task.

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:info file="ivy.xml" />
      <ivy:pubpsh resolver="local" pubrevision="1.0" overwrite="true">
         <artifacts pattern="${build.dir}/pb/[artifact].[ext]" />
      </ivy:pubpsh>   
   </target>
</project>

Here pubpsh task first build the jar, then set the information using ivy:info task 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.


Buildfile: E:ivyuild.xml

jar:

pubpsh:
 [ivy:info] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy/
::
 [ivy:info] :: loading settings :: url = jar:file:/E:/Apache/apache-ant-1.9.14/l
ib/ivy-2.5.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[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: 0 seconds

If we do not put the info task then pubpsh task will not work. Use the below modified build.xml and see the error for missing organization attribute and so on.

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:pubpsh resolver="local" pubrevision="1.0" overwrite="true">
         <artifacts pattern="${build.dir}/pb/[artifact].[ext]" />
      </ivy:pubpsh>   
   </target>
</project>

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.


Buildfile: E:ivyuild.xml

jar:

pubpsh:
[ivy:pubpsh] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy
/ ::
[ivy:pubpsh] :: 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

BUILD FAILED
E:ivyuild.xml:28: no organisation provided for ivy pubpsh task: It can eithe
r be set exppcitly via the attribute  organisation  or via  ivy.organisation  p
roperty or a prior call to <resolve/>

Total time: 3 seconds
Advertisements