Merging Spring Boot Factories

717 views
Skip to first unread message

ben.n...@gmail.com

unread,
Jul 27, 2017, 2:29:44 AM7/27/17
to bazel-dev
Spring Boot loads a number of factories (primarily, auto-configuration classes) from META-INF/spring.factories. Currently, that file doesn't get merged when building a deployment jar, so Spring Boot apps built with Bazel won't start up. Currently, DefaultJarEntryFilter has cases for other Spring configuration files, so I think Spring Boot support is reasonable.

I'd like to add a SpringFactoriesStrategy custom merge strategy that would parse the spring.factories property files and merge them all together. The format is just a properties file where keys are the factory interface class and values are comma-separated classes implementing the interface. I think I've seen other libraries use the same format, so maybe it could be generalized beyond Spring.

Any objections or thoughts? I can do some prototyping and submit a PR :)

Ulf Adams

unread,
Jul 27, 2017, 6:01:12 AM7/27/17
to ben.n...@gmail.com, bazel-dev
Well, it's unfortunate that we have to parse a bunch of disparate formats to support jar merging, but I don't really see any other option, unless Spring Boots wants to migrate to the META-INF/services/ 'standard' format?

--
You received this message because you are subscribed to the Google Groups "bazel-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-dev+unsubscribe@googlegroups.com.
To post to this group, send email to baze...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-dev/718a9b72-f10e-46ac-8ed5-bbdecec69839%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philipp Wollermann

