clinical_quality_language icon indicating copy to clipboard operation
clinical_quality_language copied to clipboard

translatorVersion comes from the Manifest.MF which Android repackages

Open vitorpamplona opened this issue 2 years ago • 2 comments

The LibraryBuilder assigns the translatorVersion as the Implementation-Version text in the Manifast.MF.

https://github.com/cqframework/clinical_quality_language/blob/932c84a041ea8f78a9717d1d4eb9612a1ec3e0ad/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/LibraryBuilder.java#L69

So, for the current Manifest.MF

Manifest-Version: 1.0
Implementation-Title: cql-to-elm
Implementation-Version: 2.1.0
Specification-Title: HL7 Clinical Quality Language (CQL)
Specification-Version: 1.5.2

the XML/JSON export would include "2.1.0" in the CqlToElmInfo.translatorVersion annotation.

A few limitations of this technique:

  • translatorVersion is not available on test cases of this library. The Manifest.MF does not exist yet.
  • Android repackages the lib and deletes the Manifest.MF file. The exported version from Android will be the version of the app or "0.0" if not defined.

Potential Solutions:

  1. Use a code generation step to create a BuildConfig class and hardcode the version inside of it.

vitorpamplona avatar Sep 13 '22 19:09 vitorpamplona

This is the standard way to convey version information within the Java ecosystem: https://docs.oracle.com/javase/10/docs/specs/jar/jar.html

Several downstream projects are already dependent upon this behavior to detect the cql translator version used.

Rather than discarding the manifest, the Android build ought to merge it. The Manifest.mf specification allows per-entry (i.e. per package) attributes that override the main attributes. See the "per-entry" section of the specification I linked above. This will allow the correct translator (and cql-engine and cql-evaluator) version to be detected at runtime from a single master manifest.mf file. Android may also have facilities to make it possible to merge that into the Android app XML manifest, I'm not sure.

The test cases ought not to depend on the translator version. I get that that's a challenge right now because we're doing string comparisons. Maybe we provide a way to not include version information at all.

JPercival avatar Sep 13 '22 19:09 JPercival

Interesting.. so, Android doesn't merge Manifests at all. And I am not sure if a merge would work. The current manifest doesn't include name and package properties so that the JVM can appropriately link each package with its versions.

vitorpamplona avatar Sep 13 '22 20:09 vitorpamplona

Closing as wontfix given that we are compliant with the Java guidelines: https://docs.oracle.com/javase/10/docs/api/java/lang/Package.html https://docs.oracle.com/javase/10/docs/specs/jar/jar.html

JPercival avatar Jan 18 '24 03:01 JPercival