The gist is that we transform the jars from another local project, including its test jar. I try to then run tests using that transformed test jar. However, I get:
> Task :hibernate-core-jakarta:test NO-SOURCE
What are the sources for the test task? Is it literally looking for the test sources as in .java files? Why would the test task need access to the sources? And if so (odd, but ok), how do you tell it about the source files? Is via SourceSet the only option?
And actually, even “faking” the test sources in SourceSet does not work. E.g.
// `hibernate-core/src/test/java` exists and contains valid Java source files
// no idea why (and noone seems to know why - https://discuss.gradle.org/t/test-task-sources/41192)
// but Gradle's Test task needs access to the test source files. makes no sense... :shrug:
// "fake it" and just use hibernate-core's test sources
sourceSets.test.java.srcDir project( ':hibernate-core' ).file( 'src/test/java' )
It appears that if the testClassesDirs contain classes, then the task should not be skipped. If you have test classes in those dirs then I’m not sure why it’s reporting NO-SOURCE.
I guess I was not clear about using “jar”. Its a confusing process. We have a project named hibernate-core which is based on Java EE (at the source level). We need to also publish a variation of that using the new Jakarta EE contracts under hibernate-core-jakarta. This is all done “on the fly”. The build for hibernate-core-jakarta:
Takes the main jar from hibernate-core and transforms it as its own jar
Takes the test jar from hibernate-core and unpacks it
Takes the unpacked test jar and applies the transformation into another directory
Configures its test task to
use the outputs from (1) and (3) for its classpath
use the output from (3) for its classesDir
So by the time :hibernate-core-jakarta:test is executed, that classesDir will exist. But it does not at configuration time. Could that be an issue? I can’t imagine so since its essentially what happens with the test task normally.
Though maybe its related to how I configure it? Since I call files( project.transformedTestDir ) at config time? For what it is worth, I tried using providers instead but same result
I did get it working, but to be honest, I forget what exactly worked. We ended up just moving to Jakarta Persistence at the source level and so that stuff is no longer part of the build.