Closed GoogleCodeExporter closed 9 years ago
Hi Marc,
Thanks for the suggestions.
With the ${token} tokens, you may turn off regex matching (since the $ is a
regex character) to make these tokens match and make your token ${username}.
I used to have my token/value map file use '=' but people were having problems
matching tokens which contained '=' characters. So I decided to use new lines
to separate instead (which was a much simpler solution than escaping out).
I can add '#' as a known comment line, but I fear I might run into the same
issue that I had with the '=' separator. Perhaps I can consider them comments
if they are the first character. However, I might just give it a go. I could
just add a parameter to define the separator.
Let me ponder on this for a little while.
Thanks for your feedback,
Steven
Original comment by baker.st...@gmail.com
on 6 Sep 2010 at 9:11
Hi Steven,
Thanks for considering my ideas.
Like I said before, I have already personally modified my own local copy to
suit me, so I personally am not desperate for these changes!
Just offering some ideas that helped me.
I fully understand regular expressions and the $ and {} characters weren't
causing me issues.
The problem was that maven replaces tokens like ${token_name} with values from
the filter file "token_name=replace_value".
I was trying to use your generic replacement plugin as a "Configuration
parameter management plugin" which meant I was going to have to go through all
my filter files and change "token_name" to "${token_name}" to make it do what I
wanted.
There are a couple of easy tweaks to make the "token=value" thing work with
escape characters, I tend to use replace on the input string and then split to
get what I want...
Usually looks like this:
private final static String EQUALS_REPLACEMENT = "_EQUALS_"; //use whatever
character sequence you like, something people are unlikely to have in their
files!
line = line.replaceAll("\\\\=", EQUALS_REPLACEMENT); //replace '\=' with some
"special token" to allow people to escape their inputs
line = line.replaceAll("=", "= "); //replace all actual '=' with '= ' because
otherwise "a=" is only 1 token and you'll be in trouble
String splitTokens[] = line.split("=");//actual split
if(splitTokens.length != 2){
//fail
}
else{
token = splitTokens[0].trim();
value = splitTokens[1].trim();
/* now replace the special token in the strings with the actual = symbol which is what the inputter requested */
token = token.replaceAll(EQUALS_REPLACEMENT, "=");
value = value.replaceAll(EQUALS_REPLACEMENT, "=");
}
As for the comments, maybe you can have a parameter "comments-enabled", default
= true and if people need to use "#" as the first character they can disable
comments.
Thanks again for taking the time to consider these suggestions.
Marc
Original comment by marc.rie...@gmail.com
on 7 Sep 2010 at 12:16
Thanks a lot for the sample code, I will give it a go and let you know. :-)
Original comment by baker.st...@gmail.com
on 8 Sep 2010 at 3:35
Thanks a million Marc!
Original comment by laila.fr...@gmail.com
on 8 Oct 2010 at 11:12
Implementation complete.
Will be in next release.
Original comment by baker.st...@gmail.com
on 30 Oct 2010 at 2:32
Released in 1.3.3.
Original comment by baker.st...@gmail.com
on 30 Oct 2010 at 3:03
Just issue clean up.
Original comment by baker.st...@gmail.com
on 17 Sep 2012 at 12:42
make config file unreadable.
Is it possible to specify a separator like new line?
Original comment by reda.abdi
on 6 Feb 2013 at 3:04
Original issue reported on code.google.com by
marc.rie...@gmail.com
on 6 Sep 2010 at 1:32