You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "feilong (JIRA)" <ji...@apache.org> on 2016/07/26 15:39:20 UTC
[jira] [Updated] (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:all-tabpanel ]
feilong updated ARCHETYPE-505:
------------------------------
Description:
I have a very simple maven test project for `archetype:create-from-project`
such as :
<pre>
| .gitignore
| pom.xml
|
\---src
+---main
| \---java
| overview.html
|
\---test
</pre>
only `.gitignore` and pom.xml , and overview.html files
and in the root folder, i excute the command line:
```
mvn -X archetype:create-from-project
```
I see ,in the `target\generated-sources\archetype\src\main\resources\archetype-resources` folder, only
```
| pom.xml
|
\---src
\---main
\---java
overview.html
```
`.gitignore` file not copied
I found 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 configed that
```
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${v.maven-resources-plugin}</version>
<configuration>
<encoding>${project.build.sourceEncoding}</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>
```
maven-resources-plugin addDefaultExcludes attibute to false
but does't work
so, i look the maven-archetype source 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
```
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" );
.....
```
here is `scanner.addDefaultExcludes();`
so , the result log show that
```
[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
```
when scan .gitignore , `Scanned 0 resources`
I also search in jira, there is #ARCHETYPE-474 , but not as i said
was:
I have a very simple maven test project for `archetype:create-from-project`
such as :
```
| .gitignore
| pom.xml
|
\---src
+---main
| \---java
| overview.html
|
\---test
```
only `.gitignore` and pom.xml , and overview.html files
and in the root folder, i excute the command line:
```
mvn -X archetype:create-from-project
```
I see ,in the `target\generated-sources\archetype\src\main\resources\archetype-resources` folder, only
```
| pom.xml
|
\---src
\---main
\---java
overview.html
```
`.gitignore` file not copied
I found 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 configed that
```
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${v.maven-resources-plugin}</version>
<configuration>
<encoding>${project.build.sourceEncoding}</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>
```
maven-resources-plugin addDefaultExcludes attibute to false
but does't work
so, i look the maven-archetype source 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
```
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" );
.....
```
here is `scanner.addDefaultExcludes();`
so , the result log show that
```
[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
```
when scan .gitignore , `Scanned 0 resources`
I also search in jira, there is #ARCHETYPE-474 , but not as i said
> 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
>
> I have a very simple maven test project for `archetype:create-from-project`
> such as :
> <pre>
> | .gitignore
> | pom.xml
> |
> \---src
> +---main
> | \---java
> | overview.html
> |
> \---test
> </pre>
> only `.gitignore` and pom.xml , and overview.html files
> and in the root folder, i excute the command line:
> ```
> mvn -X archetype:create-from-project
> ```
> I see ,in the `target\generated-sources\archetype\src\main\resources\archetype-resources` folder, only
> ```
> | pom.xml
> |
> \---src
> \---main
> \---java
> overview.html
> ```
> `.gitignore` file not copied
> I found 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 configed that
> ```
> <plugin>
> <artifactId>maven-resources-plugin</artifactId>
> <version>${v.maven-resources-plugin}</version>
> <configuration>
> <encoding>${project.build.sourceEncoding}</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>
> ```
> maven-resources-plugin addDefaultExcludes attibute to false
> but does't work
> so, i look the maven-archetype source 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
> ```
> 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" );
>
> .....
> ```
> here is `scanner.addDefaultExcludes();`
> so , the result log show that
> ```
> [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
> ```
> when scan .gitignore , `Scanned 0 resources`
>
> I also search in jira, there is #ARCHETYPE-474 , but not as i said
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)