You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jacob Beard <jb...@cs.mcgill.ca> on 2010/08/27 04:56:26 UTC

question on capabilities of AntRun plugin

Hi,

I have question on the capabilities of the AntRun plugin. This example 
shows the Maven classpaths being copied into Ant properties, which are 
then used in Ant:

http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html

I thougth it would be useful to reference these classpaths directly in 
Ant, rather than using the copied properties, and so I ran a series of 
tests. What I found was that the maven classpaths could be referenced, 
but only in the scope of the called target. When used outside of a 
target (in a taskdef, for example), an error is thrown. On the other 
hand, properties that are created in the Maven tasks element can be used 
both in and outside of the scope of the called target. This is using the 
ant task, with both inheritsAll and inheritsRefs set to true.

I'm wondering if I'm correct in the above assessment of the capabilities 
of antrun. Can maven classpaths not be referenced directly, outside of 
the scope of the called ant task? If they cannot, what is the best way 
in Ant to read a classpath that has been read into a property back into 
a path element?

Let me know. Thanks,

Jake

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


Re: question on capabilities of AntRun plugin

Posted by Jacob Beard <jb...@cs.mcgill.ca>.
Hi,

My motivation to use Maven comes from the fact that I'm working on a 
Commons sandbox component. Because all of Commons build infrastructure 
is Maven-based, there's a strong incentive for me to integrate my 
project with Maven. So, basically, I'm trying to have the best of both 
worlds: to reuse the work I've done with Ant, while leveraging all that 
Maven and the Commons parent pom bring to the table.

I really don't see why, in principle, hooking into Ant with Maven and 
AntRun is a bad idea. I think it's fairly common for build systems to be 
made extensible through multiple mechanisms, including both plugins and 
scripting. I see AntRun as bringing a scripting language to Maven, which 
is an alternative to extending it with plugins. As my project is quite 
different from a typical Maven project, I feel that it is appropriate to 
start with this approach.

In any case I found the solution to my original question here:

http://docs.codehaus.org/display/MAVENUSER/Antrun+Plugin#AntrunPlugin-PassingyourMavenclasspathtoAnt:

Thanks everyone for your insight and support,

Jake

On 10-08-27 06:21 PM, Stephen Connolly wrote:
> If you have "invested a significant amount of time in preparing the Ant
> build, and so I would prefer to find a way to leverage this work, rather
> than starting from scratch with Maven" then I recommend that you do not use
> Maven.  Instead use maven-ant-tasks to interact with the maven repository
> and keep your build in ANT.
>
> The reality is that if you are not prepared to drink the Maven kool-aid (it
> tastes great) then stick with ANT.
>
> The golden rule is "If a build ain't broke, don't fix it"
>
> Now this triggers a question.... why do you want to use Maven to build your
> project?
>
> -Stephen
>
> On 27 August 2010 17:58, Jacob Beard<jb...@cs.mcgill.ca>  wrote:
>
>    
>> Hi Wayne,
>>
>> The situation is that I have invested a significant amount of time in
>> preparing the Ant build, and so I would prefer to find a way to leverage
>> this work, rather than starting from scratch with Maven. As my project is
>> unconventional, and I'm not yet fully comfortable with Maven, I feel like,
>> at this stage, continuing to use Ant for certain parts of the build is a
>> better, safer approach. I believe this is what the AntRun plugin is designed
>> to facilitate.
>>
>> If anyone could offer any guidance regarding my original question, I would
>> greatly appreciate it. Thanks,
>>
>> Jake
>>
>>
>> On 10-08-27 12:17 PM, Wayne Fay wrote:
>>
>>      
>>> /home/jacob/workspace/gsoc2010/git-scxml-js/scxml-js/test-maven.xml:19:
>>>        
>>>> Reference maven.compile.classpath not found.
>>>>
>>>> Please let me know what you think. Thanks,
>>>>
>>>>
>>>>          
>>> Is this just "for fun" or are you seriously trying to build a big mess
>>> of your build by continuing to use various aspects of your build in
>>> Ant via Antrun and other aspects in Maven, and then sharing properties
>>> around etc?
>>>
>>> Honestly, you should just convert your Ant "stuff" into Maven plugins.
>>> It is pretty simple to write proper Maven plugins. And far easier to
>>> debug things when it doesn't work properly.
>>>
>>> Wayne
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>      
>    

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


Re: question on capabilities of AntRun plugin

Posted by Stephen Connolly <st...@gmail.com>.
If you have "invested a significant amount of time in preparing the Ant
build, and so I would prefer to find a way to leverage this work, rather
than starting from scratch with Maven" then I recommend that you do not use
Maven.  Instead use maven-ant-tasks to interact with the maven repository
and keep your build in ANT.

The reality is that if you are not prepared to drink the Maven kool-aid (it
tastes great) then stick with ANT.

The golden rule is "If a build ain't broke, don't fix it"

