If Frege had a POM and was uploaded to maven central or bintray, I could easily use it as a maven dependency in maven, gradle, buildr, and via grapes.
I couldn't find it, though. Is there any such thing?
I would not require a full maven plugin.
There is a Maven plugin for Frege here: https://github.com/talios/frege-maven-plugin but I am not sure how much it is up to date with current Frege version.
Further as far as I know, the Frege jar is still not in any central repository so you would need to have it in some local repository to use that plugin. For example, https://github.com/talios/frege-testing/blob/master/pom.xml
You can also invoke the Frege compiler through Ant in Maven (not the best way but still an option):
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<property name="compile_classpath" refid="maven.compile.classpath" />
<property name="outputDir"
value="${project.build.outputDirectory}" />
<property name="sourceDir" value="src/main/frege" />
<property name="fregec" value="${frege:frege:jar}" />
<exec executable="java" failonerror="true">
<arg value="-Xss1m" />
<arg value="-Dfrege.javac=javac" />
<arg value="-classpath" />
<arg value="${compile_classpath}" />
<arg value="frege.compiler.Main" />
<arg value="-d" />
<arg path="${outputDir}" />
<arg value="${sourceDir}/helloworld/Foo.fr" />
<arg value="${sourceDir}/helloworld/bar.fr" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Here also frege:frege:jar refers to the Frege jar in local repository. If you have any Java dependency from your Frege code or other way around, it is better to have those as separate modules (a Java module and a Frege module) so that the compilation order (Java and Frege compilation) is determined by the order the modules are built.
Related
This part of the pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<tasks>
<property name="generated.target" value="${basedir}/target/generated" />
<property name="generated.src.test" value="${generated.target}/src/main/java" />
<property name="generated.resources.test" value="${generated.target}/src/main/resources" />
<property name="generated.wsdl.test" value="${generated.resources.test}/" />
<property name="test.resources.dir" location="${basedir}/src/main/resources" />
<mkdir dir="${generated.resources.test}/wsdl/type_test" />
<xslt classpath="C://saxonhe9-3-0-5j/saxon9he.jar" style="${test.resources.dir}/wsdl/type_test/type_test_ID_xsd.xsl" in="${test.resources.dir}/wsdl/type_test/type_test.xsd" out="${generated.resources.test}/wsdl/type_test/type_test_1.xsd">
<param name="groupID" expression="1" />
</xslt>
...
This is the error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:
run (validate) on project cxf-testutils: An Ant BuildException has occured: java
.lang.NoClassDefFoundError: org/apache/xml/serializer/ExtendedContentHandler: or
g.apache.xml.serializer.ExtendedContentHandler -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-antrun-plugin:1.6:run (validate) on project cxf-te
stutils: An Ant BuildException has occured: java.lang.NoClassDefFoundError: org/
apache/xml/serializer/ExtendedContentHandler
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
I tried add classpath="C://saxonhe9-3-0-5j/saxon9he.jar" in the xslt tag.
But it still throws this exception. I tried Maven 2.2.0 and Maven 3.0.3.JDK 1.6.0 All failed.This pom is actually from apache cxf source code. Anyone can fix it?
UPDATE
I tried many workaround. But this one finally works.
Don't change anything in the xslt tag. Just put your xalan jar files into %JAVA-HOME%\jre\lib\endorsed. I download xalan-j_2_7_0. And run cmd
java org.apache.xalan.xslt.EnvironmentCheck to ensure it can find it. It finally works. Huh! It costs me hours to resolve it.
Use the XML Maven Plugin. This supports Saxon virtually out of the box.
Just ran into this issue,and this is what I did to resolve it.
Add dependency for saxon:
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.4</version>
</dependency>
Add the classpath for saxon:
<xslt in="in.xml" out="out.html" style="style.xsl">
<classpath location="${net.sf.saxon:Saxon-HE:jar}" />
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
In my Maven build, I use the antrun plugin to invoke an ant task.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true" failonerror="true">
<classpath>
<pathelement path="${plugin_classpath}" />
</classpath>
</java>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- DEPENDENCIES FROM PROJECT DUPLICATED HERE -->
</dependencies>
</plugin>
I need to duplicate all the project dependencies in the section indicated, so that they are available to the ant task. Is there a way to avoid this duplication, by referring to the project's dependencies instead of copy-pasting them?
Here's how you can do it:
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<property name="compile_classpath" refid="maven.compile.classpath" />
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true" failonerror="true">
<classpath>
<pathelement path="${plugin_classpath}" />
<pathelement path="${compile_classpath}" />
</classpath>
</java>
Reference:
Maven Antrun Plugin > Referencing the Maven Classpaths
We are in the middle of a large Java EE project/programme. Up to this point, we've been using Eclipse and Maven for our development. The appserver we are targeting is WebLogic (Oracle, these days).
It has been decided we are going to start using Oracle Business Rules (Part of Oracle SOA Suite 11g). Development for Soa Suite is confined to JDeveloper. It has some nice ant scripts to build and deploy SOA Composites (which is how rules are packaged and deployed).
I have been tasked with getting these ant scripts to run from maven using antrun, and I've gotten some of the way, but not all...
My main question is: has anyone succeeded doing this? (Has anyone even attempted..? Can't really find anything googling...)
Below is the relevant part of my pom:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<property name="oracle.home" value="C:\Oracle\Middleware\jdeveloper"/>
<property name="oracle.soa.mgmt.home" value="C:\Oracle\Middleware\jdeveloper"/>
<property name="common.components.home" value="C:\Oracle\Middleware\oracle_common"/>
<property name="env.JAVA_HOME" value="${java.home}"/>
<property name="env.PWD" value="."/>
<ant antfile="${oracle.home}\bin\ant-sca-compile.xml"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Maven is run from the project dir, outside the Oracle/Middleware tree. This almost works...
Actually, it gives the following result:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building BilagorReglerSCA
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
main:
scac:
Validating composite "C:\JDeveloper\mywork\BilagorReglerSCA\BilagorRegler\composite.xml"
[scac] oracle.fabric.common.wsdl.XSDException: Error loading schema from file:/C:/JDeveloper/mywork/BilagorReglerSCA/BilagorRegler/BilagorRegler_DecisionService.wsdl [Cause=Error in getting XML input stream: oramds:/soa/shared/rules/BpelProcess.xsd: oracle.mds.exception.MDSException: MDS-00054: Filen som ska laddas oramds:/soa/shared/rules/BpelProcess.xsd finns inte.]
[scac] at oracle.fabric.common.wsdl.SchemaBuilder.loadEmbeddedSchemas(SchemaBuilder.java:496)
[scac] at oracle.fabric.common.wsdl.SchemaBuilder.loadSchemasFromWSDL(SchemaBuilder.java:365)
...
The phrase "Filen som ska laddas oramds:/soa/shared/rules/BpelProcess.xsd finns inte." means the "file you are trying to load does not exist" (why does my client insist on installing Swedish language version of Windows, rather than international?).
ant-sca-compile.xml contains numerous import statements similar to this:
<fileset dir="${common.components.home}/modules">
...
<include name="oracle.mds_11.1.1/oramds.jar"/>
I assume oramds.jar is needed to process oramds-URL:s, which are used in the WSDS/XSD:s JDeveloper generates.
Any help appreciated...
OK, so I eventually got a chance to sit down with an ace Oracle consultant and get this to work.
This is what we came up with:
<properties>
<oracle.fmw.soa.home>C:/Oracle/Middleware</oracle.fmw.soa.home>
<!-- this is relative reference to JDK / Jrockit from ant-sca-compile|*.xml. For jdev it is ../../, for Soa Suite: TBD. -->
<env.JAVA_HOME>../../jdk160_24</env.JAVA_HOME>
<!-- For real server with Soa Suite installed use: Oracle_SOA1, for devenv use jdeveloper -->
<oracle.fmw.productName>jdeveloper</oracle.fmw.productName>
<antOutputDir>deploy</antOutputDir>
<mvnOutputDir>target</mvnOutputDir>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sca-compile</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="scac.input" value="${basedir}/composite.xml" />
<property name="scac.application.home" value="${basedir}/.." />
<property name="oracle.home" value="${oracle.fmw.soa.home}/${oracle.fmw.productName}" />
<ant
antfile="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/ant-sca-compile.xml"
dir="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/"
target="scac" />
</target>
</configuration>
</execution>
<execution>
<id>sca-package</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="package">
<property name="build.compiler" value="extJavac" />
<property name="compositeName" value="${project.artifactId}" />
<property name="compositeDir" value="${basedir}" />
<property name="revision" value="${project.version}" />
<property name="scac.application.home" value="${basedir}/.." />
<property name="oracle.home" value="${oracle.fmw.soa.home}/${oracle.fmw.productName}" />
<property name="antOutputFile" value="sca_${project.artifactId}_rev${project.version}.jar" />
<property name="mvnOutputFile" value="${project.artifactId}-${project.version}.jar" />
<ant
antfile="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/ant-sca-package.xml"
dir="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin"
target="package" />
<copy tofile="${mvnOutputDir}/${mvnOutputFile}" file="${antOutputDir}/${antOutputFile}" />
</target>
</configuration>
</execution>
<execution>
<id>sca-deploy</id>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="deploy">
<property name="serverURL" value="${weblogic.serverURL}" />
<property name="user" value="${weblogic.user}" />
<property name="password" value="${weblogic.password}" />
<property name="sarLocation" value="${basedir}/deploy/sca_${project.artifactId}_rev${project.version}.jar" />
<property name="overwrite" value="true" />
<property name="forceDefault" value="true" />
<property name="partition" value="default" />
<property name="oracle.home" value="${oracle.fmw.soa.home}/${oracle.fmw.productName}" />
<ant
antfile="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/ant-sca-deploy.xml"
dir="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin"
target="deploy" />
</target>
</configuration>
</execution>
<execution>
<id>sca-test</id>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="jndi.properties.input" value="${basedir}/sca-test.jndi.properties" />
<property name="scatest.input" value="scatestinput" />
<property name="scatest.format" value="junit" />
<property name="scatest.result" value="reports" />
<property name="oracle.home" value="${oracle.fmw.soa.home}/${oracle.fmw.productName}" />
<ant
antfile="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/ant-sca-test.xml"
dir="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin"
target="test" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Note, both different sets of properties and parameters to the ant-tag than what I was originally attempting with.
To run on a CI-server, you obviously need a local install of JDeveloper or SOA Suite. weblogic.serverURL, weblogic.user and weblogic.password needs to be set to your corresponding environment (I use profiles for local/dev/tst/etc...).
Other than that, it works like a charm...
I've not used Maven + Oracle SOA build scripts but generally when using any of the Oracle deployment tools (ADF, SOA, etc) you will need to have either an Oracle SOA Home or a JDev home (with the SCA extension) on the same machine that the build is running on. You'll need to set the Ant environment variables correctly e.g. oracle.home and common.components.home etc
Use ant-sca-package.xml (not ant-sca-compile.xml):
<ant antfile="ant-sca-package.xml" dir="${env.BEA_HOME}/jdeveloper/bin">
<property name="compositeDir" value="#{compositeDir}" />
<property name="compositeName" value="#{compositeName}" />
<property name="revision" value="${deploy.revision}" />
</ant>
I need to execute some ant commands depending on an environment variable passed in as a parameter to the maven build command.
At the moment I have 3 tasks blocks and only the tasks block with no condition is being executed.
<tasks name="isProdCheck">
<condition property="isProd">
<equals arg1="${environment}" arg2="PROD" />
</condition>
</tasks>
<tasks if="isProd" depends="isProdCheck">
...
</tasks>
<tasks>
... I am the only block executed
</tasks>
What am I doing wrong, is there a better way to do this?
First, according to Maven 1.x website, the current stable release for maven 1.x is version 1.1, not 1.4. Second, there is no AntRun Plugin version 1.7 and, to my knowledge, this is a Maven 2 plugin. Third, the syntax you are using seems very similar to Using Attributes which, again, is about Maven 2.
So, I may be missing something but, this is very confusing and you should maybe clarify these points in your question.
Anyway, as you explicitly mentioned Maven 1, I'll try to answer. If I remember well, I would write a custom goal and use Jelly's core:if or core:when. To do so, provide something like this in maven.xml:
<project xmlns:j="jelly:core" xmlns:ant="jelly:ant">
<goal name="my-goal">
<j:if test="${environment == 'PROD'}">
<ant:xxx .../>
</j:if>
</goal>
</project>
I'm really not sure of the syntax, all this Maven 1 stuff is just too far away, and I didn't test it (I'm too lazy to install Maven 1). But I guess you will. The scripting reference may help you.
To be honest, I really hope you have a good reason to prefer Maven 1.x over Maven 2.x :)
UPDATE: It appears that the OP is actually using Maven 2 so I'll update my question accordingly. To implement the desired behavior, you could use Ant-contrib's if task as shown below:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is bar" />
</then>
<else>
<echo message="The value of property foo is not bar" />
</else>
</if>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>20020829</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
And then call mvn compile -Dfoo=bar (this is just an example).
But, all this is not the "maven way" to do things. Now that I understand a bit better what you are trying to do (but not entirely as you didn't explain your ultimate goal), I think that using build profiles would be more appropriate and, having read your own answer, I think that you are over complicating things (and that you are on the wrong path).
I understand that you are a Maven beginner but I'd suggest to try to use it though instead of falling back on Ant or you won't get the benefits of it. Also, when opening a question, instead of asking for a specific solution, you should rather explain your general problem, you'll get better answers. Here, I can't provide more guidance as I don't know what you are really trying to achieve.
You don't need to use AntContrib after maven-antrun-plugin 1.5 that uses <target> instead of <tasks> according to plugin usage. This tag works in the same way as , but in this one you can add conditions like the example below.
<properties>
<execute.my.target>true</execute.my.target>
</properties>
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>config</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<!-- this target will be executed always -->
<target>
<echo message="Hello there, I'm a simple target" />
</target>
<!--
This target will be executed if and only if
the property is set to true
-->
<target name="my-target" if="execute.my.target">
<echo message="Conditional target..." />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
The code above always executes the first target, but the second target depends on a property value. You can configure it for a parent and a sub-module project too, defining the plugin on <pluginsManagement> tag and calling some properties at the sub-modules, then calling the plugin.
Update:
Be sure to use the if parameter without ${}, since it can cause troubles mentioned in the comments section.
Resolved this issue by creating multiple named targets with "if" attributes and a condition property in a build.xml file in the project root as follows.
<target name="prod" if="isProd" depends="isProdCheck">
// do something
</target>
Passed properties of the command line switches I required, and called the ant targets in the build.xml file from the tasks section in the Maven POM as follows:
<tasks>
<ant antfile="${basedir}/build.xml">
<property name="environment" value="${environment}"/>
<target name="prod"/>
</ant>
</tasks>
runable example here https://www.surasint.com/run-ant-with-if-from-maven/
Another solution would be: keep the ant-contrib-1.0b3.jar to a path and then define it like this
<property name="runningLocation" location="" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${runningLocation}/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>
then
<target name="doSomething">
<if>
<equals arg1="${someProp}" arg2="YES" />
<then>
<echo message="It is YES" />
</then>
<else>
<echo message="It is not YES" />
</else>
</if>
</target>
I put full code example here which you can download https://www.surasint.com/2017/04/09/run-ant-with-if-from-maven/
Are there ant plugins that wrap maven so that I can make use of its dependency management features to download jars for me and place them in my ant build's lib folder?
My specific problem is that I'm using the Crap4j plugin for Hudson, but it doesn't, as of yet, support Maven. Since it's a small project, maven is overkill, but I don't want to go without mvn dependency:copy-dependcies if I don't have to.
Any suggestions? (other than suck it up)
There is a new set of Ant tasks that use Mercury. Mercury is the refactored code that will be the basis of way that Maven 3 interacts with Maven (and OSGi) repositories that is being implemented by Oleg Gusakov. Mercury is well tested, and you can start using it in Ant projects today. Take a look at some of the How-to documents that Oleg has written:
http://people.apache.org/~ogusakov/sites/mercury-ant/mercury-ant-tasks/howto.html
Here's a simple example of using Mercury in an Ant build.xml file. The following build file creates a classpath that depends on verion 3.0 of the asm artifact:
<javac srcdir="src/main/java"
destdir="target/classes">
<classpath>
<deps>
<dependency name="asm:asm:3.0"/>
</deps>
</classpath>
</javac>
There are a lot of advanced features such as support for verifying PGP signatures or MD5 digests. You can also start to define different repositories that Mercury depends on. This XML allows you to define a reference to a repository such as Nexus in addition to using a local directory as a repository:
<repo id="myCentral"
url="http://localhost:8081/nexus/contengs/groups/public"/>
<repository dir="/my/local/repo"/>
<javac srcdir="src/main/java"
destdir="target/classes">
<classpath>
<deps>
<dependency name="asm:asm:3.0"/>
</deps>
</classpath>
</javac>
If you need to reference a repository that requires authentication Mercury has support for storing a username and password:
<repo id="myCentral"
url="http://localhost:8081/nexus/contengs/groups/public">
<auth name="foo" pass="bar"/>
</repo>
<javac srcdir="src/main/java"
destdir="target/classes">
<classpath>
<deps>
<dependency name="asm:asm:3.0"/>
</deps>
</classpath>
</javac>
Most compelling is the ability to publish an artifact to a repository from an Ant build file. If you work in an organization of any scale, you'll want to start thinking about deploying artifacts to a repository manager like Nexus. With Mercury, you can start deploying artifacts to a repository manager without having to adopt Maven. Here's a build file that defines an authenticated repository and writes an artifact:
<repo id="myCentral"
url="http://localhost:8081/nexus/contengs/groups/public">
<auth name="foo" pass="bar"/>
</repo>
<write repoid="myCentral"
name="t:t:1.0"
file="${basedir}/target/t.jar"/>
Mercury is ready to use, and you can expect a lot of developments from Oleg going forward. If you want to start using it, the best place to look is at Oleg's How-to Page. (Note: This information will soon be integrated into the Definitive Guide)
Whilst the mercury tasks work, I haven't used them. I have had good success with their predecessors, the maven-ant-tasks. They're fairly simple to get going, if you already have a POM handy.
<project name="blah" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<!-- If you drop the maven-ant-tasks in ~/.ant/lib, you don't need these two bits. -->
<taskdef uri="antlib:org.apache.maven.artifact.ant"
resource="org/apache/maven/artifact/ant/antlib.xml"
classpathref="ant.classpath" />
<path id="ant.classpath">
<fileset dir="${ant.tasks.dir}">
<include name="*.jar" />
</fileset>
</path>
<target name="resolve" description="--> retrieve dependencies with maven">
<!-- Resolve dependencies -->
<artifact:dependencies filesetId="dependency.fileset">
<pom file="pom.xml" />
</artifact:dependencies>
<!-- Copy all dependencies to the correct location. -->
<copy todir="${web.dir}/WEB-INF/lib">
<fileset refid="dependency.fileset" />
<!-- This mapper strips off all leading directory information -->
<mapper type="flatten" />
</copy>
</target>
</project>
I like to keep my ant task jars inside the project, so I've added the taskdef and path. But if you want to put maven-ant-tasks-2.0.9.jar in ~/.ant/lib, then you don't need to declare this stuff. I think.
If you think that Maven is overkill in your project, you could/should try Apache Ivy: It's a very powerful dependency management library similar to the Maven one.
If you're hosting a project on the web, take also a look at Ivy Roundup, it's a repository of Ivy definitions for various libraries.
Just use the Maven Ant Tasks. They can be downloaded at the normal maven download page.
Refer this: Why you should use the Maven Ant Tasks instead of Maven or Ivy
I wouldn't really recommend Ivy for reasons given in the link above.
It is very simple to run Maven goal from Ant
<target name="buildProject" description="Builds the individual project">
<exec dir="${source.dir}\${projectName}" executable="cmd">
<arg value="/c"/>
<arg value="${env.MAVEN_HOME}\bin\mvn.bat"/>
<arg line="clean install" />
</exec>
</target>
Using this you are allow to run any kind of Maven goal from Ant...
Enjoy....
In my case i just want an ejb jar to be at the repository so i could use it on another project with maven as dependency so:
<target name="runMaven" depends="deploy" description="LLama al maven.">
<exec executable="cmd">
<arg value="/c"/>
<arg value="mvn.bat install:install-file -DgroupId=com.advance.fisa.prototipo.camel -DartifactId=batch-process -Dversion=1.0 -Dpackaging=jar -Dfile=${jarDirectory}\batch-process.jar"/>
</exec>
</target>
Download Maven Ant Tasks then use this:
<target name="getDependencies">
<path id="maven-ant-tasks.classpath" path="${basedir}${file.separator}maven${file.separator}lib${file.separator}maven-ant-tasks.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />
<artifact:dependencies filesetId="dependency.fileset" type="jar">
<pom file="pom.xml" />
</artifact:dependencies>
<!--TODO take care of existing duplicates in the case of changed/upgraded dependencies-->
<copy todir="lib">
<fileset refid="dependency.fileset" />
<mapper type="flatten" from="${dependency.versions}" />
</copy>
</target>
I am working on the same problem right now. I installed all necessary libs in my local Maven repo and from there I put it into our Company Maven Repo.
It is not working quite right yet. Some of the tests fail that work nicely in my Maven test run, but since the outcome of the test is not important for the coverage data, I am quite satisfied.
Here is my Maven snippet. I hope that helps.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<inherited>false</inherited>
<executions>
<execution>
<phase>site</phase>
<configuration>
<tasks>
<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"/>
<property name="CRAP4J_HOME" value="${user.home}/Projects/crap4j"/>
<taskdef name="crap4j" classname="org.crap4j.anttask.Crap4jAntTask">
<classpath>
<fileset dir="${CRAP4J_HOME}/lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</taskdef>
<crap4j projectdir="${project.basedir}/alm-jar-server"
outputDir="${project.basedir}/crap4jReports"
dontTest="false"
debug="true">
<classes>
<pathElement location="${project.basedir}/target/classes"/>
</classes>
<srces>
<pathElement location="${project.basedir}/src/main/java"/>
</srces>
<testClasses>
<pathElement location="${project.basedir}/target/test-classes"/>
</testClasses>
<libClasspath>
<fileset dir="${user.home}/.m2/repository">
<include name="**/*.jar"/>
</fileset>
</libClasspath>
</crap4j>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.crap4j</groupId>
<artifactId>crap4j</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>args4j</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.agitar</groupId>
<artifactId>asmlib</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.agitar</groupId>
<artifactId>coverage</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>