Sunday, 15 March 2015

build - How can I best share Ant targets between projects? -


Is there a well-established way of sharing goals between projects? I currently have a solution, but it is a little rude. Here's what I'm doing here.

I have a network that is hosted on ivy-tasks.xml which is hosted on one server on our network. Other targets for managing project dependency in this file are included among boilerplate tasks. For example:

  & lt; Name of the project = "ant-iv-work" default = "init-ivy" xmlns: ivy = "antlib: org.apache.ivy.ant" & gt; ... & lt; Goal name = "Iv-download" until "skip.ivy.download" & gt; & Lt; Mkdir dir = "$ {ivy.jar.dir}" /> & Lt; Echo Message = "Establishing IV ..." /> & Lt; Get src = "http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest = "$ {Ivy.jar.file} "usetimestamp =" true "/> & Lt; / Target & gt; & Lt; Target name = "ivy-init" depend = "IV-download" description = "- & gt; defines iv functions and loads global settings" & gt; & Lt; Path id = "ivy.lib.path" & gt; & Lt; Fileset dir = "$ {ivy.jar.dir}" includes = "* .jar" /> & Lt; / Path & gt; & Lt; Taskdef resource = "org / apache / ivy / ant / antlib.xml" uri = "antibu: org.apache.ivy.ant" classpathref = "ivy.lib.path" /> & Lt; IV: Settings url = "http: //myserver/ivy/settings/ivysettings-user.xml" /> & Lt; / Target & gt; ... & lt; / Project & gt;  

Due this file is hosted because I want no :

  • Check the file in each project It will be duplicated, which makes it difficult to maintain the goal.
  • My Build. Depending on the Xml source control a project is examined - this will make the build more XML at the top-level just to access the file.

What do I do with this file in my projects' build.xmls:

  & lt; Property Name = "Download.dir" location = "Downloads" /> & Lt; Mkdir dir = "$ {download.dir}" /> & Lt; Echo message = "download import files at $ {download.dir}" /> & Lt; Get src = "http: //myserver/ivy/ivy-tasks.xml" dest = "$ {download.dir} /ivy-tasks.xml" usetimestamp = "true" /> & Lt; Import file = "$ {download.dir} /ivy-tasks.xml" />  

The "dirty" part about this is that I have to do the above step out of a target , because it should be at the top level, besides me, still This XML must be included in all build.xml files for which it is needed (i.e. some duplication is still).

Above that, there may be additional situations where I have general (non-Ivy) jobs that I want to import if I want to use these functions to depend on iv dependency management Problems are also coming, as long as I resolve the dependency, I had to be inside a target in my build.xml, and was unable to import

" Text ">

If you are using ANN 1.8+, you can import build.xml directly from the hosted location.

Since ant 1.8.0 work can also import resources from URLs or classpath resources (in real terms) If you want to know whether the existing build file has a source file or a URL, then you can consult the property ant.file.type.projectname (using the same example above ant.file.type.builddocs), which That it has the value "file" or "url".

  & lt ;! - importing.xml - & gt; & Lt; Name of the project = "import" based = "." Default = "..." & gt; & Lt; Import file = "http: //myserver/ivy/ivy-tasks.xml" /> & Lt; / Project & gt;  

No comments:

Post a Comment