title: How to build maven project with ant script?
body: <p>I have legacy java project which is build on Ant. But a new module project which is build on maven is ongoing project. Problem is I want to build maven project through ant script and create one .ear file which includes legacy and as well as new project dependencies. Or vise-versa I want also find way to run ant script through pom.xml. I tried both ways but couldn't get success.</p>
  
  <p>In my build.xml I put this target. But it won't help</p>
  
  <pre><code>&lt;artifact:mvn pom="../../idp/pom.xml" mavenHome="C:\Program Files\Apache\maven"&gt;
          &lt;arg value="install"/&gt;
        &lt;/artifact:mvn&gt;
  </code></pre>
  
  <p>It shows error in build.xml that 'The prefix &quot;artifact&quot; for element &quot;artifact:mvn&quot; is not bound.'</p>
  
  <p>I also try this:</p>
  
  <pre><code>&lt;target name="compile-mvn-init" unless="compile.classpath" xmlns:artifact="urn:maven-artifact-ant"&gt;    
              &lt;typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"
                  classpath="lib/maven-ant-tasks-2.1.3.jar"/&gt; 
              &lt;condition property="maven.repo.local" value="${maven.repo.local}" else="${user.home}/.m2/repository"&gt;
                  &lt;isset property="maven.repo.local"/&gt;
              &lt;/condition&gt;           
              &lt;echo&gt;maven.repo.local=${maven.repo.local}&lt;/echo&gt;
              &lt;artifact:localRepository id="local.repository" path="${maven.repo.local}"/&gt; 
              &lt;artifact:pom file="../../idp/pom.xml" id="maven.project"/&gt;
              &lt;artifact:dependencies pathId="compile.classpath" filesetId="compile.fileset" useScope="compile"&gt;
                  &lt;pom refid="maven.project"/&gt;
                  &lt;localRepository refid="local.repository"/&gt;
              &lt;/artifact:dependencies&gt;
              &lt;artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test"&gt;
                  &lt;pom refid="maven.project"/&gt;
                  &lt;localRepository refid="local.repository"/&gt;
              &lt;/artifact:dependencies&gt;
              &lt;artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime"&gt;
                  &lt;pom refid="maven.project"/&gt;
                  &lt;localRepository refid="local.repository"/&gt;
              &lt;/artifact:dependencies&gt;
          &lt;/target&gt;
  </code></pre>
  
  <p>But it failed says that :</p>
  
  <pre><code>compile-mvn-init:
    [typedef] Could not load definitions from resource org/apache/maven/artifact/a
  nt/antlib.xml. It could not be found.
       [echo] maven.repo.local=C:\Users\singh.pankaj/.m2/repository
  BUILD FAILED
  D:\projects\ddev\SL\DEV\RL2016_03\omega\build\build.xml:702: Problem: failed to
  create task or type urn:maven-artifact-ant:localRepository
  Cause: The name is undefined.
  Action: Check the spelling.
  Action: Check that any custom tasks/types have been declared.
  Action: Check that any &lt;presetdef&gt;/&lt;macrodef&gt; declarations have taken place
  </code></pre>
  
  <p>.</p>
  
  <p>I edited this part in my build.xml to this actually problem is for path. </p>
  
  <pre><code>&lt;target name="compile-server" 
              description="Compiles Application Tier Implementation classes."&gt;
  
          &lt;javac srcdir="${SOURCE.DIR}" destdir="${BUILD.DIR}" includes="com/emergis/els/server/**/*"
                 deprecation="${compile.deprecation}" debug="${compile.debug}" fork="${compile.fork}"
                 failonerror="${compile.failonerror}" verbose="${compile.verbose}" classpathref="javac.classpath.id"/&gt;
  
      &lt;/target&gt;
  
       &lt;target name="compile-mvn-init" unless="compile.classpath" xmlns:artifact="urn:maven-artifact-ant"&gt;    
              &lt;typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"
                  classpath="${basedir}\lib\maven-ant-tasks-2.1.3.jar"/&gt; 
              &lt;condition property="maven.repo.local" value="${maven.repo.local}" else="${user.home}/.m2/repository"&gt;
                  &lt;isset property="maven.repo.local"/&gt;
              &lt;/condition&gt;           
              &lt;echo&gt;maven.repo.local=${maven.repo.local}&lt;/echo&gt;
              &lt;artifact:localRepository id="local.repository" path="${maven.repo.local}"/&gt; 
              &lt;artifact:pom file="../../idp/pom.xml" id="maven.project"/&gt;
              &lt;artifact:dependencies pathId="compile.classpath" filesetId="compile.fileset" useScope="compile"&gt;
                  &lt;pom refid="maven.project"/&gt;
                  &lt;localRepository refid="local.repository"/&gt;
              &lt;/artifact:dependencies&gt;
              &lt;artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test"&gt;
                  &lt;pom refid="maven.project"/&gt;
                  &lt;localRepository refid="local.repository"/&gt;
              &lt;/artifact:dependencies&gt;
              &lt;artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime"&gt;
                  &lt;pom refid="maven.project"/&gt;
                  &lt;localRepository refid="local.repository"/&gt;
              &lt;/artifact:dependencies&gt;
          &lt;/target&gt; 
  </code></pre>
  
  <p>Now error was gone but my pom.xml does not execute. It simply says :</p>
  
  <pre><code>compile-mvn-init:
       [echo] maven.repo.local=C:\Users\singh.pankaj/.m2/repository
  [artifact:dependencies] Downloading: com/oracle/ojdbc14/10.2.0.1.0/ojdbc14-10.2.
  0.1.0.pom from repository central at http://repo1.maven.org/maven2
  [artifact:dependencies] Unable to locate resource in repository
  [artifact:dependencies] [INFO] Unable to find resource 'com.oracle:ojdbc14:pom:1
  0.2.0.1.0' in repository central (http://repo1.maven.org/maven2)
  [artifact:dependencies] Downloading: com/oracle/weblogi/weblogic/10.3.5/weblogic
  -10.3.5.pom from repository central at http://repo1.maven.org/maven2
  [artifact:dependencies] Unable to locate resource in repository
  [artifact:dependencies] [INFO] Unable to find resource 'com.oracle.weblogi:weblo
  gic:pom:10.3.5' in repository central (http://repo1.maven.org/maven2)
  [artifact:dependencies] Downloading: com/oracle/weblogi/wlfullclient/10.3.5/wlfu
  llclient-10.3.5.pom from repository central at http://repo1.maven.org/maven2
  [artifact:dependencies] Unable to locate resource in repository
  [artifact:dependencies] [INFO] Unable to find resource 'com.oracle.weblogi:wlful
  lclient:pom:10.3.5' in repository central (http://repo1.maven.org/maven2)
  </code></pre>
  
  <p>My target folder in project idp which is based on maven is not updated.</p>