Mavenizing ANT project
What's a proper way of mavenizing an Ant project? the project has an Ant build.xml file with 3 targets.
I've found out how to configure the pom.xml to run Ant tasks, but what worries me is this: http://maven.apache.org/plugins/maven-antrun-plugin/usage.html: "the maven-antrun-plugin has only one goal, run."
Is it possible to define 3 ant tasks in my pom.xml file and decide which target to run, based on a parameter/property? should I consider using profiles?
It depends on the tasks. Presumably, your 3 ant targets are doing 3 different builds. You could accomplish that with profiles easily (that's what they're for). If you do it right, you wouldn't use the maven-antrun-plugin at all. You'd instead be using the standard maven plugins for generating the artifacts (maven-jar-plugin, maven-war-plugin, maven-ear-plugin, assembly plugin, etc) depending on what you're trying to actually generate.
Check out the "better builds with maven" pdf, it's available free online and is great for maven beginners.
You could start by looking at this SO discussion - What does it meant o Mavenize a project. Running an ant script through maven (using maven antrun plugin) is not exactly mavenizing.
Your build script has three tasks. If they are something as simple, as clean
, compile
, jar
- then maven does all these as part of its default build lifecycle. All you would need is to create a pom file and define the required dependencies.
If the ant tasks are doing more complicated things, which cannot be achieved by maven, then you could still look at using the maven antrun plugin.
Would you want to build the three tasks independently? If so, profiles is one way to go. If the tasks are dependent on each other, then you would just want to invoke that task from maven antrun plugin, which will in turn call the dependent tasks.
链接地址: http://www.djcxy.com/p/44320.html上一篇: ant任务检索Maven配置文件依赖关系
下一篇: Maven化ANT项目