question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filter project contributors on the classpath

See original GitHub issue

Is there any way to tweak/override/disable out-of-the-box @ProjectGenerationConfigurations ?

They are not loaded as auto-config-beans, but with spring.factories (via ProjectGenerator$CoreConfiguration). I can’t see any way to filter or customize these ?

I could try to provide my own ProjectGenerationInvoker bean (overriding the default bean from InitializrAutoConfiguration) and set up my own ProjectGenerator, but the interface requires me to construct a ProjectGenerationResult which has a package-private constructor.

Am I missing something or is this just not supported ? Yet ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
wilkinsonacommented, Nov 12, 2020

I wonder if we could do this by allowing some control over the configuration class that’s registered when creating the project generation context:

https://github.com/spring-io/initializr/blob/e97233b1077407661660925e7b5383a7ae972736/initializr-generator/src/main/java/io/spring/initializr/generator/project/ProjectGenerator.java#L107-L109

CoreConfiguration does nothing other than pulling in an ImportSelector that imports all of the ProjectGenerationConfiguration classes registered in spring.factories. Allowing CoreConfiguration to be replaced would allow a different import selector to be used. This different selector could use spring.factories and filter the registrations or it could implement a different registration mechanism entirely.

There are a few different way that this customisation could be enabled. We could make it the responsibility of the ContextCustomizer, we could pass something in as a new type, or we could perhaps provide a protected method that can be overridden.

1reaction
snicollcommented, Oct 21, 2020

perhaps contributors can be conditionally enabled via ConditionalOnProperty annotations, much like how actuator endpoints or health actuator contributors are turned on/off. This will allow control over each ProjectContributor and is not drastic enough to block or cause trouble for future enhancements. What do you think?

We thought of that as it would be a natural move with regards to what you can find in Spring Boot. We’ve ruled it out with the current infrastructure as we don’t have any way to debug this (similar to the auto-configuration report and the actuator endpoint). It is also something that can be a bit involved if you want to get this done per request or globally.

The initializr-generator-spring would only autoconfigure such apis (instead of defining them + autoconfigure them).

This is a valid idea but I am not keen to do such a split at this level. The module with the @ProjectGenerationConfiguration would be a shell and the surface area is too small to warrant such work IMO. I’d like to explore how a ProjectGenerator can filter those upfront but I haven’t had the time to look at a solution yet, sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ClassGraph, how to filter the classpath's content - java
I try to find the runtime classpath using ClassGraph: String classpath = new ClassGraph().getClasspath();. The classpath content looks as ...
Read more >
Diff. btw jars in contributors,filters,library dependencies,in ...
Diff. btw jars in contributors,filters,library dependencies,in JDev 11g · 1. Application tab -> Project Properties -> Libraries and classpath · 2.
Read more >
Application discovery via the classpath - Apache TomEE
This document details the various ways to get OpenEJB to detect applications you would like deployed while in an embedded mode.
Read more >
Eclipse Buildship: Eclipse Plug-ins for Gradle 2.2.0
If the project uses Gradle 4.4 or newer then all source directories and binary ... Buildship then filters elements from the runtime classpath...
Read more >
“How-to” Guides - Spring
You can automatically expand properties from the Maven project by using resource filtering. If you use the spring-boot-starter-parent ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found