[
https://issues.apache.org/jira/browse/ARCHETYPE-505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16205303#comment-16205303
]
justin georgeson commented on ARCHETYPE-505:
--------------------------------------------
I think ignoring such files by default makes sense, especially when using
_create-from-project_. _But_ ... I'm using maven-archetype-plugin 3.0.1 with
the maven-archetype packaging type to build my archetype (ie I have the v2
format archetype-metadata.xml descriptor and the template project contents in
src/main/resources/archetype-resources) and have expressly requested to include
the .gitignore (or any other file that's in the default excludes). It's
silently ignoring what I've configured. It should at least warn me that's it's
not fulfilling my project configuration.
The only current workaround I can think of is to write a post-generation script
(src/main/resources/META-INF/archetype-post-generate.groovy) to generate my
.gitignore and .gitattributes files. Is that my only option with current
release?
> archetype:create-from-project,the .gitignore file not copy to
> archetype-resources
> ---------------------------------------------------------------------------------
>
> Key: ARCHETYPE-505
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-505
> Project: Maven Archetype
> Issue Type: Bug
> Components: Archetypes
> Affects Versions: 2.4
> Environment: maven 3.3 ,maven-archetype-plugin 2.4
> Reporter: feilong
> Attachments: webapp-springmvc32.zip
>
>
> I have a very simple maven test project for {{archetype:create-from-project}}
> such as :(you can download from the Attachment)
> {noformat}
> | .gitignore
> | pom.xml
> |
> \---src
> +---main
> | \---java
> | overview.html
> |
> \---test
> {noformat}
> only {{.gitignore}} and {{pom.xml}}, and {{overview.html}} files
> and I excute the command line in the root folder:
> {code:xml}
> mvn -X archetype:create-from-project
> {code}
> I see ,in the
> {{target\generated-sources\archetype\src\main\resources\archetype-resources}}
> folder, only
> {noformat}
> | pom.xml
> |
> \---src
> \---main
> \---java
> overview.html
> {noformat}
> no {{.gitignore}} file
> ----
> first , I search the same issue in jira, there is #ARCHETYPE-474 , but not as
> my scene
> ----
> I search some solution in stackoverflow
> http://stackoverflow.com/questions/7981060/maven-archetype-plugin-doesnt-let-resources-in-archetype-resources-through#answer-37322323
> In pom.xml,I have also configed that
> {code:xml}
> <plugin>
> <artifactId>maven-resources-plugin</artifactId>
> <version>3.0.1</version>
> <configuration>
> <encoding>utf-8</encoding>
> <includeEmptyDirs>true</includeEmptyDirs>
> <addDefaultExcludes>false</addDefaultExcludes>
> </configuration>
> <executions>
> <execution>
> <id>default-resources</id>
> <phase>process-resources</phase>
> <goals>
> <goal>resources</goal>
> </goals>
> <configuration>
> <detail>true</detail>
> </configuration>
> </execution>
> <execution>
> <id>default-testResources</id>
> <phase>process-test-resources</phase>
> <goals>
> <goal>testResources</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> {code}
> {{maven-resources-plugin}} set {{addDefaultExcludes}} attribute to {{false}}
> but does't work
> ----
> so, I look for the maven-archetype source code in github
> https://github.com/apache/maven-archetype
> the
> org.apache.maven.archetype.creator.FilesetArchetypeCreator.*createArchetypeFiles*(Properties,
> List<FileSet>, String, File, File, String) method
> line 796 show that:
> {code:title=FilesetArchetypeCreator.java|borderStyle=solid}
> private void createArchetypeFiles( Properties reverseProperties,
> List<FileSet> fileSets, String packageName,
> File basedir, File
> archetypeFilesDirectory, String defaultEncoding )
> throws IOException
> {
> getLogger().debug( "Creating Archetype/Module files from " + basedir
> + " to " + archetypeFilesDirectory );
> for ( FileSet fileSet : fileSets )
> {
> DirectoryScanner scanner = new DirectoryScanner();
> scanner.setBasedir( basedir );
> scanner.setIncludes( (String[]) concatenateToList(
> fileSet.getIncludes(), fileSet.getDirectory() ).toArray(
> new String[fileSet.getIncludes().size()] ) );
> scanner.setExcludes( (String[]) fileSet.getExcludes().toArray(
> new String[fileSet.getExcludes().size()] ) );
> scanner.addDefaultExcludes();
> getLogger().debug( "Using fileset " + fileSet );
> scanner.scan();
> List<String> fileSetResources = Arrays.asList(
> scanner.getIncludedFiles() );
> getLogger().debug( "Scanned " + fileSetResources.size() + "
> resources" );
>
> .....
> {code}
> here is {{scanner.addDefaultExcludes();}}
> So , the result log show that :
> {noformat}
> [DEBUG] Creating Archetype/Module files from
> C:\Users\feilong\feilong\feilong-archetypes\0726-232539 to
> C:\Users\feilong\feilong\feilong-archetypes\0726-232539\
> target\generated-sources\archetype\src\main\resources\archetype-resources
> [DEBUG] Using fileset src/main/java (Copied-Flat) [**/*.html -- ]
> [DEBUG] Scanned 1 resources
> [DEBUG] Package as Directory: Package:com.baozun.store->com\baozun\store
> [DEBUG] InputFileName:src\main\java\overview.html
> [DEBUG] OutputFileName:src\main\java\overview.html
> [DEBUG] Copied src/main/java files
> [DEBUG] Using fileset (Copied-Flat) [.gitignore -- ]
> [DEBUG] Scanned 0 resources
> [DEBUG] Package as Directory: Package:com.baozun.store->com\baozun\store
> [DEBUG] Copied files
> [DEBUG] Created files for webapp-springmvc3
> {noformat}
> when scan {{.gitignore}} , {{Scanned 0 resources}}
> ----
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)