Exclude additional-spring-configuration-metadata.json from the jars.
This file is not required.
Comment From: bclozel
This file is packaged with your project to provide additional information to developers when working with your library, as explained in our reference documentation.
Not packaging it with the library would make that file useless.
Comment From: bclozel
@wilkinsona pointed out that this information is indeed merged in the main metadata file.
I’m not sure how we can prevent this file from being packaged with the library. Is there anything we can do here? Maybe document how to filter out this file in the build?
Comment From: wangliang181230
Can put the additional-spring-configuration-metadata.json in the src/main/xxx directory? Not the /src/main/resources/META-INF directory.
Comment From: wangliang181230
Outside the /src/main/resources directory, I think it will not be packaged into the library.
Comment From: bclozel
I'm not sure the annotation processor will be able to find these files if they're not shipped as resources.
Comment From: wangliang181230
Can the Maven plugin merge the metadata?
Comment From: wangliang181230
@bclozel The maven-jar-plugin can exclude additional, and is merged to the main metadata.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<excludes>
<exclude>**/META-INF/additional-spring-configuration-metadata.json</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
Comment From: snicoll
@wangliang181230 using the maven plugin to process the metadata would significantly decrease the developer experience. Using an annotation processor for this is the right call IMO and we really need the additional file to be on the classpath to process it. You are right that the file is, strictly speaking for Spring Boot, not used at runtime but I wouldn't be surprised if third party tools were relying on it. Configuring the maven-jar-plugin is one option if you really care about the duplicate.
Flagging for team attention to get more feedback from the team.
Comment From: wilkinsona
I think it would be nice to avoid bundling the additional metadata file by default if we can.
It would be straightforward in our own build, but I'm not sure it's possible to do it automatically for users while using a location beneath src/main/resources. They could be building a shared module without our Maven or Gradle plugins so we don't have a chance to filter things.
The only other option that I can think of is to use a location outside src/main/resources for the metadata as suggested above. I wonder about the additional complexity of this, though, and the possible impact on up-to-date checks and incremental compilation with Gradle.
Comment From: wilkinsona
We're going to update the Maven and Gradle plugins to filter out the file automatically. We'll also update the documentation to suggest that anyone building a library without our plugins configures their build to do the same.