FileUtils.deleteDirectory( basedir );
FileUtils.mkdir( basedir );
ArchetypeGenerationRequest request =
new ArchetypeGenerationRequest().setArchetypeGroupId( project.getGroupId() ).setArchetypeArtifactId(
project.getArtifactId() ).setArchetypeVersion( project.getVersion() ).setGroupId(
properties.getProperty( Constants.GROUP_ID ) ).setArtifactId(
properties.getProperty( Constants.ARTIFACT_ID ) ).setVersion(
properties.getProperty( Constants.VERSION ) ).setPackage(
properties.getProperty( Constants.PACKAGE ) ).setOutputDirectory( basedir ).setProperties(
properties );
ArchetypeGenerationResult result = new ArchetypeGenerationResult();
archetypeGenerator.generateArchetype( request, archetypeFile, result );
if ( result.getCause() != null )
{
if ( result.getCause() instanceof ArchetypeNotConfigured )
{
ArchetypeNotConfigured anc = (ArchetypeNotConfigured) result.getCause();
throw new IntegrationTestFailure(
"Missing required properties in archetype.properties: " + StringUtils.join(
anc.getMissingProperties().iterator(), ", " ), anc );
}
throw new IntegrationTestFailure( result.getCause().getMessage(), result.getCause() );
}
File reference = new File( goalFile.getParentFile(), "reference" );
if ( reference.exists() )
{
// compare generated project with reference
getLog().info( "Comparing generated project with reference content: " + reference );
assertDirectoryEquals( reference, new File( basedir, request.getArtifactId() ) );
}
String goals = FileUtils.fileRead( goalFile );
invokePostArchetypeGenerationGoals( goals, new File( basedir, request.getArtifactId() ), goalFile );
}
catch ( IOException ioe )
{
throw new IntegrationTestFailure( ioe );
}