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.
In my build.xml I put this target. But it won't help
<artifact:mvn pom="../../idp/pom.xml" mavenHome="C:\Program Files\Apache\maven">
<arg value="install"/>
</artifact:mvn>
It shows error in build.xml that 'The prefix "artifact" for element "artifact:mvn" is not bound.'
I also try this:
<target name="compile-mvn-init" unless="compile.classpath" xmlns:artifact="urn:maven-artifact-ant">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"
classpath="lib/maven-ant-tasks-2.1.3.jar"/>
<condition property="maven.repo.local" value="${maven.repo.local}" else="${user.home}/.m2/repository">
<isset property="maven.repo.local"/>
</condition>
<echo>maven.repo.local=${maven.repo.local}</echo>
<artifact:localRepository id="local.repository" path="${maven.repo.local}"/>
<artifact:pom file="../../idp/pom.xml" id="maven.project"/>
<artifact:dependencies pathId="compile.classpath" filesetId="compile.fileset" useScope="compile">
<pom refid="maven.project"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test">
<pom refid="maven.project"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime">
<pom refid="maven.project"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
</target>
But it failed says that :
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 <presetdef>/<macrodef> declarations have taken place
.
I edited this part in my build.xml to this actually problem is for path.
<target name="compile-server"
description="Compiles Application Tier Implementation classes.">
<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"/>
</target>
<target name="compile-mvn-init" unless="compile.classpath" xmlns:artifact="urn:maven-artifact-ant">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"
classpath="${basedir}\lib\maven-ant-tasks-2.1.3.jar"/>
<condition property="maven.repo.local" value="${maven.repo.local}" else="${user.home}/.m2/repository">
<isset property="maven.repo.local"/>
</condition>
<echo>maven.repo.local=${maven.repo.local}</echo>
<artifact:localRepository id="local.repository" path="${maven.repo.local}"/>
<artifact:pom file="../../idp/pom.xml" id="maven.project"/>
<artifact:dependencies pathId="compile.classpath" filesetId="compile.fileset" useScope="compile">
<pom refid="maven.project"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test">
<pom refid="maven.project"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime">
<pom refid="maven.project"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
</target>
Now error was gone but my pom.xml does not execute. It simply says :
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)
My target folder in project idp which is based on maven is not updated.