You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Vitaliy S <ru...@gmail.com> on 2006/06/16 17:54:37 UTC

How to add mutable content to immutable build file

Hello,

I have target with a task supporting subtasks
e.g

 <copy todir="../dest/dir">
   <!--begin of mutable content -->
    <fileset dir="src_dir">
      <exclude name="**/*.java"/>
    </fileset>
   <!--end of mutable content -->
  </copy>
the content of task may be changed but the rest file is immutable.
I want to store mutable content in  seporate file.
What is the best way to do it?


Regards,
Vitaliy S

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How to add mutable content to immutable build file

Posted by "Scot P. Floess" <fl...@mindspring.com>.
Have you considered <macrodef>?

Look at the example <macrodef name="call-cc">  You will see a 
<cc-elements> child...  I think this is what you are wanting to do...

Vitaliy S wrote:
> Hello Ben,
>
> I want to let users to change content of task in my ant file but don't 
> want
> to let them change the file it self.
>
> e.g.
>
> <project name="myproject" basedir=".">
>     <target name="mytarget">
>         <copy todir="../dest/dir">
>           <fileset dir="src_dir">
>              <exclude name="/*.java"/>
>            </fileset>
>           <!--begin of mutable content -->
>            <fileset dir="other_src__dir">
>              <exclude name="**/*.java"/>
>            </fileset>
>           <!--end of mutable content -->
>         </copy>
>     </target>
> </project>
>
> In the example above mutable part can not be extracted as seporate
> task of other ant file.
> (in actual example it is hibernate hbm files include for xdoclet).
> I want to find clean solution to include xml code for subtasks from a
> different files to my build file.
>
> Thanks for your replay.
>
> Regards,
> Vitaliy S
> On 6/17/06, Ben Stringer <be...@burbong.com> wrote:
>> On Fri, 2006-06-16 at 18:54 +0300, Vitaliy S wrote:
>> > Hello,
>> >
>> > I have target with a task supporting subtasks
>> > e.g
>> >
>> >  <copy todir="../dest/dir">
>> >    <!--begin of mutable content -->
>> >     <fileset dir="src_dir">
>> >       <exclude name="**/*.java"/>
>> >     </fileset>
>> >    <!--end of mutable content -->
>> >   </copy>
>> > the content of task may be changed but the rest file is immutable.
>> > I want to store mutable content in  seporate file.
>> > What is the best way to do it?
>>
>> Hi Vitaliy,
>>
>> I'm not sure I understand your requirement, but if you are saying that
>> the XML describing the task will change from build to build, and you
>> need to use it, then I'd suggest using <import> to import the mutable
>> part of the task, then having the immutable part of the task call the
>> mutable part using <antcall>.
>>
>> Eg.
>>
>> mutable.xml:
>>
>> <project name="mutable" basedir=".">
>>   <target name="mutable.part">
>>     <echo>I change from build to build</echo>
>>   </target>
>> </project>
>>
>> build.xml:
>>
>> <project name="build" basedir=".">
>>   <import file="mutable.xml"/>
>>   <target name="immutable.part">
>>     <echo>I never change from build to build</echo>
>>     <antcall target="mutable.part"/>
>>     <echo>I also never change</echo>
>>   </target>
>> </project>
>>
>> If the mutable part changes _during_ build time, this gets trickier,
>> although it still should be possible to get working, by using the <ant>
>> task to re-import the mutable file.
>>
>> But not fully understanding what you are after, I may be way off here :)
>>
>> Cheers, Ben
>>
>> >
>> >
>> > Regards,
>> > Vitaliy S
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> > For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>
>

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How to add mutable content to immutable build file

Posted by "Robert r. Sanders" <ro...@ipov.net>.
So what you really want to do is "include" a 2nd file into the main ANT 
build? 

Look at the "Import" task from the Ant manual.  You could even use the 
first bit of your build to validate/create a "proper" snippet from 
somewhere else and then import it so your users can have a simplier syntax.


Vitaliy S wrote:
> Hello Ben,
>
> I want to let users to change content of task in my ant file but don't 
> want
> to let them change the file it self.
>
> e.g.
>
> <project name="myproject" basedir=".">
>     <target name="mytarget">
>         <copy todir="../dest/dir">
>           <fileset dir="src_dir">
>              <exclude name="/*.java"/>
>            </fileset>
>           <!--begin of mutable content -->
>            <fileset dir="other_src__dir">
>              <exclude name="**/*.java"/>
>            </fileset>
>           <!--end of mutable content -->
>         </copy>
>     </target>
> </project>
>
> In the example above mutable part can not be extracted as seporate
> task of other ant file.
> (in actual example it is hibernate hbm files include for xdoclet).
> I want to find clean solution to include xml code for subtasks from a
> different files to my build file.
>
> Thanks for your replay.
>
> Regards,
> Vitaliy S
> On 6/17/06, Ben Stringer <be...@burbong.com> wrote:
>> On Fri, 2006-06-16 at 18:54 +0300, Vitaliy S wrote:
>> > Hello,
>> >
>> > I have target with a task supporting subtasks
>> > e.g
>> >
>> >  <copy todir="../dest/dir">
>> >    <!--begin of mutable content -->
>> >     <fileset dir="src_dir">
>> >       <exclude name="**/*.java"/>
>> >     </fileset>
>> >    <!--end of mutable content -->
>> >   </copy>
>> > the content of task may be changed but the rest file is immutable.
>> > I want to store mutable content in  seporate file.
>> > What is the best way to do it?
>>
>> Hi Vitaliy,
>>
>> I'm not sure I understand your requirement, but if you are saying that
>> the XML describing the task will change from build to build, and you
>> need to use it, then I'd suggest using <import> to import the mutable
>> part of the task, then having the immutable part of the task call the
>> mutable part using <antcall>.
>>
>> Eg.
>>
>> mutable.xml:
>>
>> <project name="mutable" basedir=".">
>>   <target name="mutable.part">
>>     <echo>I change from build to build</echo>
>>   </target>
>> </project>
>>
>> build.xml:
>>
>> <project name="build" basedir=".">
>>   <import file="mutable.xml"/>
>>   <target name="immutable.part">
>>     <echo>I never change from build to build</echo>
>>     <antcall target="mutable.part"/>
>>     <echo>I also never change</echo>
>>   </target>
>> </project>
>>
>> If the mutable part changes _during_ build time, this gets trickier,
>> although it still should be possible to get working, by using the <ant>
>> task to re-import the mutable file.
>>
>> But not fully understanding what you are after, I may be way off here :)
>>
>> Cheers, Ben
>>
>> >
>> >
>> > Regards,
>> > Vitaliy S
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> > For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>
>

-- 
    Robert r. Sanders
    Chief Technologist
    iPOV
    (334) 821-5412
    www.ipov.net


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How to add mutable content to immutable build file

Posted by Vitaliy S <ru...@gmail.com>.
Hello Ben,

I want to let users to change content of task in my ant file but don't want
to let them change the file it self.

e.g.

<project name="myproject" basedir=".">
	<target name="mytarget">
		<copy todir="../dest/dir">
		  <fileset dir="src_dir">
		     <exclude name="/*.java"/>
		   </fileset>
		  <!--begin of mutable content -->
		   <fileset dir="other_src__dir">
		     <exclude name="**/*.java"/>
		   </fileset>
		  <!--end of mutable content -->
		</copy>
	</target>
</project>

In the example above mutable part can not be extracted as seporate
task of other ant file.
(in actual example it is hibernate hbm files include for xdoclet).
I want to find clean solution to include xml code for subtasks from a
different files to my build file.

Thanks for your replay.

Regards,
Vitaliy S
On 6/17/06, Ben Stringer <be...@burbong.com> wrote:
> On Fri, 2006-06-16 at 18:54 +0300, Vitaliy S wrote:
> > Hello,
> >
> > I have target with a task supporting subtasks
> > e.g
> >
> >  <copy todir="../dest/dir">
> >    <!--begin of mutable content -->
> >     <fileset dir="src_dir">
> >       <exclude name="**/*.java"/>
> >     </fileset>
> >    <!--end of mutable content -->
> >   </copy>
> > the content of task may be changed but the rest file is immutable.
> > I want to store mutable content in  seporate file.
> > What is the best way to do it?
>
> Hi Vitaliy,
>
> I'm not sure I understand your requirement, but if you are saying that
> the XML describing the task will change from build to build, and you
> need to use it, then I'd suggest using <import> to import the mutable
> part of the task, then having the immutable part of the task call the
> mutable part using <antcall>.
>
> Eg.
>
> mutable.xml:
>
> <project name="mutable" basedir=".">
>   <target name="mutable.part">
>     <echo>I change from build to build</echo>
>   </target>
> </project>
>
> build.xml:
>
> <project name="build" basedir=".">
>   <import file="mutable.xml"/>
>   <target name="immutable.part">
>     <echo>I never change from build to build</echo>
>     <antcall target="mutable.part"/>
>     <echo>I also never change</echo>
>   </target>
> </project>
>
> If the mutable part changes _during_ build time, this gets trickier,
> although it still should be possible to get working, by using the <ant>
> task to re-import the mutable file.
>
> But not fully understanding what you are after, I may be way off here :)
>
> Cheers, Ben
>
> >
> >
> > Regards,
> > Vitaliy S
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
Regards,
Vitaliy S

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How to add mutable content to immutable build file

Posted by Ben Stringer <be...@burbong.com>.
On Fri, 2006-06-16 at 18:54 +0300, Vitaliy S wrote:
> Hello,
> 
> I have target with a task supporting subtasks
> e.g
> 
>  <copy todir="../dest/dir">
>    <!--begin of mutable content -->
>     <fileset dir="src_dir">
>       <exclude name="**/*.java"/>
>     </fileset>
>    <!--end of mutable content -->
>   </copy>
> the content of task may be changed but the rest file is immutable.
> I want to store mutable content in  seporate file.
> What is the best way to do it?

Hi Vitaliy,

I'm not sure I understand your requirement, but if you are saying that
the XML describing the task will change from build to build, and you
need to use it, then I'd suggest using <import> to import the mutable
part of the task, then having the immutable part of the task call the
mutable part using <antcall>.

Eg.

mutable.xml:

<project name="mutable" basedir=".">
  <target name="mutable.part">
    <echo>I change from build to build</echo>
  </target>
</project>

build.xml:

<project name="build" basedir=".">
  <import file="mutable.xml"/>
  <target name="immutable.part">
    <echo>I never change from build to build</echo>
    <antcall target="mutable.part"/>
    <echo>I also never change</echo>
  </target>
</project>

If the mutable part changes _during_ build time, this gets trickier,
although it still should be possible to get working, by using the <ant>
task to re-import the mutable file. 

But not fully understanding what you are after, I may be way off here :)

Cheers, Ben

> 
> 
> Regards,
> Vitaliy S
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org