Hi,

Maven includes the pom.xml by default under META-INF/maven/${grouId}/${artifactId}/pom.xml in the generated artifact. So if you just need the file during runtime it is already there :-)

-Tim

G.B. schrieb:
Hi,
I want to do something very simple : copy my pom file to a
known location (in the classpath), and I want that to be done
in all my project/subprojects.

I have main project A with sub component B and C
A contains the super pom B and C pom are inherited from A.
First thing I did is create the following
<build>
<plugins>
…
<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                        <execution>
                                <id>pomAntCopy</id>
                                <goals>
                                        <goal>run</goal>
                                </goals>
                                <phase>process-resources</phase>
                                <configuration>
                                        <tasks>
                                                <copy file="${basedir}/pom.xml"
todir="${project.build.outputDirectory}/myLocation/${groupId}/${artifactId}"
overwrite="true"/>
                                        </tasks>
                                </configuration>          
                        </execution>
                </executions>
        </plugin>

If I  do mvn process-resources I only get that result in
A/target/… B and C are just ignoring it
After a lot of tries I did
<plugin>
        <inherited>true</inherited>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                        <inherited>true</inherited>
                        <execution>
                                <inherited>true</inherited>
                                <id>pomAntCopy</id>
                                <goals>
                                        <inherited>true</inherited>
                                        <goal>run</goal>
                                </goals>
                                <phase>process-resources</phase>
                                <configuration>
                                        <inherited>true</inherited>
                                        <tasks>
                                                <copy file="${basedir}/pom.xml"
todir="${project.build.outputDirectory}/META-INF/maven/${groupId}/${artifactId}-ant"
overwrite="true"/>                 </tasks>
                                </configuration>
                        </execution>
                </executions>
        </plugin>

I know I added too much inherited but I wanted to make sur
maven would understand I want inheritance :o) … it did not work

I tried to do a stupid plugin:

/**
 * @goal copy
 * @description Copy Pom into location in classpath to be use
by life cycle tool durring
 *              developpment process
 * @execute phase="process-resources"
 */
public class DevelopmentPomReplicator extends AbstractMojo {

  /**
   * The project to process.
* * @parameter expression="${project}"
   * @required
   * @readonly
   */
  private MavenProject mavenProject;

  /**
   * The project base dir.
* * @parameter expression="${basedir}"
   * @required
   * @readonly
   */
  private String pomDir;

  /**
   * @parameter expression="${project.build.directory}"
   * @required
   */
  private String outDir;

public void execute() throws MojoExecutionException,
MojoFailureException {
    final int BUFFER = 2048;
    if("jar".equalsIgnoreCase(mavenProject.getPackaging())){
      try{
        String outputSubPath ="/mylocation/" +
mavenProject.getGroupId() + "/" + mavenProject.getArtifactId();
        File pomIn = new File(pomDir + "/pom.xml");
        BufferedInputStream l_bis = new BufferedInputStream(
new FileInputStream(pomIn));
        File pomOut = new File(outDir + outputSubPath +
"/pom.xml");
        pomOut.getParentFile().mkdirs();
        BufferedOutputStream l_bos = new BufferedOutputStream(
new FileOutputStream(pomOut));
        byte data[] = new byte[BUFFER];
        int count;
        while ((count = l_bis.read(data, 0, BUFFER)) != -1) {
          l_bos.write(data, 0, count);
        }
        l_bos.flush();
        l_bos.close();
      } catch(Exception e){
        throw new MojoExecutionException("copy", e);
      }
}

  }}

in A pom I added
<plugin>
<inherited>true</inherited>
        <groupId>test.build.inheritance</groupId>
        <artifactId>DevelopmentPomReplicator</artifactId>
        <configuration>
                <outDir>${project.build.directory}/toto</outDir>
        </configuration>
                <executions>
                        <inherited>true</inherited>
                                <execution>
                                        <inherited>true</inherited>
                                        <id>pomReplicatorCopy</id>
                                        <phase>process-resources</phase>
                                        <goals>
                                                <goal>copy</goal>
                                        </goals>
                                </execution>
                        </executions>
                </plugin>

did not work … only A execute it … more over I have the
following message :

[INFO] Preparing DevelopmentPomReplicator:copy

[WARNING] Removing: copy from forked lifecycle, to prevent
recursive invocation.

Arg no please no … it’s exactly what I want! Recursive invocation.
How can I enable it ?
How should I proceed ?

Please help.
Thanks in advance
Guillaume

Accédez au courrier électronique de La Poste : www.laposte.net ; 3615 LAPOSTENET (0,34 €/mn) ; tél : 08 92 68 13 50 (0,34€/mn)




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to