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

New plugin: 'com.palantir.baseline-enable-preview-flag' #1549

Merged
merged 7 commits into from
Nov 17, 2020

Conversation

iamdanfox
Copy link
Contributor

@iamdanfox iamdanfox commented Nov 17, 2020

Before this PR

I have a PR up internally on template-witchcraft#1414 which demonstrates how verbose it is to opt-in to feature previews, e.g. records. As described in this stackoverflow answer, I had to add:

tasks.withType(JavaCompile) {
    options.compilerArgs += "--enable-preview"
}
tasks.withType(Test) {
    jvmArgs += "--enable-preview"
}
tasks.withType(JavaExec) {
    jvmArgs += "--enable-preview"
}

Which was pretty lame. Additionally, you'd have to add this to every project.

After this PR

==COMMIT_MSG==
Add the new line apply plugin: 'com.palantir.baseline-enable-preview-flag' to your subprojects block to enable the usage of unreleased java features (e.g. records, switch expressions, var keyword etc).

Note, this plugin is a no-op on any project where you have a low sourceCompatibility.
==COMMIT_MSG==

cc @robert3005 who usually likes shiny new things

Possible downsides?

  • I think the decision to start using unstable java features should be taken quite cautiously, as I really don't want to find abandoned projects which are deeply coupled to some exotic unstable feature which has since been changed/removed. I think the rule-of-thumb for using this is if you really had to back it out, you could undo it all in a day.
  • For a moment, I wondered if actually the verbosity of enabling this stuff is actually desirable, but it occurred to me that people will just copy and paste these snippets everywhere and then we'll be completely screwed. Better to have a one-liner which is easy to excavate

@changelog-app
Copy link

changelog-app bot commented Nov 17, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Add the apply plugin: 'com.palantir.baseline-enable-preview-flag' to your subprojects block to enable the usage of unreleased java features (e.g. records, switch expressions, var keyword etc).

Note, this plugin is a no-op on any project where you have a low sourceCompatibility.

Check the box to generate changelog(s)

  • Generate changelog entry

@fawind
Copy link
Contributor

fawind commented Nov 17, 2020

Looks good!

Need to double check but do we also need to set the preview flag for the javadoc task?

Edit: Tried it and we also need to set preview on javadoc. Something like:

tasks.withType(Javadoc) {
    options.addBooleanOption('-enable-preview', true)
    options.addStringOption("source", SOURCE_COMPAT)
}

Copy link
Contributor

@fawind fawind left a comment

Choose a reason for hiding this comment

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

Javadoc is just nasty. But looks good!

@bulldozer-bot bulldozer-bot bot merged commit 33f1db9 into develop Nov 17, 2020
@bulldozer-bot bulldozer-bot bot deleted the dfox/enable-preview-flag branch November 17, 2020 14:43
@svc-autorelease
Copy link
Collaborator

Released 3.52.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants