HI Sumit,

The simplest thing might be to make a separate module which does nothing but 
run your script. Then it would only run when executing that module.

If you are doing this once for each build, you don’t even need the profile.

Regards,
Russ

On Dec 23, 2013, at 3:16 PM, Sumit Kumar <skbrnwl-...@yahoo.com> wrote:

> Hi,
> 
> 
> I want to create a profile  that can help me run an auto-generated script 
> onto the target m/c. Since i would want this on a build m/c to be executed 
> only once, i figured it would be better to keep this target in a separate 
> profile. Here is what the skeleton looks like in my parent component's 
> pom.xml (i chose parent component, because there are 3 or 4 sub components 
> who would need this script's output).
> 
> 
>     <profile>
>       <id>run-script</id>
>       <build>
>         <plugins>
>           <plugin>
>             <groupId>org.apache.maven.plugins</groupId>
>             <artifactId>maven-antrun-plugin</artifactId>
>             <version>${maven-antrun-plugin.version}</version>
>            
> <configuration>
>               <skipTests>false</skipTests>
>             </configuration>
>             <executions>
>               <execution>
>                 <id>run-script</id>
>                 <phase>initialize</phase>
>                 <goals>
>                  
> <goal>run</goal>
>                 </goals>
>                 <configuration>
>                   <target>
>                     <echo file="target/install-foo.sh">
> ................
>                     </echo>
>                     <exec executable="sh" dir="${basedir}"
> failonerror="true">
>                       <arg line="target/install-foo.sh" />
>                     </exec>
>                   </target>
>                 </configuration>
>               </execution>
>             </executions>
>           </plugin>
>         </plugins>
>       </build>
>    
> </profile>
> 
> My problem is that this script gets executed for each and every sub component 
> of the parent component. Is there a way to ensure that this script 
> install-foo.sh is executed only once? I was running "mvn initialize 
> -Prun-script" I tried with generate-sources phase as well and had the script 
> running for all the sub-components. Any pointers will be very helpful.
> 
> 
> Thanks,
> -Sumit

-----------------
Author, Getting Started with Apache Maven 
<http://www.packtpub.com/getting-started-with-apache-maven/video>

Come read my webnovel, Take a Lemon <http://www.takealemon.com>, 
and listen to the Misfile radio play <http://www.fuzzyfacetheater.com/misfile/>!







Reply via email to