You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Pablo <pa...@tiger.com.pl> on 2005/11/15 12:45:34 UTC

problems with Integration-test and plexus compiler

Hello there

I'm writting a plugin which is supposed to do a few things:
1) Compile test classes to be run in integration-test phase
2) Start tomcat
3) Run tests
4) Stop tomcat

Steps 2, 3 and 4 are almost done. The main problem is step 1.
I thought it would be too much to do by implementing compilation from 
scratch therefore I simply created a class extending TestCompilerMojo class.
Unfortunatelly it doesn't work, throws exception because CompilerManager 
is not initialized. I tried to make it by myself by setting necessary 
field in execute() method (compilerManager, compilerId) and now it 
doesn't throw any exceptions.

In plugin configuration I've placed 'compileSourceRoots' and 
''outputDirectory' but it seems that these values are not set because I 
got a message:
'[INFO] No sources to compile'

Can someone point me to some tutorial or HOWTO describing all necessary 
steps to make it work?

I don't want to place integration tests in the same directory as normal 
junit tests because these tests are supposed to be run after tomcat is 
started with web application running in the *integration-test* phase not 
the *test* phase. If they were placed in src/tests the *package* phase 
would return error since there would be no webapp running *(test* is 
before *package* phase).

Thanks in advance.
Pablo

Integration-test and, classpath etc

Posted by Pablo <pa...@tiger.com.pl>.
Hello there

I'm struggling with maven to make him work the way I want.

I've written a plugin which has two goals:
1) testCompile - compiles tests to be executed during integration-test 
phase.
2) test - starts tomcat, run tests and stops tomcat

In all jars associated with tests there is a 'test scope' set.
Normal tests (junit tests) which are run in the 'test-compile phase' are 
compiled without errors. These tests are based on StrutsTestCase which 
are based on JUnit.
Somehow junit.jar is included in classpath during compilation and 
execution of these tests.
It's fine.

And now, my plugin wants to compile integration tests and then run them.
The first goal 'testCompile' has the following attributes
 * @goal testCompile
 * @phase test-compile
 * @requiresDependencyResolution test

However, all jars which have scope set to test are not present in the 
classpath. Why?
There is no httpunit, htmlunit, junit etc.

Could some one tell me what I'm doing wrong and what I should do to make 
it work?

Cheers
Pablo

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


Re: problems with Integration-test and plexus compiler

Posted by Jesse McConnell <je...@gmail.com>.
I needed to do a bit of compiling after the process-classes phase for a
couple of custom plugins...so I pulled out the interesting parts of the
compiler mojo and used that...not sure if there is a better way, but this
certainly works..

jesse



private Compiler compiler = new JavacCompiler();



private void compile(String file) throws MojoExecutionException {

getLog().debug("outputDir " + outputDirectory);
getLog().debug("file " + file);
getLog().debug("build to " + buildDirectory);

try {

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
compilerConfiguration.setOutputLocation( buildDirectory + "/classes" );
ArrayList list = new ArrayList();
list.add(outputDirectory);
compilerConfiguration.setSourceLocations( list );

compilerConfiguration.setClasspathEntries(
project.getCompileClasspathElements() );

HashSet set = new HashSet();
set.add(new File(file));

compilerConfiguration.setSourceFiles( set );


compilerConfiguration.setDebug( true );

List messages = null;
messages = compiler.compile( compilerConfiguration );
}
catch ( Exception e )
{
e.printStackTrace();
// TODO: don't catch Exception
throw new MojoExecutionException( "Fatal error compiling", e );
}

}

On 11/15/05, Pablo <pa...@tiger.com.pl> wrote:
>
> Hello there
>
> I'm writting a plugin which is supposed to do a few things:
> 1) Compile test classes to be run in integration-test phase
> 2) Start tomcat
> 3) Run tests
> 4) Stop tomcat
>
> Steps 2, 3 and 4 are almost done. The main problem is step 1.
> I thought it would be too much to do by implementing compilation from
> scratch therefore I simply created a class extending TestCompilerMojo
> class.
> Unfortunatelly it doesn't work, throws exception because CompilerManager
> is not initialized. I tried to make it by myself by setting necessary
> field in execute() method (compilerManager, compilerId) and now it
> doesn't throw any exceptions.
>
> In plugin configuration I've placed 'compileSourceRoots' and
> ''outputDirectory' but it seems that these values are not set because I
> got a message:
> '[INFO] No sources to compile'
>
> Can someone point me to some tutorial or HOWTO describing all necessary
> steps to make it work?
>
> I don't want to place integration tests in the same directory as normal
> junit tests because these tests are supposed to be run after tomcat is
> started with web application running in the *integration-test* phase not
> the *test* phase. If they were placed in src/tests the *package* phase
> would return error since there would be no webapp running *(test* is
> before *package* phase).
>
> Thanks in advance.
> Pablo
>
>


--
jesse mcconnell
jesseDOTmcconnellATgmailDOTcom