You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by shinjan sen <sh...@gmail.com> on 2007/06/25 09:20:10 UTC

Maven and Ant | Executing Ant script before downloading dependencies | Need Help

Hi,
I have a maven project which has a dependency on an ant project. To achieve
this I have added a execution of the maven ant-run-plugin in my pom.xml as
follows:

 <plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-antrun-plugin</artifactId>
   <executions>
    <execution>
     <phase>package</phase>
     <configuration>
     <tasks>
     <echo>Download dependent jars</echo>
     <ant antfile="build.xml" dir="." inheritAll="true" inheritRefs="true">
     </ant>
     </tasks>
     </configuration>
     <goals>
          <goal>run</goal>
              </goals>
    </execution>
   </executions>
   </plugin>

This ant script "build.xml" compiles the associated ant project and installs
the same in the maven local repository.

<project basedir="." default="buildJar" >
 <condition property="mvn.exec" value="mvn.bat" else="mvn">
   <os family="windows"/>
 </condition>
 <target name="buildJar" description="Builds ant project and copies jar to
local repository">
  <ant antfile="build.xml" dir="ant_common" target="compile" />
  <exec executable="${mvn.exec}">
   <arg line="-D mvn install:install-file -Dfile=ant_common.jar
-DgroupId=mytest -DartifactId=ant_common -Dversion=1.0 -Dpackaging=jar"/>
  </exec>
 </target>
</project>

My question is how do I add this ant project as a dependency in my pom.xml?
if I add it as
   <dependency>
      <groupId>mytest</groupId>
      <artifactId>ant_common</artifactId>
      <version>1.0</version>
    </dependency>
my pom will try to download the same before executing the
maven-antrun-plugin execution and will throw an error.

I want to achieve the effect of installing the ant project and then
referencing it as a dependency in one execution.

Please advise.

Thanks in advance.

Regards,
Shinjan

Re: Maven and Ant | Executing Ant script before downloading dependencies | Need Help

Posted by Paul Copeland <te...@jotobjects.com>.
Henry -

What maven packaging type would the ant project have in this case?

What would the ant project do in each phase of the first maven build?

How would the second maven project gain access to the products of the 
first ant build?

On 6/26/2007 6:08 PM, Henry Isidro wrote:
> Hi Shinjan,
>
> You can separate the two. Place the ant project in its own project, 
> configure the ant run plugin there. Then, in the maven project, add 
> the ant project as a dependency. If you want this in one nice build, 
> you can place both projects under one parent, this way, when you build 
> the parent, it would build the ant project first, then the maven one.
>
> HTH,
> Henry
>
> shinjan sen wrote:
>> Hi,
>> I have a maven project which has a dependency on an ant project. To 
>> achieve
>> this I have added a execution of the maven ant-run-plugin in my 
>> pom.xml as
>> follows:
>>
>> <plugin>
>>   <groupId>org.apache.maven.plugins</groupId>
>>   <artifactId>maven-antrun-plugin</artifactId>
>>   <executions>
>>    <execution>
>>     <phase>package</phase>
>>     <configuration>
>>     <tasks>
>>     <echo>Download dependent jars</echo>
>>     <ant antfile="build.xml" dir="." inheritAll="true" 
>> inheritRefs="true">
>>     </ant>
>>     </tasks>
>>     </configuration>
>>     <goals>
>>          <goal>run</goal>
>>              </goals>
>>    </execution>
>>   </executions>
>>   </plugin>
>>
>> This ant script "build.xml" compiles the associated ant project and 
>> installs
>> the same in the maven local repository.
>>
>> <project basedir="." default="buildJar" >
>> <condition property="mvn.exec" value="mvn.bat" else="mvn">
>>   <os family="windows"/>
>> </condition>
>> <target name="buildJar" description="Builds ant project and copies 
>> jar to
>> local repository">
>>  <ant antfile="build.xml" dir="ant_common" target="compile" />
>>  <exec executable="${mvn.exec}">
>>   <arg line="-D mvn install:install-file -Dfile=ant_common.jar
>> -DgroupId=mytest -DartifactId=ant_common -Dversion=1.0 
>> -Dpackaging=jar"/>
>>  </exec>
>> </target>
>> </project>
>>
>> My question is how do I add this ant project as a dependency in my 
>> pom.xml?
>> if I add it as
>>   <dependency>
>>      <groupId>mytest</groupId>
>>      <artifactId>ant_common</artifactId>
>>      <version>1.0</version>
>>    </dependency>
>> my pom will try to download the same before executing the
>> maven-antrun-plugin execution and will throw an error.
>>
>> I want to achieve the effect of installing the ant project and then
>> referencing it as a dependency in one execution.
>>
>> Please advise.
>>
>> Thanks in advance.
>>
>> Regards,
>> Shinjan
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven and Ant | Executing Ant script before downloading dependencies | Need Help

Posted by Henry Isidro <hi...@exist.com>.
Hi Shinjan,

You can separate the two. Place the ant project in its own project, 
configure the ant run plugin there. Then, in the maven project, add the 
ant project as a dependency. If you want this in one nice build, you can 
place both projects under one parent, this way, when you build the 
parent, it would build the ant project first, then the maven one.

HTH,
Henry

shinjan sen wrote:
> Hi,
> I have a maven project which has a dependency on an ant project. To achieve
> this I have added a execution of the maven ant-run-plugin in my pom.xml as
> follows:
> 
> <plugin>
>   <groupId>org.apache.maven.plugins</groupId>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>    <execution>
>     <phase>package</phase>
>     <configuration>
>     <tasks>
>     <echo>Download dependent jars</echo>
>     <ant antfile="build.xml" dir="." inheritAll="true" inheritRefs="true">
>     </ant>
>     </tasks>
>     </configuration>
>     <goals>
>          <goal>run</goal>
>              </goals>
>    </execution>
>   </executions>
>   </plugin>
> 
> This ant script "build.xml" compiles the associated ant project and 
> installs
> the same in the maven local repository.
> 
> <project basedir="." default="buildJar" >
> <condition property="mvn.exec" value="mvn.bat" else="mvn">
>   <os family="windows"/>
> </condition>
> <target name="buildJar" description="Builds ant project and copies jar to
> local repository">
>  <ant antfile="build.xml" dir="ant_common" target="compile" />
>  <exec executable="${mvn.exec}">
>   <arg line="-D mvn install:install-file -Dfile=ant_common.jar
> -DgroupId=mytest -DartifactId=ant_common -Dversion=1.0 -Dpackaging=jar"/>
>  </exec>
> </target>
> </project>
> 
> My question is how do I add this ant project as a dependency in my pom.xml?
> if I add it as
>   <dependency>
>      <groupId>mytest</groupId>
>      <artifactId>ant_common</artifactId>
>      <version>1.0</version>
>    </dependency>
> my pom will try to download the same before executing the
> maven-antrun-plugin execution and will throw an error.
> 
> I want to achieve the effect of installing the ant project and then
> referencing it as a dependency in one execution.
> 
> Please advise.
> 
> Thanks in advance.
> 
> Regards,
> Shinjan
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org