unread,
Jul 27, 2017, 7:18:58 AM7/27/17
to Ulf Adams, ben.n...@gmail.com, bazel-dev
Please note that we have a newer implementation of SingleJar written in C++, which is used everywhere except on Windows (but will be used there, once #2241 is fixed):



For more options, visit https://groups.google.com/d/optout.



--
Google Germany GmbH
Erika-Mann-Straße 33
80636 München

Geschäftsführer: Matthew Scott Sucherman, Paul Terrence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Ben Navetta

unread,
Jul 27, 2017, 11:31:26 AM7/27/17
to Philipp Wollermann, Ulf Adams, bazel-dev
Yeah, I can give it a shot. Offhand, do you know if bazel has any C++ utilities for properties file parsing?
On Thu, Jul 27, 2017 at 4:18 AM 'Philipp Wollermann' via bazel-dev <baze...@googlegroups.com> wrote:
Please note that we have a newer implementation of SingleJar written in C++, which is used everywhere except on Windows (but will be used there, once #2241 is fixed):


On Thu, Jul 27, 2017 at 12:01 PM, 'Ulf Adams' via bazel-dev <baze...@googlegroups.com> wrote:
Well, it's unfortunate that we have to parse a bunch of disparate formats to support jar merging, but I don't really see any other option, unless Spring Boots wants to migrate to the META-INF/services/ 'standard' format?
On Thu, Jul 27, 2017 at 2:29 AM, <ben.n...@gmail.com> wrote:
Spring Boot loads a number of factories (primarily, auto-configuration classes) from META-INF/spring.factories. Currently, that file doesn't get merged when building a deployment jar, so Spring Boot apps built with Bazel won't start up. Currently, DefaultJarEntryFilter has cases for other Spring configuration files, so I think Spring Boot support is reasonable.

I'd like to add a SpringFactoriesStrategy custom merge strategy that would parse the spring.factories property files and merge them all together. The format is just a properties file where keys are the factory interface class and values are comma-separated classes implementing the interface. I think I've seen other libraries use the same format, so maybe it could be generalized beyond Spring.

Any objections or thoughts? I can do some prototyping and submit a PR :)

--
You received this message because you are subscribed to the Google Groups "bazel-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-dev+...@googlegroups.com.

To post to this group, send email to baze...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-dev/718a9b72-f10e-46ac-8ed5-bbdecec69839%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bazel-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-dev+...@googlegroups.com.

To post to this group, send email to baze...@googlegroups.com.



--
Google Germany GmbH
Erika-Mann-Straße 33
80636 München

Geschäftsführer: Matthew Scott Sucherman, Paul Terrence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

--
You received this message because you are subscribed to a topic in the Google Groups "bazel-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-dev/lOMq99O68d4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-dev+...@googlegroups.com.

To post to this group, send email to baze...@googlegroups.com.

Thiago Farina

unread,
Jul 27, 2017, 7:37:57 PM7/27/17
to Ben Navetta, Philipp Wollermann, Ulf Adams, bazel-dev
On Thu, Jul 27, 2017 at 12:31 PM, Ben Navetta <ben.n...@gmail.com> wrote:
Yeah, I can give it a shot. Offhand, do you know if bazel has any C++ utilities for properties file parsing?

Besides reading a file into a string, I would say 'no'. Which 'utilities for properties' do you have in mind?

Anything specific from Python, Java or Go?

--
Thiago Farina

ben.n...@gmail.com

unread,
Jul 28, 2017, 2:32:46 AM7/28/17
to bazel-dev, ben.n...@gmail.com, phi...@google.com, ulf...@google.com
Just a C++ equivalent to java.util.Properties. It's a pretty simple format, but if there's existing code in Bazel to parse a properties file, I may as well reuse it.

jk...@mobvoi.com

unread,
Nov 7, 2017, 5:10:58 AM11/7/17
to bazel-dev
Hi, have you submitted your PR? That could be really useful I think.

Peter Laird

unread,
Nov 7, 2017, 7:21:39 PM11/7/17
to bazel-dev
If that doesn't work out...

I have written a Skylark rule for Spring Boot. It is ready to go, but I need to get permission from my employer before open sourcing (in progress).
It avoids the merge problem by following the Boot maven plugin's layout (with nested BOOT-INF/lib jar files, which encapsulate the same-named files):

# /
# /META-INF/
# /META-INF/MANIFEST.MF                        <-- very specific manifest for Spring Boot (generated by this rule)
# /BOOT-INF
# /BOOT-INF/classes
# /BOOT-INF/classes/**/*.class                 <-- compiled application classes, must include @SpringBootApplication class
# /BOOT-INF/classes/META-INF/*                 <-- application level META-INF config files (e.g. spring.factories)
# /BOOT-INF/lib
# /BOOT-INF/lib/*.jar                          <-- all upstream transitive dependency jars must be here (except spring-boot-loader)
# /org/springframework/boot/loader
# /org/springframework/boot/loader/**/*.class  <-- the Spring Boot Loader classes must be here

Regards,
Peter Laird

mts...@gmail.com

unread,
Dec 1, 2017, 5:33:51 AM12/1/17
to bazel-dev
I am also trying to get spring boot working with Bazel. Any luck with getting employer approval for open sourcing the Skylark rule Peter?

Peter Laird

unread,
Dec 1, 2017, 1:58:07 PM12/1/17
to bazel-dev
I just removed all my samples from my repo, which should speed things up. The moment you package a Spring Boot app, you have a dependency on a large number of upstream OSS libs. By removing the samples, I just have the Bazel Skylark code which is a much smaller surface area to get approved. I have filled in the gap of not having samples with more documentation. Hoping for a week or two....

mat...@zaver.se

unread,
Dec 5, 2017, 7:49:50 AM12/5/17
to bazel-dev
That's awesome, and I would be so happy if you get it approved. Not that I actually want to use Spring, but swapping out the build system is higher priority for me than changing the webserver. :/

Ben Navetta

unread,
Dec 5, 2017, 10:17:46 AM12/5/17
to bazel-dev
This sounds awesome! I wasn't able to make much progress on the PR
--
You received this message because you are subscribed to a topic in the Google Groups "bazel-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-dev/lOMq99O68d4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-dev+...@googlegroups.com.
To post to this group, send email to baze...@googlegroups.com.

mat...@zaver.se

unread,
Dec 20, 2017, 6:35:49 PM12/20/17
to bazel-dev
Has anyone tried the seemingly new springboot rules by salesforce? I tried it with partial success, but my maven project has lots of dependencies, and might take while to sort out.

jk...@mobvoi.com

unread,
Jan 1, 2018, 5:17:04 AM1/1/18
to bazel-dev
I think your repo on the github should work. Will give more feedback after applying this rule on our production systems.

Thanks so much.

rajesh....@gmail.com

unread,
Sep 12, 2018, 3:06:36 AM9/12/18
to bazel-dev
could you send me sample project Bazel+SpringBoot if you implemented so small demo will be fine

Kumar Rajesh

unread,
Sep 12, 2018, 3:09:51 AM9/12/18
to baze...@googlegroups.com
I just started with Bazel one api(spring boot implementatio) call that give me response json will be fine

--
You received this message because you are subscribed to a topic in the Google Groups "bazel-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-dev/lOMq99O68d4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-dev+...@googlegroups.com.
To post to this group, send email to baze...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages