You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by James Mitchell <jm...@apache.org> on 2006/05/02 17:18:48 UTC

[m2] Generated test sources not being compiled

Hi, I am creating a new plugin that generates test sources.  This is  
my first Maven plugin ever, so I'm sure I'm doing something wrong.

Following the way the antlr plugin is structured, my plugin @goal and  
@phase match the below config and my plugin correctly generates the  
test source in the correct place (as configured by my test project --  
see below).

The problem is that Maven doesn't actually compile the generated  
tests.  Perhaps I'm not understanding the way phases/binding works in  
M2.  I've gone through most of the documentation, and most of the  
BetterBuildsWithMaven.pdf

Any help?


...
...
/**
  * @parameter expression="${project}"
  * @required
  */
private MavenProject project;

public void execute()
  throws MojoExecutionException, MojoFailureException
  {

  ...
  ...
  // blah, blah, generate sources
  ...
  ...
  project.addTestCompileSourceRoot( genSrcOutputDirectory );

}


My test project that uses my plugin...

...
   (junit dependency)
...
...

<build>
  <testSourceDirectory>${project.build.directory}/generated-tests/my- 
plugin</testSourceDirectory>

  <plugins>
   <plugin>
    <groupId>my.group.id</groupId>
    <artifactId>maven-gentests-plugin</artifactId>
    <executions>
      <execution>
       <id>generate-tests</id>
       <phase>generate-test-sources</phase>
       <configuration>
        <scriptSourceDirectory>src/main/scripts/</scriptSourceDirectory>
        <genSrcOutputDirectory>${project.build.directory}/generated- 
tests/my-plugin</genSrcOutputDirectory>
       </configuration>
       <goals>
         <goal>generateTests</goal>
       </goals>
    </execution>
    </executions>
   </plugin>
   </plugins>

</build>


--
James Mitchell





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


Re: [m2] Generated test sources not being compiled -- Solved

Posted by James Mitchell <jm...@apache.org>.
Just to update this, I found the problem.  It was just as I suspected  
-- I am a moron :)

I had copied someone else's existing (integration test) pom and  
didn't realize the packaging was 'pom'.

Thanks anyway.

--
James Mitchell




On May 2, 2006, at 11:18 AM, James Mitchell wrote:

> Hi, I am creating a new plugin that generates test sources.  This  
> is my first Maven plugin ever, so I'm sure I'm doing something wrong.
>
> Following the way the antlr plugin is structured, my plugin @goal  
> and @phase match the below config and my plugin correctly generates  
> the test source in the correct place (as configured by my test  
> project -- see below).
>
> The problem is that Maven doesn't actually compile the generated  
> tests.  Perhaps I'm not understanding the way phases/binding works  
> in M2.  I've gone through most of the documentation, and most of  
> the BetterBuildsWithMaven.pdf
>
> Any help?
>
>
> ...
> ...
> /**
>  * @parameter expression="${project}"
>  * @required
>  */
> private MavenProject project;
>
> public void execute()
>  throws MojoExecutionException, MojoFailureException
>  {
>
>  ...
>  ...
>  // blah, blah, generate sources
>  ...
>  ...
>  project.addTestCompileSourceRoot( genSrcOutputDirectory );
>
> }
>
>
> My test project that uses my plugin...
>
> ...
>   (junit dependency)
> ...
> ...
>
> <build>
>  <testSourceDirectory>${project.build.directory}/generated-tests/my- 
> plugin</testSourceDirectory>
>
>  <plugins>
>   <plugin>
>    <groupId>my.group.id</groupId>
>    <artifactId>maven-gentests-plugin</artifactId>
>    <executions>
>      <execution>
>       <id>generate-tests</id>
>       <phase>generate-test-sources</phase>
>       <configuration>
>        <scriptSourceDirectory>src/main/scripts/</ 
> scriptSourceDirectory>
>        <genSrcOutputDirectory>${project.build.directory}/generated- 
> tests/my-plugin</genSrcOutputDirectory>
>       </configuration>
>       <goals>
>         <goal>generateTests</goal>
>       </goals>
>    </execution>
>    </executions>
>   </plugin>
>   </plugins>
>
> </build>
>
>
> --
> James Mitchell
>
>
>
>
>
> ---------------------------------------------------------------------
> 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