Comment From: philwebb
I'd been thinking about the layers configuration during the design of the API. Its unfortunately really hard to come up with a logic way to do it. I was originally thinking that we could define the layers in the oder that they should appear and define the items that they capture. For example:
<layers>
<layer>
<name>my-libs</name>
<libs>
<lib>org.acme:my-lib:*</lib>
</libs>
...
</layer>
</layers>
The problem with this approach is it's quite hard to define catch-all patterns that are out of order. For example, if we want to recreate ImplicitLayerResolver
in config it's quite hard. We want the dependencies
layer above the snapshot-dependencies
but we want it to contain anything that the snapshot-dependencies
doesn't capture.
The best option I could come up with is to define the layer names and their order separately from the pattern matching config.
<layer-config>
<layers>
<layer>dependencies</layer>
<layer>snapshot-dependencies</layer>
<layer>resources</layer>
<layer>application</layer>
</layers>
<contents>
<content>
<libraries>
<library>*:*:*SNAPSHOT</library>
</libraries>
<destination>snapshot-dependencies</destination>
</content>
<content>
<libraries>
<library>*:*:*</library>
</libraries>
<destination>dependencies</destination>
</content>
<content>
<resources>
<resource>static/*</resource>
</resources>
<destination>resources</destination>
</content>
<!-- anything not caught ends up in the last layer -->
</contents>
</layer-config>
I'm not totally convinced that this isn't too confusing, but I'm not sure how else we can support complex matching rules.
Comment From: snicoll
The more I think of it and the more I find some analogy with the maven-assembly-plugin
. The Maven dev team decided to go for an external descriptor which has several advantages.
A separate XML file tailored for layering can have a dedicated XSD with documentation. Maven is pretty limited with regards to documenting complex POJO structure (and I doubt that all IDEs have the same level of support in auto-completion).
The assembly plugin also has a concept of predefined descriptors that would match with opinions in terms of layering.
Comment From: mbhave
Regarding the ordering of the layers, I wonder if there's a way to have an optional configuration option that lets you define the order if is is different from the order that they were defined in <layers>
.
Comment From: wilkinsona
<layers>
<layer>dependencies</layer>
<layer>snapshot-dependencies</layer>
<layer>resources</layer>
<layer>application</layer>
</layers>
I find this ordering confusing. I'd expect the layers to be listed from most to least frequently changing but the above is the reverse of that. In other words, I think of the layers as a representation of what the image will look like, rather than a representation of the order in which they'll be written.