You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Konrad Windszus (Jira)" <ji...@apache.org> on 2024/02/21 12:53:00 UTC

[jira] [Comment Edited] (MNG-5726) Update OS Activation To Allow Wildcards In OS Version

    [ https://issues.apache.org/jira/browse/MNG-5726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17819226#comment-17819226 ] 

Konrad Windszus edited comment on MNG-5726 at 2/21/24 12:52 PM:
----------------------------------------------------------------

Currently this is based on a string comparison in https://github.com/apache/maven/blob/a31c145ae9383cf9f252cf83f08ae71b7dbb8532/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java#L98. I am wondering if we can use version ranges here reasonably like we do for the JDK activation: https://github.com/apache/maven/blob/a31c145ae9383cf9f252cf83f08ae71b7dbb8532/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java#L78C20-L78C27.
OTOH OS versions are much harder to parse, so maybe using regex parsing makes indeed more sense here.

Maybe using a reserved prefix like `regex:` would work here, this is already used in https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getPathMatcher-java.lang.String-. Pretty unlikely that this prefix is used in a version string literally.


was (Author: kwin):
Currently this is based on a string comparison in https://github.com/apache/maven/blob/a31c145ae9383cf9f252cf83f08ae71b7dbb8532/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java#L98. I am wondering if we can use version ranges here reasonably like we do for the JDK activation: https://github.com/apache/maven/blob/a31c145ae9383cf9f252cf83f08ae71b7dbb8532/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java#L78C20-L78C27.
OTOH OS versions are much harder to parse, so maybe using regex parsing makes indeed more sense here.

> Update OS Activation To Allow Wildcards In OS Version
> -----------------------------------------------------
>
>                 Key: MNG-5726
>                 URL: https://issues.apache.org/jira/browse/MNG-5726
>             Project: Maven
>          Issue Type: New Feature
>          Components: Profiles
>    Affects Versions: 3.1.1, 3.2.3
>         Environment: RHEL/CentOs
>            Reporter: Andy Lehane
>            Priority: Minor
>         Attachments: maven-os-version-patch-3.2.3.zip
>
>
> I'm attempting to use maven to build a legacy project that requires different dependecies based on the operating system version, i.e:
>  - version 1.0 of "a platform specific library" for Red Hat Linux 5 
>  - version 1.1 of "a platform specific library" for Red Hat Linux 6
>  - version 1.4a of "a platform specific library" for Windows and
>  - version 1.3b of (a platform specific library" for Solaris.
> I can configure my pom file to get activate specific profiles for RHEL, Win and Solaris but cannot distinguish between Red Hat 5 and 6 unless I use the full version string, which is of the form "2.6.32-504.1.3.el6.x86_64".
> As this Linux version will change whenever patch updates are installed, this will make maintaining the pom/project akward.
> To solve this, it would be good to be able to specify wildcard's in the os version tag. I have taken a look at the range checking (for example, as applied to the JdkVersion), but don't think this method would be sufficient, as the specific part of the Red Hat version number we require is buried over half way into the version string (i.e. "el6" of the version "2.6.32-504.1.3.el6.x86_64").
> It would be nice to be able to have something like:
> {code}
>     <profile>
>       <id>linux-rhel5</id>
>         <activation>
>           <activeByDefault>false</activeByDefault>
>           <os>
>             <family>unix</family>
>             <name>Linux</name>
>             <version>*el5*</version>
>           </os>
>         </activation>
>         <properties>
>             .....
> {code}
> I've taken a look at the OperatingSystemProfileActivator code and have created a patch that will use ^ to signify that the text is a regular expression, for example:
> {code}
>             <version>^.*(el5).*</version>
> {code}
> I've also kept the ! notation, so the following can also be used:
> {code}
>             <version>!^.*(el5).*</version>
> {code}
> The patch added contains a unit test for the OperatingSystemProfileActivator in the maven-model-builder project (warning: it's a nasty test but I couldn't find a nicer way of being able to reliably manuplate the OS Version).
> I've also patch the OperatingSystemProfileActivator class in the maven-compat project but have not been able to write a unit test for that class.
> Can this updated be considered for implementation/inclusion please?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)