Now this triggers a question.... why do you want to use Maven to build your
project?

-Stephen

On 27 August 2010 17:58, Jacob Beard <jb...@cs.mcgill.ca> wrote:

> Hi Wayne,
>
> The situation is that I have invested a significant amount of time in
> preparing the Ant build, and so I would prefer to find a way to leverage
> this work, rather than starting from scratch with Maven. As my project is
> unconventional, and I'm not yet fully comfortable with Maven, I feel like,
> at this stage, continuing to use Ant for certain parts of the build is a
> better, safer approach. I believe this is what the AntRun plugin is designed
> to facilitate.
>
> If anyone could offer any guidance regarding my original question, I would
> greatly appreciate it. Thanks,
>
> Jake
>
>
> On 10-08-27 12:17 PM, Wayne Fay wrote:
>
>> /home/jacob/workspace/gsoc2010/git-scxml-js/scxml-js/test-maven.xml:19:
>>> Reference maven.compile.classpath not found.
>>>
>>> Please let me know what you think. Thanks,
>>>
>>>
>> Is this just "for fun" or are you seriously trying to build a big mess
>> of your build by continuing to use various aspects of your build in
>> Ant via Antrun and other aspects in Maven, and then sharing properties
>> around etc?
>>
>> Honestly, you should just convert your Ant "stuff" into Maven plugins.
>> It is pretty simple to write proper Maven plugins. And far easier to
>> debug things when it doesn't work properly.
>>
>> Wayne
>>
>> ---------------------------------------------------------------------
>> 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: question on capabilities of AntRun plugin

Posted by Ron Wheeler <rw...@artifact-software.com>.
  On 27/08/2010 12:58 PM, Jacob Beard wrote:
> Hi Wayne,
>
> The situation is that I have invested a significant amount of time in 
> preparing the Ant build, and so I would prefer to find a way to 
> leverage this work, rather than starting from scratch with Maven. As 
> my project is unconventional, and I'm not yet fully comfortable with 
> Maven, I feel like, at this stage, continuing to use Ant for certain 
> parts of the build is a better, safer approach. I believe this is what 
> the AntRun plugin is designed to facilitate.
>
> If anyone could offer any guidance regarding my original question, I 
> would greatly appreciate it. Thanks,
If you are not going to do it the maven way, you will find yourself in 
trouble constantly and always taking a lot longer that you envisioned.

If you can actually assert that your project is totally unlike a 
"normal" application, you probably should stick with Ant.
Maven is really good for "normal" projects. It does the "right" thing 
without any effort on the developer's part.
This means that it makes all kinds of assumptions about how the universe 
unfolds.
If your universe operates under a completely different set of rules, 
then Maven will only make you unhappy. It will do this on a regular basis.

Ron

>
> Jake
>
> On 10-08-27 12:17 PM, Wayne Fay wrote:
>>> /home/jacob/workspace/gsoc2010/git-scxml-js/scxml-js/test-maven.xml:19:
>>> Reference maven.compile.classpath not found.
>>>
>>> Please let me know what you think. Thanks,
>> Is this just "for fun" or are you seriously trying to build a big mess
>> of your build by continuing to use various aspects of your build in
>> Ant via Antrun and other aspects in Maven, and then sharing properties
>> around etc?
>>
>> Honestly, you should just convert your Ant "stuff" into Maven plugins.
>> It is pretty simple to write proper Maven plugins. And far easier to
>> debug things when it doesn't work properly.
>>
>> Wayne
>>
>> ---------------------------------------------------------------------
>> 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
>
>


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


Re: question on capabilities of AntRun plugin

Posted by Jacob Beard <jb...@cs.mcgill.ca>.
Hi Wayne,

The situation is that I have invested a significant amount of time in 
preparing the Ant build, and so I would prefer to find a way to leverage 
this work, rather than starting from scratch with Maven. As my project 
is unconventional, and I'm not yet fully comfortable with Maven, I feel 
like, at this stage, continuing to use Ant for certain parts of the 
build is a better, safer approach. I believe this is what the AntRun 
plugin is designed to facilitate.

If anyone could offer any guidance regarding my original question, I 
would greatly appreciate it. Thanks,

Jake

On 10-08-27 12:17 PM, Wayne Fay wrote:
>> /home/jacob/workspace/gsoc2010/git-scxml-js/scxml-js/test-maven.xml:19:
>> Reference maven.compile.classpath not found.
>>
>> Please let me know what you think. Thanks,
>>      
> Is this just "for fun" or are you seriously trying to build a big mess
> of your build by continuing to use various aspects of your build in
> Ant via Antrun and other aspects in Maven, and then sharing properties
> around etc?
>
> Honestly, you should just convert your Ant "stuff" into Maven plugins.
> It is pretty simple to write proper Maven plugins. And far easier to
> debug things when it doesn't work properly.
>
> Wayne
>
> ---------------------------------------------------------------------
> 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: question on capabilities of AntRun plugin

