Skip to content
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

additional-spring-configuration-metadata.json is not being merged when building with Gradle 4 #9732

Closed
dima767 opened this issue Jul 11, 2017 · 9 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@dima767
Copy link

dima767 commented Jul 11, 2017

Set up the simplest possible app according to the documentation wrt generating spring configuration metadata along with additional-spring-configuration-metadata.json for those additional "hints" to be merged into the main metadata file. It does not seem to work.

https://github.com/dima767/additional-config-metadata-not-working

Try ./gradlew clean build or ./gradlew clean bootRun

This is Boot 1.5.4 and Gradle 4.0

/cc @mmoayyed

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 11, 2017
@snicoll
Copy link
Member

snicoll commented Jul 12, 2017

For the record, this project does work with Gradle 3.x as far as I can see (and we don't support Gradle 4 officially in the 1.5.x line). I wonder if that's a regression in Gradle 4. Perhaps @wilkinsona knows?

@dima767
Copy link
Author

dima767 commented Jul 12, 2017 via email

@wilkinsona
Copy link
Member

The problem's caused by Gradle changing the output location of classes in Gradle 4. The output location of resources has not changed which means that we fail to find the additional metadata file relative to the classes location.

In Gradle < 4 the layout is like this:

app/build/
├── classes
│   └── main
│       └── com
│           └── example
│               └── SomeClass.class
├── resources
│   └── main
│       └── META-INF
│           └── additional-spring-configuration-metadata.json
└── tmp
    └── compileJava

With Gradle 4 it now looks like this:

app/build/
├── classes
│   └── java
│       └── main
│           └── com
│               └── example
│                   └── SomeClass.class
├── resources
│   └── main
│       └── META-INF
│           └── additional-spring-configuration-metadata.json
└── tmp
    └── compileJava

Note the new java directory beneath build/classes

@wilkinsona wilkinsona changed the title additional-spring-configuration-metadata.json is not being merged additional-spring-configuration-metadata.json is not being merged when building with Gradle 4 Jul 12, 2017
@snicoll snicoll changed the title additional-spring-configuration-metadata.json is not being merged when building with Gradle 4 Support additional-spring-configuration-metadata merging with Gradle 4 Jul 13, 2017
@snicoll snicoll added priority: high type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 13, 2017
@snicoll snicoll added this to the 2.0.0.M4 milestone Jul 13, 2017
@dima767
Copy link
Author

dima767 commented Jul 13, 2017

From Gradle 4.0.1 release notes:

In projects that use multiple JVM languages (Java and Scala, Groovy and other languages) in separate source directories (e.g., src/main/groovy and src/main/java), Gradle now uses separate output directories for each language.

To return to the old behavior, explicitly set the classes directory:

// Change the output directory for the main source set back to the old path
sourceSets.main.output.classesDir = new File(buildDir, "classes/main")

@mmoayyed
Copy link
Contributor

Besides the workaround, is this something we can help to fix by the way? To not return to the old behavior and simply make this work with Gradle 4 as is? If so, what might be a good starting point to review and track changes?

@wilkinsona
Copy link
Member

We can, and I think should, fix this in 1.5.x. There's a low-risk fix that can be applied: look for the resources folder one directory higher up if we don't find it where we're currently looking.

There are actually some other problems with the current situation, but they're more complex and harder to fix. I'll open a separate issue for those as they'll have to wait for 2.0.

@wilkinsona wilkinsona added type: bug A general bug and removed type: enhancement A general enhancement labels Jul 13, 2017
@wilkinsona wilkinsona modified the milestones: 1.5.5, 2.0.0.M4 Jul 13, 2017
@wilkinsona wilkinsona changed the title Support additional-spring-configuration-metadata merging with Gradle 4 additional-spring-configuration-metadata.json is not being merged when building with Gradle 4 Jul 13, 2017
@mmoayyed
Copy link
Contributor

Great, thanks. I'll put together a pull request.

@wilkinsona
Copy link
Member

I've opened #9755 for the trickier problems.

@mmoayyed Thanks very much. Just in case you haven't already spotted where the fix needs to be made, it's in MetadataStore.

@mmoayyed
Copy link
Contributor

Managed to get this working and tested it. First draft at #9758

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants