• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Merging ant build.xml and pom.xml  RSS feed

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java application that I build with ant. I've had to convert my application to a Maven project in order to use some maven dependencies. So now my project has a pom.xml file. When I run using Eclipse everything is fine. But when I run my build xml with ant the maven dependencies are missing. I am guessing I need to somehow include the pom.xml file into the build file and that is where I need help. Is there some xml syntax that simply includes the pom.xml or to I somehow need to physically merge the two files? TIA
Here is my current build file:

Here is the pom.xml that I now need to include:
 
Sheriff
Posts: 5458
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm not an ant expert, but my inclination would be to execute mvn from ant, like
(that's windows)  Unix/Linux would be more like:
 
Knute Snortum
Sheriff
Posts: 5458
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you can execute Ant from Maven too.
 
Sam Ritter
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a bit confusing. How does your suggestion fit into the posted ant build.xml? I've never used maven before other then via my IDE.
 
Sam Ritter
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may have found what I need but being a maven noob I'm not sure what I am seeing. I am looking at this article. I don't see how pom.xml fits into this for the maven dependencies and it is not clear if maven winds up with the correctly named jar file from the embedded ant build xml.
 
Saloon Keeper
Posts: 5046
134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that you have a Maven build, why still use Ant at all?
 
Knute Snortum
Sheriff
Posts: 5458
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you've just looking for dependency management in Ant, then use Ivy.
 
Sam Ritter
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:Now that you have a Maven build, why still use Ant at all?


Mostly because I don't know what I am doing with maven. As you can see from the posted ant build script I obtain certain variables from the ant command line. Those variables are extracted from MySQL and passed to ant in a script I wrote to generate the jar. I can find nothing in maven that does the equivalent nor can I find how to put all those various tests into a maven build xml (which I assume is pom.xml). As a maven noob I am having trouble finding what I need in the docs nor can I find any examples that help me. I guess my build script is a bit complicated for a noob.
 
Tim Moores
Saloon Keeper
Posts: 5046
134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. Maven is a bit long in the tooth anyway. These days one would opt for Gradle instead.

Knute's suggestion of using Ivy is a good one - it adds dependency management to Ant, and nothing else.
 
Sam Ritter
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I been looking at converting from ant to maven but it is still pretty fuzzy to me. I'll look into Ivy. Thanks.
 
Sam Ritter
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It turns out that I don't need Ivy or even mvn. I found this article for using maven from ant. It seems to build successfully however there is a dependency that cannot be resolved. When I run the jar file I get this error:


I would have thought that the build would fail if that dependency was missing. In any case I can run it successfully from Eclipse so it can find that dependency in the library. Here is the entry in pom.xml:

Is it possible for the build to be successful and it not find that dependency at all? Can someone tell me how to debug this? TIA.
 
Knute Snortum
Sheriff
Posts: 5458
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sam Ritter wrote:It turns out that I don't need Ivy or even mvn...


"mvn" is the command you issue to start Maven.
 
Knute Snortum
Sheriff
Posts: 5458
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sam Ritter wrote:I found this article for using maven from ant.


But that article is nine years old.  Maybe there are some more modern way to accomplish what you need.
 
Sam Ritter
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not that I've been able to find so far.
 
Sam Ritter
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just realized I posted the wrong link. The one I posted refered to the link I actually used. While still 9 years old this is what I used.
 
Knute Snortum
Sheriff
Posts: 5458
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But see this:

http://maven.apache.org/ant-tasks/
 
Sam Ritter
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I saw that but best I can tell, I am not using any of those features. I am using maven-ant-tasks-2.1.3.jar which seems to be still supported.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!