unitsofmeasurement / indriya

JSR 385 - Reference Implementation
Other
118 stars 40 forks source link

adds support for relative quantity multiplication #290

Closed andi-huber closed 4 years ago

andi-huber commented 4 years ago

solves #247

implemented according to https://github.com/unitsofmeasurement/unit-api/wiki/Arithmetic-rules-for-Difference-versus-Absolute-quantities


This change is Reviewable

keilw commented 4 years ago

@andi-huber Unfortunately you introduced a bug here because Optional.isEmpty() did not exist before Java 9 ;-/ I moved the latest version of AbstractConverter, AbstractQuantity and others to the jdk9 multi-release codebase, if you find a way to backport it to Java 8 please to. I have not explored any multi-release tests, therefore no JUnit tests for Java 9 or 14 specific features.

andi-huber commented 4 years ago

Uups sorry for that. I should be able to do a new revision next week.

keilw commented 4 years ago

Yeah it's worse, it was introduced in Java 11, so have to isolate the changes into the Java 12 release codebase. I don't know why the heck they even bothered with that isEmpty(), you should be able to fix it by using !isPresent() ;-)

andi-huber commented 4 years ago

How do I verify on my end, that the maven multi jar build works. Do I just call mvn clean install or anything else?

andi-huber commented 4 years ago

Doing mvn clean install I'm getting

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:3.0.0:toolchain (default) on project indriya: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ version='[8,)' ]
[ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.

Which suggests there is something missing in my local ~/.m2/toolchains.xml

andi-huber commented 4 years ago

Ok, all I needed to know seems to be defined in .circleci/config.yml. Think I understand how to do a multi jar build now locally.

keilw commented 4 years ago

Cool, if you use Toolchain, also don't forget to include that. I came across a strange behavior and created a tiny example project, maybe won't share it on the uom organization but at least in Eclipse it almost feels like in a Java 12 project with true "multi release" JAR feature (meaning more than just 2) accidentally picks only the META-INF/versions/14 instead of 12, at least that's what I see in Eclipse. I did that without Maven in Eclipse or IntelliJ only, the behavior is the same, the Java 12 class NumberFormatStyle is not found although it's in the JAR.