You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Dietrich Schulten (Jira)" <ji...@apache.org> on 2020/07/09 14:07:00 UTC

[jira] [Comment Edited] (ARCHETYPE-505) archetype:create-from-project,the .gitignore file not copy to archetype-resources

    [ https://issues.apache.org/jira/browse/ARCHETYPE-505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17154593#comment-17154593 ] 

Dietrich Schulten edited comment on ARCHETYPE-505 at 7/9/20, 2:06 PM:
----------------------------------------------------------------------

The .gitignore and .gitattributes files are ignored both by {{create-from-project}} *and* by {{generate}}. With maven-archetype-plugin:3.1.2 and maven-resources-plugin:3.1.0 in Maven 3.6.2 not even the {{addDefaultExcludes}} option of the resources plugin has any effect, although {{create-from-project}} automatically lists .gitignore and .gitattributes explicitly as files to include in archteype-metadata.xml.

Since the .gitxxx files don't make it into the archetype, a groovy script can't restore them either.

The handling of files which are on plexus' default excludes list is thoroughly broken in the current versions of the plugins.


was (Author: dschulten):
The .gitignore and .gitattributes files are ignored both by {{{color:#808080}{color:#172b4d}create-from-project {color}{color}}}{color:#172b4d}*and* by {color}{color:#808080}{color:#172b4d}{{generate}}. With maven-archetype-plugin:3.1.2 and maven-resources-plugin:3.1.0 in Maven 3.6.2 not even the {{addDefaultExcludes}} option of the resources plugin has any effect, although create-from-project lists .gitignore and .gitattributes explicitly as file to include in archteype-metadata.xml.{color}
{color}

{color:#808080}{color:#172b4d}Since the .gitxxx files don't make it into the archetype, a groovy script can't restore them either.{color}{color}

{color:#808080}{color:#172b4d}The handling of files which are on plexus' default excludes list is thoroughly broken in the current versions of the plugins.{color}{color}

> 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
>            Priority: Major
>         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
(v8.3.4#803005)