-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Choose default targetVersion using Gradle/Maven configuration #1478
Conversation
jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
Outdated
Show resolved
Hide resolved
d245d7e
to
1f42596
Compare
76fdd36
to
bb17e82
Compare
...radle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/GenerateJsonSchemaAndroidTask.groovy
Show resolved
Hide resolved
jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
Show resolved
Hide resolved
jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
Show resolved
Hide resolved
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to get these CI jobs running against HEAD, not the latest release! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.