Repository navigation
Choose default targetVersion using Gradle/Maven configuration - #1478
Conversation
d245d7e to
1f42596
Compare
76fdd36 to
bb17e82
Compare
bb17e82 to
eacaaf7
Compare
eacaaf7 to
a7b042c
Compare
a7b042c to
2a18f48
Compare
| if (!configuration.targetVersion) { | ||
| def compileJavaTask = project.getTasksByName("compileJava", false).first() | ||
| configuration.targetVersion = compileJavaTask.getProperties().get("sourceCompatibility") | ||
| logger.warn 'Using Gradle targetCompatibility as targetVersion for jsonschema2pojo: ' + configuration.targetVersion |
There was a problem hiding this comment.
@joelittlejohn you have now merged this with the inconsistent log message, it should mention sourceCompatibility here, no?
same problem in GenerateJsonSchemaJavaTask.groovy
There was a problem hiding this comment.
Oops, thanks I will fix
|
|
||
| void setTargetVersion(JsonSchemaExtension configuration) { | ||
| if (!configuration.targetVersion) { | ||
| def compileJavaTask = project.getTasksByName("compileJava", false).first() |
There was a problem hiding this comment.
@joelittlejohn Sorry for reviving this PR.
Could this be the cause for actions failure
Execution failed for task ':app:generateJsonSchema2PojoForDebug'.
Cannot access first() element from an empty Iterable
Neither gradle nor android expert, but could it be that something similar to:
void setTargetVersion(JsonSchemaExtension configuration) {
if (!configuration.targetVersion) {
configuration.targetVersion = project.android.compileOptions.sourceCompatibility
logger.info 'Using Gradle sourceCompatibility as targetVersion for jsonschema2pojo: ' + configuration.targetVersion
}should be used (perhaps even in a null safe way?) for android (see Android Gradle plugin API reference: CompileOptions )?
Given of course that android project is configured with com.android.application plugin
There was a problem hiding this comment.
Yes, clearly the way the detection is working here is not right.
I have replicated the problem locally and I guess a combination of using a different property, and some more defensive coding, would be best.
There was a problem hiding this comment.
I don't have time to look this evening but can hopefully fix tomorrow (and release 1.2.1).
There was a problem hiding this comment.
We also need to get these CI jobs running against HEAD, not the latest release! :)
There was a problem hiding this comment.
I don't have time to look this evening but can hopefully fix tomorrow (and release 1.2.1).
Whilst error is certainly not a pleasant one, there might be several workarounds (maybe not the nicest ones) eg.: provide target version in configuration, create/register a dummy compileJava task, appy java plugin.
I don't know whether it is a critical/big pain point for android developers or not, if not - perhaps it would make sense to take some time and not rush ?
Relates to #1473.