maven-git-versioning-extension
maven-git-versioning-extension copied to clipboard
[Feature Request] Activate and Deactivate Maven Profile based in git ref
Great plugin! One thing I am missing is activating a profile. I tried using a property to activate a profile, but looks like the profile is not detecting this property.
My Configs look like: maven-git-versioning-extension.xml
<refs>
<ref type="branch">
<pattern><![CDATA[(feature\/)(?<project>[A-Za-z]+)-(?<issueNum>[0-9]+).*]]></pattern>
<version>${version.release}-${ref.project}${ref.issueNum}-SNAPSHOT</version>
<properties>
<issueKey>FOO123</issueKey>
</properties>
</ref>
</refs>
pom.xml
...
<profile>
<id>feature-branch</id>
<activation>
<property>
<name>issueKey</name>
</property>
</activation>
</profile>
...
When I run clean install the pom version changes, but the profile does not activate.
I'm afraid it is not possible right now. That is because only system properties are supported by maven for the <activation>< property>
However I could add config section to activate or deactivate profiles
<ref type="branch">
<profiles>
<debug>true</debug>
</profiles>
</ref>
Yea that would be great!
Apparently it is not that easy to enable profile in a dynamic way or I can't figuring out how. I tried at this branch with GitVersioningProfileSelector class. The strange think is it gets called however it does not have any effect no matter what I return from getActiveProfiles method.
Any help is welcome.
I have played around a bit with this in https://github.com/advanova/maven-git-versioning-extension/tree/feature/control-profiles
This seems to work now. I think the main problem was this line: https://github.com/qoomon/maven-git-versioning-extension/blob/442d0256919f832ffd61f757bbc5d915fa4edbca/src/main/java/me/qoomon/maven/gitversioning/GitVersioningProfileSelector.java#L40
It should have a == instead of the !=, so that the custom profile activation is activated for all projects, that do have a project directory.
Unfortunately I couldn't rebase this easily, maybe you could help with that, since you know the code better? I could then do the rest to finish this (add tests, add documentation, change schema)
@tisoft thanks a lot for your deep dive. I'll try to fix it the upcoming days.
@tisoft I think you are right it is working, however the rebase involves more effort and I don't have the time right now. I maybe able to do the development until the end of January. I'll keep you posted.
@tisoft Unfortunately there is a challenge to make the configuration available in the ProfileSelector. I don't have the time solve this for now. I reset the branch feature/control-profiles and added a working implementation for GitVersioningProfileSelector. Feel free to open a PR.