ThePrez / ServiceCommander-IBMi

Service Commander for IBM i
Apache License 2.0
41 stars 13 forks source link

[BUG]New option --version displays "ERROR: Unknown version!" #144

Closed chrjorgensen closed 2 years ago

chrjorgensen commented 2 years ago

Describe the bug

The new option --version does not work correctly.

To Reproduce

I checked out the latest main branch from this repository and ran make install followed by sc --version. This resulted in the following output: Screenshot from 2022-03-23 00-43-32

Expected behavior

The command should print the current version, not "Unknown version!"...

Verbose output Run the command with the -v option and share the output here.

Same output with the '-v' option...

Additional context Add any other context about the problem here.

ThePrez commented 2 years ago

Thanks for reporting. That's actually working as designed. The version is only set during the RPM build. It is done like so:

The .spec file passes the RPM version to gmake: https://github.com/ThePrez/ServiceCommander-IBMi/blob/cdc136871feabfb10e9d22fe31f843462db11d7a/service-commander.spec#L40

And the Makefile passes it to Maven in the project.sc_version property: https://github.com/ThePrez/ServiceCommander-IBMi/blob/cdc136871feabfb10e9d22fe31f843462db11d7a/Makefile#L5

And the maven-replacer-plugin uses that to insert the version into the file: https://github.com/ThePrez/ServiceCommander-IBMi/blob/cdc136871feabfb10e9d22fe31f843462db11d7a/pom.xml#L60

The idea is that one wouldn't accidentally confuse a development build (for instance, someone did a git clone and make install on a system) for the production version.

There's definitely some room for improvement. A simple approach would mimic what I did for Ublu, and include a "vanilla" Version class: https://github.com/jwoehr/ublu/blob/main/src/main/java/ublu/Version.java

Alternatively, we could pass another property down through the .spec -> gmake -> mvn chain that indicates a production build.

chrjorgensen commented 2 years ago

Ha ha - my total lack of make and maven knowledge were caught in the spotlight... 😂

I like your approach used with Ublu - showing the version as DEVELOPMENT_BUILD - this shows that it is not an error, but instead intentional.

ThePrez commented 2 years ago

Proposing an even simpler approach (I think) in #146, that will even tell you if the dev build was built with Make or with mvn directly