Posted by Wayne Fay <wa...@gmail.com>.
> /home/jacob/workspace/gsoc2010/git-scxml-js/scxml-js/test-maven.xml:19:
> Reference maven.compile.classpath not found.
>
> Please let me know what you think. Thanks,

Is this just "for fun" or are you seriously trying to build a big mess
of your build by continuing to use various aspects of your build in
Ant via Antrun and other aspects in Maven, and then sharing properties
around etc?

Honestly, you should just convert your Ant "stuff" into Maven plugins.
It is pretty simple to write proper Maven plugins. And far easier to
debug things when it doesn't work properly.

Wayne

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


Re: question on capabilities of AntRun plugin

Posted by Jacob Beard <jb...@cs.mcgill.ca>.
Sure thing.

Here is an excerpt from the pom.xml:

<tasks>
<ant antfile="test-maven.xml" target="test-maven-classpath"
inheritRefs="true"/>
</tasks>

Then, this works:

<project name="scxml-js" basedir="." >
<target name="test-maven-classpath">
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>

<echo message="compile classpath: ${compile_classpath}"/>
<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="test classpath: ${test_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>
</target>
</project>

But this fails:

<project name="scxml-js" basedir="." >
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>

<target name="test-maven-classpath">
<echo message="compile classpath: ${compile_classpath}"/>
<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="test classpath: ${test_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>
</target>
</project>

With the following error:

[INFO] An Ant BuildException has occured: The following error occurred
while executing this line:
/home/jacob/workspace/gsoc2010/git-scxml-js/scxml-js/test-maven.xml:19:
Reference maven.compile.classpath not found.

If I then set a property in the pom.xml, like this:


<tasks>
<property name="foo" value="bar"/>

<ant antfile="test-maven.xml" target="test-maven-classpath"
inheritRefs="true"/>
</tasks>

Then both of the following work:

<project name="scxml-js" basedir="." >

<target name="test-maven-classpath">
<property name="new-foo" value="${foo}"/>

<echo>${new-foo}</echo>
</target>
</project>

<project name="scxml-js" basedir="." >

<property name="new-foo" value="${foo}"/>

<target name="test-maven-classpath">

<echo>${new-foo}</echo>
</target>
</project>


Please let me know what you think. Thanks,

Jake

On 10-08-27 02:24 AM, Cody zhang wrote:
> Hi,Jacob
>     Can you paste your code example?
>     Best Regards,
>         --Cody.Zhang
>
>
> 2010/8/27 Jacob Beard <jb...@cs.mcgill.ca>
>
>   
>> Hi,
>>
>> I have question on the capabilities of the AntRun plugin. This example
>> shows the Maven classpaths being copied into Ant properties, which are then
>> used in Ant:
>>
>>
>> http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html
>>
>> I thougth it would be useful to reference these classpaths directly in Ant,
>> rather than using the copied properties, and so I ran a series of tests.
>> What I found was that the maven classpaths could be referenced, but only in
>> the scope of the called target. When used outside of a target (in a taskdef,
>> for example), an error is thrown. On the other hand, properties that are
>> created in the Maven tasks element can be used both in and outside of the
>> scope of the called target. This is using the ant task, with both
>> inheritsAll and inheritsRefs set to true.
>>
>> I'm wondering if I'm correct in the above assessment of the capabilities of
>> antrun. Can maven classpaths not be referenced directly, outside of the
>> scope of the called ant task? If they cannot, what is the best way in Ant to
>> read a classpath that has been read into a property back into a path
>> element?
>>
>> Let me know. Thanks,
>>
>> Jake
>>
>> ---------------------------------------------------------------------
>> 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: question on capabilities of AntRun plugin

Posted by Cody zhang <co...@infowarelab.com>.
Hi,Jacob
    Can you paste your code example?
    Best Regards,
        --Cody.Zhang


2010/8/27 Jacob Beard <jb...@cs.mcgill.ca>

> Hi,
>
> I have question on the capabilities of the AntRun plugin. This example
> shows the Maven classpaths being copied into Ant properties, which are then
> used in Ant:
>
>
> http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html
>
> I thougth it would be useful to reference these classpaths directly in Ant,
> rather than using the copied properties, and so I ran a series of tests.
> What I found was that the maven classpaths could be referenced, but only in
> the scope of the called target. When used outside of a target (in a taskdef,
> for example), an error is thrown. On the other hand, properties that are
> created in the Maven tasks element can be used both in and outside of the
> scope of the called target. This is using the ant task, with both
> inheritsAll and inheritsRefs set to true.
>
> I'm wondering if I'm correct in the above assessment of the capabilities of
> antrun. Can maven classpaths not be referenced directly, outside of the
> scope of the called ant task? If they cannot, what is the best way in Ant to
> read a classpath that has been read into a property back into a path
> element?
>
> Let me know. Thanks,
>
> Jake
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>