-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace characters and change the case of letters #317
Comments
Interesting use-case. Thanks for creating this ticket and sharing your idea! As of right now the plugin doesn't support this. What comes closes to this is the following: I would be happy to implement some sort of transformation rule, but want to make sure its somewhat generic.
Not sure if there would need to be an option that would allow multiple casing transformation rules to be performed after each other (e.g. apply capitalization and invert). As far it seems the rest can be achieved using regex. |
I don't know which regex engine you use, but it seems that Perl provides the operator \L which can be used to convert cases. Something like |
Inside the link you suggested there is a sample use of the GMaven plugin, which I tried
This was the input: The uppercase letters are removed, so I think that this plugin regex replacer came first, before the GMaven plugin (or the GMaven plugin came even before the Maybe some sort of Maven configuration between the phases of execution. |
I also saw this perl-thing, but unfortunately we have a java-project here so this doesn't work ;-) We use plain java-features with Java-Pattern. The appraoch with the gmaven-plugin should technically work. Double check the phases where the plugins are executed. What you also could try is instead of overwriting the |
Looking around I found the In addition to regex replacement, it offers 2 additional flags to convert in upper/lower case the output of the replacement. Here is my current configuration:
I created 2 different executions (one for remove forbidden characters+lowercase and one for removing the multiple hyphens. I found the With the provided configuration is my current situation: EDIT: After reading in the documentation that this plugin is triggered by default on After this modification the entire build seems to be work fine |
Agree, it seems that you run into the same problem as outlined in #287. |
I agree with you, your suggestion But after I discovered that this generates an error, I then tried with the
There is something wrong with the build if all the 3 values are considered as empty. I also tried with a Maven property that exists for sure:
but the result is the same. If At this point can be another problem here, not the usual one |
Hi, |
Thinking about this feature. <replacementProperties>
<replacementProperty>
<!-- input -->
<property>git.branch</property>
<!-- optional output property -->
<outputProperty>git.branch.replacemagic</outputProperty>
<token>^([^\/]*)\/([^\/]*)$</token>
<value>$1-$2</value>
<regex>true</regex>
<transformationRules>
<transformationRule>
<apply>BEFORE_REGEX</apply>
<action>CAPITALIZATION</action>
<transformationRule>
<transformationRule>
<apply>BEFORE_REGEX</apply>
<action>INVERT_CASE</action>
<transformationRule>
<transformationRule>
<apply>AFTER_REGEX</apply>
<action>LOWER_CASE</action>
<transformationRule>
</transformationRules>
</replacementProperty>
</replacementProperties>
This is the very first draft and thus, I'm not sure about the naming. I def. want something sounding very generic...eventhough it would be a pain to parse somehow the enums in a nested configuration object (yeah thats the most tricky part here). Regardless of the naming this seems that could do the magic what is being asked for and with generic names could easily be extended... |
One advice I can think of, allow to declare a different output property for the regex. Something like the "name" property of the build-help plugin |
@NicolaSpreafico thanks for the feedback. Almost missed that...I added it to my previous comment; obviously this property definition would be optional and by default it would use the same property as given in the input... Note for future references: |
… the case of letters
…hlight potential future candidates (those would most likely require stringutils - additional dependency)
Feature added with #327 will be available with the upcoming 2.2.4 |
…-profile that is being executed; note Maven is not required to use the constructer to create a Transformation rule and thus we need to set the applyRule and actionRule
…sted objects at least fail as early as possible with a somewhat meaningfull message when the required parameters are not set
This is my plugin configuration
As already discussed in issue #287, I'm trying to use the
git.branch
property as a version name for a web application. This value need to be url-safe with the following rules:As I discovered looking into the wiki, exists a very new configuration (from 2.2.3)
replacementProperties
that can achieve this kind of need.My idea is replacing all the forbidden characters with a - characters
and after that removing all the duplicated -
I'm a little stuck changing the case of the letters. I need to lowercase the letter BEFORE the first replacement, or the pattern will convert all the uppercase letters in - character.
Of course if this cannot be made I will simply use lowercase letters for my feature names, it is not a big problem. But if this transformation can be done is useful as well.
Can the case of the letters be changed?
The text was updated successfully, but these errors were encountered: