Skip to content

Case-insensitive OS activation#2286

Merged
alexarchambault merged 4 commits intocoursier:masterfrom
dwickern:case-insensitive-os-activation
Mar 15, 2022
Merged

Case-insensitive OS activation#2286
alexarchambault merged 4 commits intocoursier:masterfrom
dwickern:case-insensitive-os-activation

Conversation

@dwickern
Copy link
Copy Markdown
Contributor

@dwickern dwickern commented Dec 6, 2021

This profile does not activate due to the capital W in Windows:

<activation>
  <os>
    <family>Windows</family>
    <arch>amd64</arch>
  </os>
</activation>

For my use-case, jvmbrotli uses profiles to pull in its jni libs for each operating system:
https://github.com/nixxcode/jvm-brotli/blob/06a73890dec39b060c80d021a45e80c8ae1a8c32/jvmbrotli/pom.xml#L18-L33

This works for <family>unix</family> and <family>mac</family> but not <family>Windows</family> due to the capitalization:
https://github.com/dwickern/sbt-web-brotli/runs/4423716589?check_suite_focus=true

Copy link
Copy Markdown
Member

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It looks like this needs to be fixed, yes.

I think I'd prefer to keep the arch / family / … as is in the Activation.Os class, and only convert things to lower case in its isActive method (maybe keeping lower case values as private lazy vals in Activation.Os). Some people use the POM parsing capabilities of coursier, and I'd rather keep the original values for them, just in case.

@dwickern
Copy link
Copy Markdown
Contributor Author

I did as you suggested so that we preserve the original Os values. I switched to Locale.US for string comparisons, since that's what plexus-utils uses.

def isEmpty: Boolean =
arch.isEmpty && families.isEmpty && name.isEmpty && version.isEmpty

def archMatch(current: Option[String]): Boolean =
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to keep this for compatibility since it's public?

Copy link
Copy Markdown
Member

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants