4

I want to write a maven plugin (extension) which implements lifecycles for javascript projects so projects with a pom.xml like this can be compiled:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org
  <modelVersion>4.0.0</modelVersion>

  <groupId>de.ailis.maven.javascript</groupId>
  <artifactId>demo</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <name>Maven JavaScript Demo Project</name>
  <packaging>javascript</packaging>

  <build>
    <plugins>
      <plugin>
        <groupId>de.ailis.maven.plugins</groupId>
        <artifactId>maven-javascript-plugin</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>

</project>

I already successfully created a plugin with a components.xmlfile which defines the lifecycles so I can call my own Mojos during the various phases. But there are some phases for which the default mojos are adequate as long as I can change some default values. For example I want to specify a custom outputDirectory to the Maven Resources Plugin so JavaScript resources are copied to target/classes/script-resources instead of target/classes. Can this be done in the plugin without copying the whole ResourcesMojo class and changing the default value of the property there?

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
kayahr
  • 20,913
  • 29
  • 99
  • 147

1 Answers1

-1

Mojo:

public class MyMojo extends AbstractMojo
{
    private String foo; //filePath

    public void execute()
        throws MojoExecutionException
    {         
        ...
        writeFile(foo)
        ...
    }
}

pom.xml

<plugin>

    <groupId>de.ailis.maven.plugins</groupId>

    <artifactId>maven-javascript-plugin</artifactId>

    <version>1.0.0-SNAPSHOT</version>

    <configuration>

        <foo>script-resources</foo> 

    </configuration>

</plugin>   
Montells
  • 6,389
  • 4
  • 48
  • 53
  • 2
    This just explains how I can pass configuration variables to a custom Mojo. That doesn't solve the problem. – kayahr Aug 25 '11 at 15:01