Tobias Roeser
unread,Mar 26, 2014, 11:02:04 AM3/26/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sbuil...@googlegroups.com
Hello folks,
let me share some idea I have for a long time. I really like to get your
thoughts or veto or support for it.
Motivation:
On (larger) projects, you often want to share some project settings, like
compiler settings, dependencies, plugins, version numbers between all (or
some) modules. Today, this is possible with the @include annotation. But that
approach has some disadvantages:
- You can not share script dependencies which you would typically add with
@classpath in each project file
- You have to provide all dependencies of the included file via @classpath, in
each module that uses the includes file
- You have to program extra "boilerplate" to apply some functionality of the
included file to the project.
The Feature:
Let me introduce the `@defaults` annotation, to fix these shortcommings and to
add some additional advantages.
I essence, I want to annotate a project with an additional annotation
`@defaults("Defaults.scala")` pointing to another scala resource (e.g.
Defaults.scala). This file will be compiled and somehow applied to the project
before the project class itself (SBuild.scala) is applied. Thus it will be
able to configure the project. That configuration will be available very early
and will even influence the scheme handlers available in the @classpath and
@include annotations of the project.
The "Defaults.scala" class itself will look pretty much the same as an project
buildfile, beside the class name.
As I alread started to convert all current default scheme handler into
plugins, it will be very easily to configure thoose over the Plugin API. E.g.
it would be easy to configure the "mvn:" scheme to use additional remote
repositories or to add an "https:" scheme handler containing some pre-
authentication to a dedicated corporate server. I general, a lot more use
cases might show up, once this feature is implemented.
I also pretty much like the idea of a second boolean "replace" parameter in
the @defaults annotation. If it is `true`, the given Defaults files will
disable the built-in defaults (but it will itself use theses previous
defaults). The default would be to not replace (but extend) the defaults.
Technically, there is no reason, why a Defaults project shouldn't itself be
able to use a defaults file itself, but of course this might leed to hard to
grasp project setups, so I tend to disable that ability.
I'm not that sure, if the internal state of the Defaults file should be keept
in the same directory (which means, that it can be shared) or if that state is
keept in the project using it (no shared state and each project needs to
compile that include file itself) or if this should be configurable, too, e.g.
with a `@shared` annotation on that class.
I hope you got an idea of the planned concept. Any feedback is much
appreciated! If something is not clear, I'd be glad to clarify, just ask.
Best regards,
Tobias