I'm trying to force a maven package structure with my gradle build script since the new package layo...
j
I'm trying to force a maven package structure with my gradle build script since the new package layout seems to break certain libraries, or at least, it seems they're not picking up configs that's sitting inside src/main/resources The maven package layout basically dumps java, kotlin and resources content directly into the classes directory whereas gradle splits it into classes/kotlin/main, classes/java/main and resources/main
Copy code
sourceSets {
	main {
		java {
			setSrcDirs(listOf("src/main/java"))
			outputDir = File("build/classes")
		}
		withConvention(KotlinSourceSet::class) {
			kotlin.setSrcDirs(listOf("src/main/kotlin"))
			kotlin.outputDir = File("build/classes")
		}
		resources {
			setSrcDirs(listOf("src/main/resources"))
			outputDir = File("build/classes")
		}
	}
	test {

	}
}
The Java one works perfectly, the resources one doesn't do anything and the Kotlin one i'm not sure how to configure.
g
It works like this by default
or your problme is outputDir?
outputDirs for classes of different languages separated now in Gradle and not sure that you can return old behavior, what is your use case for this?
j
yeah, i'm trying to force the output dir to see if it fixes this problem i'm having: https://stackoverflow.com/questions/55843888/hibernate-annotation-scanning-not-working-under-gradle-5-4
doesn't seem like my persistence.xml is being picked up under the new split directory layout
not sure if that is something that can be set in the manifest, explicitly specifying where resources is sitting
g
I would check Gradle or Hibernate issue tracker instead, I believe it should work already, maybe there is some another problem. This behavior changed some time ago, probably in Gradle 5.0
Resources just should work, they don’t have any specific language class output dir, and anyway all languages have the same classpath on runtime
did you tried get this resource from code on runtime? I think it should be available and there is some another problem
j
resource loading works for everything else, not for hibernate let me check if a minor version upgrade fixes it ...
g
I don’t know, it looks wrong for me trying to fix it like that, maybe better to find real source of the problem
everything else, not for hibernate
So, maybe it’s some hibernate configuration problem?
j
let me try copying META-INF into src/main/kotlin and see if it picks up
g
Why do you think that problem in output dir? Output dir doesn’t exist on runtime
j
i'm trying everything even if it's bizarre this problem seems quite bizarre
g
I undertand, but most probably it will not help
Maybe there is some way to debug hibernate resource loading
also, do you use hibernate gradle plugin?
j
hibernate's debug mode outputs so much logs that it's hard to figure out what you're looking at by hibernate gradle plugin, do you mean adding it as an
implementation
?
or is there some other plugin that i'm missing ?
g
no
there is some hibernate plugin, but not sure that it really needed, I’m not familiar with hibernate setup
it’s not really maintained, so not sure, I would just try to find some hibernate example with Gradle
j
mmm, have never seen that before
g
also, maybe better try to ask in #server
j
Thanks Andrey, let me try server, this is probably a hibernate issue and not a gradle issue