os-maven-plugin icon indicating copy to clipboard operation
os-maven-plugin copied to clipboard

Prefix os.detected.classifier property on mac

Open jkirsch opened this issue 8 years ago • 10 comments

This is a small feature request.

Currently the plugin does not work out of the box with the bytedeco/javacpp-presets on mac.

For example, the opencv bindings are published for different architectures

http://search.maven.org/#search%7Cga%7C1%7Corg.bytedeco.javacpp-presets%20opencv

MacOs is refered to as macosx-x86_64, whereas currently the plugin resolves mac to osx.

Is there some way to overwrite the detection, such that no additional handling of this case is needed and one can simply write

<dependency>
   <groupId>org.bytedeco.javacpp-presets</groupId>
   <artifactId>opencv</artifactId>
   <classifier>${os.detected.classifier}</classifier>
</dependency>

jkirsch avatar Mar 07 '16 16:03 jkirsch

Sounds like a good idea. Will try to find some time.

trustin avatar Jun 22 '16 00:06 trustin

@trustin I am currently running into a similar issue. Is there any known workaround for this issue?

bin01 avatar Apr 17 '17 20:04 bin01

Be careful here. Other projects have used the value of 'osx' instead of 'macosx' when publishing classifiers to maven central. Google's protoc for example uses the 'osx' classifier. This will need a configuration property or something for backwards compatibility.

taftster avatar Jun 02 '17 00:06 taftster

any news?

RobertoUa avatar Dec 27 '18 16:12 RobertoUa

What do you think about letting a user create a file (.os-mappings.json in project root) that contains something like this:

{
  "copiedProperties": [
    {
      "src": "os.detected.name",
      "dest": "os.detected.name.alternative",
      "replacements": {
        "osx": "macos"
      }
    },
    {
      "src": "os.detected.arch",
      "dest": "os.detected.arch", // overwrite
      "replacements": {
        "s390_32": "s390",
        "s390_64": "s390x"
      }
    }
  ],
  "additionalProperties": {
    "os.detected.classifier.alternative": "${os.detected.name.alternative}-${os.detected.arch}",
    "myCustomProp": "foobar"
  }
}

Then, a user could use ${os.detected.classifier.alternative} for the dependencies with a macos-* classifier.

trustin avatar Feb 06 '21 06:02 trustin

Would this custom mappings file allow a developer to pull dependencies from classifiers that were BOTH 'osx' and 'macosx' in their pom? I think that's the minimum requirement. Something like this should be possible:

<!-- uses original 'osx' value -->
<dependency>
  <groupId>com.google.protobuf</groupId>
  <artifactId>protoc</artifactId>
  <classifier>${os.detected.classifier}</classifier>
</dependency>

<!-- uses alternative 'macosx' value -->
<dependency>
  <groupId>org.bytedeco.javacpp-presets</groupId>
  <artifactId>opencv</artifactId>  
  <classifier>${os.detected.classifier.alternative}</classifier>
</dependency>

For extra credit, hypothetically what if there were three or more distinct values for classifier? Can this solution produce those variants? Maybe we need something like: ${os.detected.classifier.alternative.1} and ${os.detected.classifier.alternative.2} etc.?

taftster avatar Feb 06 '21 17:02 taftster

Would this custom mappings file allow a developer to pull dependencies from classifiers that were BOTH 'osx' and 'macosx' in their pom? I think that's the minimum requirement.

Yeah, that's what the example .json file tries to show.

For extra credit, hypothetically what if there were three or more distinct values for classifier?

Yeah, something like this:

{
  "copiedProperties": [
    {
      "src": "os.detected.name",
      "dest": "os.detected.name.alternative.1",
      "replacements": {
        "osx": "macos"
      }
    },
    {
      "src": "os.detected.name",
      "dest": "os.detected.name.alternative.2",
      "replacements": {
        "osx": "apple"
      }
    }
  ]
}

trustin avatar Feb 07 '21 04:02 trustin

Perfect. Seems like a really nice solution then! +1 Thanks for the explanation.

taftster avatar Feb 07 '21 07:02 taftster

any news?

juzi214032 avatar Jan 05 '22 05:01 juzi214032

What do you think about letting a user create a file (.os-mappings.json in project root) that contains something like this:

{
  "copiedProperties": [
    {
      "src": "os.detected.name",
      "dest": "os.detected.name.alternative",
      "replacements": {
        "osx": "macos"
      }
    },
    {
      "src": "os.detected.arch",
      "dest": "os.detected.arch", // overwrite
      "replacements": {
        "s390_32": "s390",
        "s390_64": "s390x"
      }
    }
  ],
  "additionalProperties": {
    "os.detected.classifier.alternative": "${os.detected.name.alternative}-${os.detected.arch}",
    "myCustomProp": "foobar"
  }
}

Then, a user could use ${os.detected.classifier.alternative} for the dependencies with a macos-* classifier.

I create .os-mappings.json in project root, but it's doesn't work

vin188 avatar Sep 06 '22 02:09 vin188