You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Pete <pe...@gmail.com> on 2006/05/15 14:09:14 UTC

Re: [m2] problem w/ antcall in ANT-based mojo

Did anyone reslove this issue ?
This is a major flaw with the ant-based mojo.

Wayne is correct in that if you place a build.xml containing the antcall
targets it works, BUT this build.xml has to be in the current directory.

Therefore I cannot create a reusable ant-based plugin, because everywhere I
need to use it I have to have a build.xml in the current directory !
(containing these internal helper targets)

Pete


On 21/03/06, Adrian Herscu <bm...@fastmail.fm> wrote:
>
> Wayne, thanks for your reply.
> I will try your idea now.
>
>
> Wayne Fay wrote:
> > When you create the my/project/path/build.xml file and add the task to
> > that file, does the antcall function work as you expected?
> >
> > Not saying this is the proper solution, just trying to help figure it
> out...
> >
> > Wayne
> >
> >
> > On 3/19/06, Adrian Herscu <bm...@fastmail.fm> wrote:
> >> Hi all,
> >>
> >> When using antcall in an ANT-based mojo the build fails with
> >>
> >> [ERROR] BUILD ERROR
> >> [INFO]
> >>
> -------------------------------------------------------------------------
> >> ---
> >> [INFO] Failed to execute: Executing Ant script:
> >> /my/plugin/path/mymojo.build.xml [my-target]: Failed to execute.
> >>
> >> my/project/path/build.xml (The system cannot find the file s
> >> pecified)
> >>
> >> (of course in my project dir. there is no build.xml)
> >>
> >> ANT's documentation
> >> (http://ant.apache.org/manual/CoreTasks/antcall.html) says that antcall
> >> invokes targets in the same build file, namely in mymojo.build.xml --
> so
> >> why it tries to find build.xml in project's directory?
> >>
> >> Thanks for any hint,
> >> Adrian.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: [m2] problem w/ antcall in ANT-based mojo

Posted by cristal <da...@jpmorgan.com>.
That's great!. I applied the macrodef usage in my situation and it worked
very well. Finally we get rid of the <antcall> code that mojo plugin doesn't
work very well with.

Thanks Pete.

--
View this message in context: http://www.nabble.com/-m2--problem-w--antcall-in-ANT-based-mojo-t1307160.html#a5011671
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] problem w/ antcall in ANT-based mojo

Posted by Pete <pe...@gmail.com>.
Here's a macrodef

	<macrodef name="macro.dbunit-update">
		<attribute name="databaseDriver" />
		<attribute name="databaseUrl"  />
		<attribute name="databaseUsername"  />
		<attribute name="databasePassword"  />
		<attribute name="datatypeFactory"  />
		<attribute name="operation"  />
		<attribute name="srcDir"  />
		<attribute name="filename"  />
		<attribute name="file-extension"  />
		<attribute name="format"  />
		<!-- <element name="options" optional="true" />  -->
		<sequential>
			<echo message="------ MACRO macro.dbunit-update -----------" />
			<dbunit driver="${databaseDriver}" url="${databaseUrl}"
userid="${databaseUsername}" password="${databasePassword}"
datatypeFactory="${datatypeFactory}">
				<classpath refid="dbunit.classpath"/>
				<operation type="${operation}"
src="${srcDir}/${filename}.@{file-extension}" format="@{format}"/>
			</dbunit>
		</sequential>
	</macrodef>

Here's invoking it

<target name="dbunit-update-XML" depends="int.echo-properties"
description="Refreshes DB using data from XML file">
		<macro.dbunit-update databasedriver="${databaseDriver}"
					databasepassword="${databasepassword}"
					databaseurl="${databaseurl}"
					databaseusername="${databaseusername}"
					datatypefactory="${datatypefactory}"
					file-extension="xml"
					filename="${filename}"
					format="flat"
					operation="${operation}"
					srcdir="${srddir}">
		</macro.dbunit-update>
			
	</target>

On 20/06/06, cristal <da...@jpmorgan.com> wrote:
>
> Thanks Pete, that sounds very promising. Could you also post a piece of
> sample code? Thanks a lot.
> --
> View this message in context: http://www.nabble.com/-m2--problem-w--antcall-in-ANT-based-mojo-t1307160.html#a4956130
> Sent from the Maven - Users forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] problem w/ antcall in ANT-based mojo

Posted by cristal <da...@jpmorgan.com>.
Thanks Pete, that sounds very promising. Could you also post a piece of
sample code? Thanks a lot.
--
View this message in context: http://www.nabble.com/-m2--problem-w--antcall-in-ANT-based-mojo-t1307160.html#a4956130
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] problem w/ antcall in ANT-based mojo

Posted by Pete <pe...@gmail.com>.
I got around this issue in the end by using Ant 1.6's new macrodef
feature, this allows you to easily create a macro instead of a
callable ant target.

See
http://ant.apache.org/manual/CoreTasks/macrodef.html

so I put the Macrodef's in the same build file and called them where necessary.

Pete

On 16/06/06, cristal <da...@jpmorgan.com> wrote:
>
> The only work-around to this issue is to add a line of ant script in the
> target before you invoke the <antcall>task, like this
>
>     <copy file="/my/plugin/path/mymojo.build.xml"
> tofile="/my/plugin/path/build.xml" />
>
> so that there is always a build.xml available in the directory by the time
> <antcall> is executed. But you will always need to remember the
> "mymojo.build.xml" is the real one for you to work with when you modify the
> mojo plugin.
>
> It's ugly but works for me.
>
>
> --
> View this message in context: http://www.nabble.com/-m2--problem-w--antcall-in-ANT-based-mojo-t1307160.html#a4905731
> Sent from the Maven - Users forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] problem w/ antcall in ANT-based mojo

Posted by cristal <da...@jpmorgan.com>.
The only work-around to this issue is to add a line of ant script in the
target before you invoke the <antcall>task, like this

    <copy file="/my/plugin/path/mymojo.build.xml"
tofile="/my/plugin/path/build.xml" />

so that there is always a build.xml available in the directory by the time
<antcall> is executed. But you will always need to remember the
"mymojo.build.xml" is the real one for you to work with when you modify the
mojo plugin. 

It's ugly but works for me.


--
View this message in context: http://www.nabble.com/-m2--problem-w--antcall-in-ANT-based-mojo-t1307160.html#a4905731
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] problem w/ antcall in ANT-based mojo

Posted by cristal <da...@jpmorgan.com>.
Pete, this is still a problem as of today. I am having exactly the same
situation as you did. Haven't found any solution yet. 

Folks, please share some tips on this if you know any. 
--
View this message in context: http://www.nabble.com/-m2-+problem+w-+antcall+in+ANT-based+mojo-t1307160.html#a4666854
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org