-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exported XML should contain version of abandon #112
Conversation
Move generated BuildInfo.scala to co.uproot.abandon Add version xml elements to Journal and Balance exports with the version from BuildInfo.scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @alexanderzafirov, thanks!
Have a couple of comments.
|
||
import scala.Predef._ | ||
|
||
/** This object was generated by sbt-buildinfo. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexanderzafirov This generated file should not be checked in to the repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused. How are we going to reference the file when it is not being tracked by Git?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it generated automatically on compilation? I thought that is how the plugin worked but I maybe wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is. The problem is that I manually moved it from the main target
folder to where it resides now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umm.. the point of this issue is to automate the version numbering. Developers will only update the sbt file when the version number increases, and the application will automatically pick up the version number when emitting to the XML file, etc.
If there is any manual step, then it defeats the purpose.
I suggest you verify whether the manual step is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood.
@@ -252,6 +252,9 @@ object Reports { | |||
|
|||
def xmlBalanceExport(state: AppState, exportSettings: XmlExportSettings): xml.Node = { | |||
<abandon> | |||
<version> | |||
{ BuildInfo.version } | |||
</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to keep it on one line and no extra spaces, for example:
<version>{BuildInfo.version}</version>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I just followed the "convention" from the lines below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the spaces. For readability's sake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a leaf node, then it is better to not have spaces. It will be easy for the application which is reading the XML file to parse the text content.
Actually, you could even make version
an attribute of the abandon
node. No need for a separate node.
If a node is a "structural node" with child nodes, then spacing and indentation makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, I didn't realize that the spaces in the curly braces are actual spaces in the generated xml.
I actually though of landing version
as an attribute to abandon
but for some reason decided to be more straightforward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize that the spaces in the curly braces are actual spaces in the generated xml.
They are not; you can keep them. I thought you were referring to spaces between the XML tag and the scala code; those are significant; hence need to be removed.
Sorry for the confusion.
👍 for attribute.
@@ -260,6 +263,9 @@ object Reports { | |||
|
|||
def xmlJournalExport(state: AppState, exportSettings: XmlExportSettings): xml.Node = { | |||
<abandon> | |||
<version> | |||
{ BuildInfo.version } | |||
</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: would be better to keep it on one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
fork in run := true | ||
fork in run := true, | ||
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion), | ||
buildInfoPackage := "build.info" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By looking at the rest of the code, shouldn't buildInfoPackage
be co.uproot.abandon
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it makes sense. I just want to note that BuildInfo
is generated in the target folder.
@alexanderzafirov the tests are failing. This is probably because they are checking for an exact match of the generated xml. We need to either:
I think last option (config property) is best. |
Thanks for the comments, @hrj! |
The CLI tests (which are failing) run the whole application. They don't call the internal methods directly. So the parameter has to be either a command line option (passed via |
Got it. I will implement the necessary fixes and ping you for review later! |
Add new command line parameter Add parameter to differentiate between versioned xml and nonversioned one Start to fix tests Make client xml code compile
</balance> | ||
</abandon> | ||
def xmlBalanceExport(state: AppState, exportSettings: XmlExportSettings, withVersion: Boolean): xml.Node = { | ||
if (withVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid duplicating the code, you can add the version
attribute after creating the abandon
node normally.
Example code to add an attribute to an Element:
def addAttrib(n: Elem, k: String, v: String) = n % new xml.UnprefixedAttribute(k, v, xml.Null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @hrj. I was away for a couple of days and didn't want to have the changes laying around so I pushed them to the branch. I was definitely looking for a better implementation and your suggestion is great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, except for the default.
thanks 👍
</journal> | ||
</abandon> | ||
def xmlJournalExport(state: AppState, exportSettings: XmlExportSettings, withVersion: Boolean): xml.Node = { | ||
if (withVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as before: avoid duplicating the code.
@@ -36,9 +36,10 @@ object SettingsHelper { | |||
val cliConf = new AbandonCLIConf(args) | |||
cliConf.verify() | |||
val configOpt = cliConf.config.toOption | |||
val withVersion = cliConf.version.getOrElse(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default here should be true
I think.
That is, for normal usage, the version should be shown in the output. It is only the tests that have a problem with it, and hence they should explicitly disable it.
Set default value of versioned to be true Set the versioned value for cli test to false
@hrj Tests are happy now. I did a bit of rewording of the variables since the Boolean switches give you true if added. At the same time we want to have version added by default. Please let me know if you are happy with the outcome. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Closes #105
Update sbt to incorporate sbt-buildinfo plugin
Move generated BuildInfo.scala to co.uproot.abandon
Add version xml elements to Journal and Balance exports with the version from BuildInfo.scala