Having issues pulling in buildInfo in autoconfig as gradle is placing buildInfo in BOOT-INF with a META-INF rather than using the root META-INF

buildInfo-error

I just ran across it and have a working example and screenshot.

Am not using a GUI/IDE or devops for builds... purely shell.

Code for testing can be found here: https://github.com/orubel/spring-boot-starter-beapi

Your help on this is greatly appreciated and I apologize ahead of time if this is something that is better sent to stackoverflow.

Comment From: snicoll

This appears to be referenced in #23620 with Maven and was marked invalid

I am not following. That related issue was about not generating the file at all, not generating it in the wrong place (as I understand from your description).

Code for testing can be found here:

Thanks for sharing a sample but it doesn't build for me:

* What went wrong:
Execution failed for task ':beapi-spring-boot-autoconfigure:compileGroovy'.
> Could not resolve all files for configuration ':beapi-spring-boot-autoconfigure:compileClasspath'.
   > Could not find io.beapi:beapi-lib:0.4.
     Searched in the following locations:
       - https://jcenter.bintray.com/io/beapi/beapi-lib/0.4/beapi-lib-0.4.pom
       - file:/Users/snicoll/.m2/repository/io/beapi/beapi-lib/0.4/beapi-lib-0.4.pom
       - file:/Users/snicoll/.m2/repository/io/beapi/beapi-lib/0.4/beapi-lib-0.4.jar
       - https://repo.maven.apache.org/maven2/io/beapi/beapi-lib/0.4/beapi-lib-0.4.pom
     Required by:
         project :beapi-spring-boot-autoconfigure

Back to the problem, BOOT-INF is used for applications (when the repackager is kicking off), and the repackager shouldn't be used at all for libraries. Can you please clarify what "Having issues pulling in buildInfo in autoconfig" means?

Comment From: orubel

Can you please clarify what "Having issues pulling in buildInfo in autoconfig" means?

My apologies. Left in old lib... just fixed.

Well I am trying to create a BuildProperties bean in the autoconfiguration to share the application properties (ie version etc) with the autoconfigurations and other beans

I guess my question is: am I reading that from JAR (because that one is in BOOT-INF)? The build is SHOWING it being in 'demo-application/build/resources/main/META-INF/build-info.properties' but in the JAR it gets put into 'BOOT-INF'

All documentation I can see says this is supposed to be read from META-INF and I have this in BOOT-INF so am wondering if this is bug.

And I apologize again if I am wasting your time; am trying to read documentation and examples before ever coming here.

Comment From: philwebb

Spring Boot fat jars have a special layout that allows us to embed nested jars and classes into a single executable. The format is documented a little bit here but it doesn't go into all the details.

We're trying to take inspiration from the war format where there's a WEB-INF/lib and WEB-INF/classes folder. In our case BOOT-INF/classes contains all the user defined code. When the fat jar is launched we use some custom URL Handler and ClassLoader tricks to bootstrap things. That should mean that you can do ClassLoader.getResourceAsStream("META-INF/build-info.properties") from your app and it will find BOOT-INF/classes/META-INF/build-info.properties transparently.

I guess my question is: am I reading that from JAR (because that one is in BOOT-INF)? The build is SHOWING it being in 'demo-application/build/resources/main/META-INF/build-info.properties' but in the JAR it gets put into 'BOOT-INF'

This is by design. Gradle is copying the resource to build/resources/main/META-INF/build-info.properties but when we create the packaged jar we move it to BOOT-INF/classes.

Comment From: orubel

thank you for the correction. Found a good test for that for people spotting my egregious error in the future : https://stackoverflow.com/questions/45758528/how-to-load-a-properties-file-from-the-meta-inf-directory