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 1 commit
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 setCreteBaseDir( boolean createBaseDir )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HEre is a typo

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:o yes, i need fix it ,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-o you can review now, please

{
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,37 @@ 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);
assertTemplateContentGeneratedWithFileSetArchetype( "src/main/java/file/value/package/App.java", "file-value" );
assertTemplateContentGeneratedWithFileSetArchetype( "src/main/java/file/value/package/inner/package/App2.java","file-value" );

assertTemplateCopiedWithFileSetArchetype( "src/main/java/file/value/package/App.ogg" );

File templateFile = new File( projectDirectory, "src/main/java/file/value/package/ToDelete.java" );
assertFalse( templateFile + " should have been removed (by post-generate.groovy script", templateFile.exists() );

assertTemplateContentGeneratedWithFileSetArchetype( "src/main/resources/App.properties", "file-value" );
assertTemplateContentGeneratedWithFileSetArchetype( "src/main/resources/file-value/touch.txt", "file-value" );
assertTemplateContentGeneratedWithFileSetArchetype( "src/main/resources/file-value/touch_root.txt",
"file-value" );

assertTemplateCopiedWithFileSetArchetype( "src/main/resources/some-dir/App.png" );

assertTemplateContentGeneratedWithFileSetArchetype( "src/site/site.xml", "file-value" );
assertTemplateContentGeneratedWithFileSetArchetype( "src/site/apt/usage.apt", "file-value" );
assertTemplateContentGeneratedWithFileSetArchetype( ".classpath", "file-value" );
assertTemplateContentGeneratedWithFileSetArchetype( "profiles.xml", "file-value" );
}

public void testGenerateArchetypeWithPostScriptIncluded()
throws Exception
Expand Down