Comments (7)
The section in the end was named 'vars' rather than 'globals' in the end, according to Iulian's original request in #40. That was also because configuration files may end up being nested into one another, in the future, therefore 'globals' would not be an accurate description in that case. The fix for #40 does preserve the overall schema checking in the configuration file, whereas the initial hack was just disabling schema checking altogether. The fix works by specifying a custom deserializer that simply skips over the 'vars' section, while the rest is processed as normal by the jacks/jackson libraries (mostly using reflection).
It is possible to "smuggle" inside properties in a number of ways. Normally, when you define them as bash vars for instance, they are expanded in the config file directly when the Typesafe config library loads the configuration file, and the same happens for java properties. That all happens in the line:
readValue[DBuildConfiguration](configFile)
in SbtBuildMain.scala; the implementation of readValue is:
def readValue[T](f: File)(implicit m: Manifest[T]) = readValueT[T](parseFile(f))
where the parseFile is the call to the config library that reads the file and expands all the vars, converting all to a single string. Then, the subsequent readValueT performs the actual JSON parsing.
There are various ways in which loading a properties file can be accomplished. The first would be to add some code before the readValue() that loads the properties file and manually adds properties to the System properties beforehand. This is a bit undesirable, as it would pollute the system properties unnecessarily.
Another way could be to load the properties file(s), and then "merge" them together with the original loaded configuration by using the typesafe config's API, either using the properties as-is, or by lifting them and adding the 'vars' prefix.
The properties file(s) could be specified by either using a command line option, or as an additional option in the top-level 'options' section of the config file. I am trying to store the entire configuration in the config file, therefore the second approach would be preferable.
In the first case, the option would have to be introduced via an option introduced by a flag; however, there is no command line option parsing code in dbuild, at this time.
The second case is better, but it involves a bit of a catch-22: the readValueT can only be performed once the config is complete, but in order to extract the properties file path from the config file it is usually necessary to run readValueT on it first. We could be 'cheating' by hardcoding the relevant option path, and loading it manually by using the typesafe config library (rather than using the JSON parsing code), right after the config file is loaded. I would have to think whether a cleaner approach is possible.
It can be done, it just involves a bit of work; I'll be happy to work on it. If you need this soon, I can work on it now for inclusion in the next upcoming release of dbuild (due soon).
from dbuild.
It would be very handy to have something like this, as we're already seeing the pain of keeping all the version numbers in synch, as well as parsing the properties file in bash, exporting to environment variables, and importing those again in the builds. If we could standardize on property names across builds, it would be a lot nicer. It's not a must-have, though -- I can work around it in the jenkins scripts.
from dbuild.
Also, thanks for the thorough explanation! One thing that occurred to me is that repeatable builds are important, so we should only read property files from git repos, so that the sha of the commit determines the content of the property file.
from dbuild.
I already have most of the code in place, a pull request should follow soon. The repeatable build data is only generated after all the expansions have already taken place, both concerning the environment variables as well as the conversion of branches/tags to fixed commits. Therefore the place where the properties are coming from does not affect repeatability.
Conversely, the vars expansion takes place at the very beginning in the code: we need to have everything expanded early. By the time we get to looking into the git repositories, the configuration file has already been processed and expanded, so it is too late. The properties files need to be accessible when dbuild starts.
However, to ease the pain, I can offer access to properties files via an arbitrary URL (which can also be built using environment variables). So you only need to set a tag/branch env var from bash, and you can then use that to denote within the config file the URL on github where the properties file is located, as well as the URL of the corresponding git repo. Would that work?
from dbuild.
Pull request #73 contains the relevant patch. Please let me know if any additional changes are needed.
from dbuild.
Perfect! The properties file is already available, so no need for getting it from git. Your explanation re: repeatable builds makes sense. I'll try it out tomorrow! BTW, are there nightly builds of dbuild? I don't mind building my own -- just wondering :-)
from dbuild.
I'll publish a test version later today; stay tuned. :)
from dbuild.
Related Issues (20)
- Support test:compile only without test:test HOT 5
- sbt 0.13 compatibility (avoid deprecated operators) HOT 3
- support Scala.js HOT 9
- Print out scope terser HOT 5
- 0.9.9 not tagged? HOT 3
- Add support for the "override" Bintray option
- Take "skip in publish" into account
- drepo broken since 0.9.7 HOT 2
- drop support for "assemble" build system? HOT 2
- support shallow cloning of repositories? HOT 2
- can I skip re-fetching of the repos? HOT 9
- Support patterns in exclude/include subprojects HOT 5
- sbt 1.2 support HOT 10
- sbt 1.2.1 support HOT 4
- Enable Git Wire Protocol v2 HOT 1
- Migrate publishing off of Bintray HOT 6
- Resolve scala-xml version conflict (1.x vs 2.x) with sbt 1.8.0 HOT 8
- get the website publishing again HOT 1
- CI sometimes fails in `dist/*:deliverLocal` HOT 1
- Default stack size is too low and not configurable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbuild.