[
http://jira.codehaus.org/browse/ARCHETYPE-191?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=160206#action_160206
]
Alexander Maslov edited comment on ARCHETYPE-191 at 1/7/09 2:59 AM:
--------------------------------------------------------------------
this does not work for files like:
messages\_\_\_property-name\_\_.properties
So if there is "\_" before "\_\_property-name\_\_" the it tries to use
"\_property-name" which is undefined.
This is because DELIMITER in DefaultFilesetArchetypeGenerator.java is "\_\_"
and as a result TOKEN_PATTERN is ".\*\_\_.\*\_\_.\*"
If you restrict property name to start and end with letter or number, then
TOKEN_PATTERN could be changed to avoid this kind of situations.
TOKEN_PATTERN might be not a problem but here:
{code:title:DefaultFilesetArchetypeGenerator.java}
private String replaceFilenameTokens( String filePath, Context context )
{
String interpolatedResult = filePath;
String propertyToken = null;
String contextPropertyValue = null;
int start = 0;
int end = 0;
int skipUndefinedPropertyIndex = 0;
int maxAttempts = StringUtils.countMatches( interpolatedResult,
DELIMITER ) / 2;
for ( int x = 0; x < maxAttempts && start != -1; x++ )
{
start = interpolatedResult.indexOf( DELIMITER,
skipUndefinedPropertyIndex );
if ( start != -1 )
{
end = interpolatedResult.indexOf( DELIMITER,
start + DELIMITER.length() );
if ( end != -1 )
{
propertyToken = interpolatedResult.substring(
start + DELIMITER.length(), end );
}
{code}
was (Author: maslovalex):
this does not work for files like:
messages\_\_\_property-name\_\_.properties
So if there is "\_" before "\_\_property-name\_\_" the it tries to use
"\_property-name" which is undefined.
This is because DELIMITER in DefaultFilesetArchetypeGenerator.java is "\_\_"
and as a result TOKEN_PATTERN is ".\*\_\_.\*\_\_.\*"
If you restrict property name to start and end with letter or number, then
TOKEN_PATTERN could be changed to avoid this kind of situations.
> Ability to filter filenames (rename files) during project generation
> --------------------------------------------------------------------
>
> Key: ARCHETYPE-191
> URL: http://jira.codehaus.org/browse/ARCHETYPE-191
> Project: Maven Archetype
> Issue Type: New Feature
> Components: Generator
> Affects Versions: 2.0-alpha-3
> Reporter: Wendy Smoak
> Fix For: 2.0-alpha-4
>
> Attachments: mytest-1.0.1.jar, mytest-1.0.1.pom,
> ReplaceAnyContextPropertyEnhancement-v2.patch,
> ReplaceAnyContextPropertyEnhancement.patch
>
>
> When generating a new project from an archetype, I need to filter not only
> values within files, but the names of the files themselves.
> For example, in .NET projects, the project files (.sln, .csproj) match the
> name of the solution or project rather than having a fixed name like Maven's
> pom.xml does.
> Another user raised a similar issue on the mailing list, the ability to
> filter in the name of Java source code files.
> See: http://www.nabble.com/Archetype%2C-define-file-name-ts18430983.html
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira