[ 
https://jira.codehaus.org/browse/ARCHETYPE-361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Osipov closed ARCHETYPE-361.
------------------------------------

    Resolution: Won't Fix

Please refer to 
https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014
 if you're wondering why this issue was closed out.

> String.replace() used in an inconsistent (and unnecessary) way
> --------------------------------------------------------------
>
>                 Key: ARCHETYPE-361
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-361
>             Project: Maven Archetype
>          Issue Type: Bug
>          Components: Generator
>    Affects Versions: 2.0
>            Reporter: Marc Wirth
>            Priority: Minor
>         Attachments: unnecessary_stringreplace.patch
>
>
> See attached patch. Sorry, no specific test case, but the existing testcases 
> do not complain if this change is applied.
> First one:
> {code}
> processFilesetProject( archetypeDescriptor,
>                                          StringUtils.replace( artifactId, 
> "${rootArtifactId}", rootArtifactId ),
>                                          archetypeResources, pom, 
> archetypeZipFile, moduleOffset, context, packageName,
>                                          outputDirectoryFile, basedirPom );
> {code}
> replaced with:
> {code}
> processFilesetProject( archetypeDescriptor,
>                                          artifactId,
>                                          archetypeResources, pom, 
> archetypeZipFile, moduleOffset, context, packageName,
>                                          outputDirectoryFile, basedirPom );
> {code}
> On the first call to the method the artifactId is the id from the request, so 
> it cannot really contain "$\{rootArtifactId\}" unless somebody typed that on 
> the console. If there are modules and the method recurses the parameter is 
> replaced with {{StringUtils.replace( project.getDir(), "__rootArtifactId__", 
> rootArtifactId )}} and the ModuleDescriptor dir uses the underscores for 
> escaping, not the dollar and the braces, so I assume this replacement is not 
> necessary at all. (None of the existing tests breaks).
> Second one:
> {code}
> processFilesetModule( rootArtifactId,
>                                         StringUtils.replace( 
> project.getDir(), "__rootArtifactId__", rootArtifactId ),
>                                         archetypeResources,
>                                         new File( moduleOutputDirectoryFile, 
> Constants.ARCHETYPE_POM ), archetypeZipFile,
>                                         ( StringUtils.isEmpty( moduleOffset ) 
> ? "" : ( moduleOffset + "/" ) )
>                                                 + StringUtils.replace( 
> project.getDir(), "${rootArtifactId}", rootArtifactId ),
>                                         pom, moduleOutputDirectoryFile, 
> packageName, project, context );
> {code}
> replaced with:
> {code}
> processFilesetModule( rootArtifactId,
>                                         StringUtils.replace( 
> project.getDir(), "__rootArtifactId__", rootArtifactId ),
>                                         archetypeResources,
>                                         new File( moduleOutputDirectoryFile, 
> Constants.ARCHETYPE_POM ), archetypeZipFile,
>                                         ( StringUtils.isEmpty( moduleOffset ) 
> ? "" : ( moduleOffset + "/" ) )
>                                                 + project.getDir(),
>                                         pom, moduleOutputDirectoryFile, 
> packageName, project, context );
> {code}
> The dir of the Module descriptor uses underscores, not dollar plus braces for 
> escaping. At least that's the way it is also created in 
> org.apache.maven.archetype.creator.FilesetArchetypeCreator#createModule. Thus 
> replacing a {{"$\{...\}"}} expression in ModuleDescriptor#getDir() should 
> never actually do anything.
> Is that analysis correct?



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Reply via email to