Skip to content

Provide a way to customize layers with the Maven plugin #20295

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

Closed
mbhave opened this issue Feb 21, 2020 · 4 comments
Closed

Provide a way to customize layers with the Maven plugin #20295

mbhave opened this issue Feb 21, 2020 · 4 comments
Assignees
Labels
Milestone

Comments

@mbhave
Copy link
Contributor

mbhave commented Feb 21, 2020

No description provided.

@philwebb
Copy link
Member

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.

@snicoll
Copy link
Member

snicoll commented Feb 26, 2020

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.

@mbhave
Copy link
Contributor Author

mbhave commented Feb 26, 2020

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>.

@wilkinsona
Copy link
Member

wilkinsona commented Feb 27, 2020

<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.

@mbhave mbhave self-assigned this Feb 27, 2020
@wilkinsona wilkinsona modified the milestones: 2.3.x, 2.3.0.M3 Mar 12, 2020
@snicoll snicoll self-assigned this Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants