Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ARCHETYPE-311] Add feature to create base dir #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public class ArchetypeGenerationRequest
private String archetypeVersion;

private String archetypeGoals = "";

private boolean createBaseDir = true;

/**
* The URL to the archetype repository
Expand Down Expand Up @@ -390,4 +392,16 @@ public ArchetypeGenerationRequest setFilter( String filter )

return this;
}

public boolean isCreateBaseDir()
{
return createBaseDir;
}

public ArchetypeGenerationRequest setCreateBaseDir( boolean createBaseDir )
{
this.createBaseDir = createBaseDir;

return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public void generateArchetype( ArchetypeGenerationRequest request, File archetyp

String packageName = request.getPackage();
String artifactId = request.getArtifactId();
File outputDirectoryFile = new File( request.getOutputDirectory(), artifactId );
File outputDirectoryFile = new File( request.getOutputDirectory(),
ripper2hl marked this conversation as resolved.
Show resolved Hide resolved
request.isCreateBaseDir() ? artifactId : "" );
File basedirPom = new File( request.getOutputDirectory(), Constants.ARCHETYPE_POM );
File pom = new File( outputDirectoryFile, Constants.ARCHETYPE_POM );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,35 @@ public void testPropertiesNotDefined()
result.getCause().getMessage().startsWith( "Archetype archetypes:basic:1.0 is not configured" )
&& result.getCause().getMessage().endsWith( "Property property-without-default-4 is missing." ) );
}

public void testGenerateArchetypeWithSameDirectoryExcution()
throws Exception
{
System.out.println( "testGenerateArchetypeWithSameDirectoryExcution" );
ArchetypeGenerationRequest request = createArchetypeGenerationRequest( "generate-14", ARCHETYPE_BASIC );
request.setCreteBaseDir( false );
projectDirectory = new File( outputDirectory );
FileUtils.forceDelete( projectDirectory );

generateProjectFromArchetype(request);

assertTemplateContent( "src/main/java/file/value/package/App.java" );
assertTemplateContent( "src/main/java/file/value/package/inner/package/App2.java" );
assertTemplateContent( "src/main/c/file/value/package/App.c" );
assertTemplateContent( "src/test/java/file/value/package/AppTest.java" );
assertTemplateContent( "src/test/c/file/value/package/AppTest.c" );
assertTemplateContent( "src/main/resources/App.properties" );
assertTemplateContent( "src/main/resources/inner/dir/App2.properties" );
assertTemplateContent( "src/main/mdo/App.mdo" );
assertTemplateContent( "src/test/resources/AppTest.properties" );
assertTemplateContent( "src/test/mdo/AppTest.mdo" );

Model model = readPom( new File( projectDirectory, "pom.xml" ) );
assertNull( model.getParent() );
assertEquals( "file-value", model.getGroupId() );
assertEquals( "file-value", model.getArtifactId() );
assertEquals( "file-value", model.getVersion() );
}

public void testGenerateArchetypeWithPostScriptIncluded()
throws Exception
Expand Down