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

Specify target JVM version #454

Merged
merged 3 commits into from
Nov 30, 2015

Conversation

ctrimble
Copy link
Collaborator

Exposes a targetVersion property to the rules and test compiler, specifying the target Java version to generate for.

This fixes an issue during cross compilation where the source generated is valid for the JVM running the test suite but not for the JVM being targeted. For instance, auto boxing a cast like (int)value works in Java7 but not in Java6.

Interface Changes:

  • Maven: adds a targetVersion config property, with a default value of maven.compiler.target.
  • Gradle: adds a targetVersion property, with a default value of 1.6
  • Ant: adds a targetVersion property, with a default value of 1.6
  • CLI: adds options -tv and --target-version, with a default value of 1.6

Limitations: This patch does not set the bootclasspath from toolchains.xml. So, there can still be issues where Java7 classes and methods are referenced when generating code for Java6. I attempted to add support using classes from Maven, but there is a classpath conflict with the testing for Ant. -Xlint:-options has been set during testing, to suppress warnings related to this.

The changes here were taken from #386.

@ctrimble
Copy link
Collaborator Author

@joelittlejohn this change adds a new configuration option. The naming is strange for the Ant task and I am not very proficient at Gradle, so any notes around those items would be appreciated.

@ctrimble ctrimble mentioned this pull request Nov 27, 2015
@ctrimble ctrimble force-pushed the feature_target-version branch 4 times, most recently from 069ee4e to 9d0d1d4 Compare November 28, 2015 17:44
@ctrimble
Copy link
Collaborator Author

@joelittlejohn I think the PR that adds the target option is ready to merge.

@ctrimble
Copy link
Collaborator Author

Looks like I forgot setTarget( String target ) in the ant task and associated documentation.

@ctrimble ctrimble force-pushed the feature_target-version branch 2 times, most recently from b5c029c to 9f6fbee Compare November 28, 2015 20:57
@@ -65,7 +65,7 @@ public void antTaskDocumentationIncludesAllProperties() throws IntrospectionExce
String documentation = FileUtils.readFileToString(new File("../jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html"));

for (Field f : Jsonschema2PojoTask.class.getDeclaredFields()) {
assertThat(documentation, containsString(f.getName()));
assertThat(documentation, containsString(">"+f.getName()+"<"));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot 😄

@joelittlejohn
Copy link
Owner

Looking good to me. One thing, I think target here is a little confusing as it's easy to confuse this with the target directory. I prefer targetVersion everywhere, as you've used in the CLI.

@joelittlejohn joelittlejohn added this to the 0.4.17 milestone Nov 28, 2015
@joelittlejohn
Copy link
Owner

Other than that change, I can't see anything else to comment on. Nice work, I'll merge when you're ready.

@@ -131,6 +131,9 @@

@Parameter(names = { "-da", "--disable-accessors" }, description = "Whether to omit getter/setter methods and create public fields instead.")
private boolean disableAccessors = false;

@Parameter(names = { "-tv", "--target-version" }, description = "Target version for generated source files.")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best way to describe this setting. Make all descriptions like this one.

@ctrimble
Copy link
Collaborator Author

@joelittlejohn target has been changed to targetVersion. I also made the documentation consistent across all the interfaces. This is ready to merge.

joelittlejohn added a commit that referenced this pull request Nov 30, 2015
@joelittlejohn joelittlejohn merged commit 005161a into joelittlejohn:master Nov 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants