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

set plugin versions #10

Closed
nedtwigg opened this issue Jan 10, 2020 · 1 comment
Closed

set plugin versions #10

nedtwigg opened this issue Jan 10, 2020 · 1 comment
Labels
enhancement New feature or request pr-welcome Extra attention is needed

Comments

@nedtwigg
Copy link
Member

nedtwigg commented Jan 10, 2020

EDIT: the comments below make this WAY too complicated. Solved in blowdryer 1.7.0, docs here.


The biggest unsolved problem for blowdryer is that it can't currently help with setting the versions of third-party plugins. Starting with Gradle 6.0, there is a great way to centralize these:

// settings.gradle
pluginManagement {
  plugins {
    id 'com.diffplug.blowdryer' version '1.0.0'
    id 'com.diffplug.blowdryerSetup' version '1.0.0'
    id 'foo' version 'bar'
    ...
  }
}
plugins {
  id 'com.diffplug.blowdryerSetup' // no version necessary
  id 'foo' apply false // to use in script plugins, it needs to be declared here
  ...
}

// any build.gradle
plugins {
  id 'com.diffplug.blowdryer' // no version necessary
}
// or
apply plugin: 'foo' // guaranteed to be present if settings.gradle had `plugins{} apply false`

Easiest thing

The easiest thing would be to have a special plugin-versions.properties file:

com.diffplug.blowdryerSetup toSettings=1.0.0 # 'toSettings' is code for
com.diffplug.blowdryer=1.0.0                 # apply to the settings.gradle file
foo=bar                         # all other plugins will have `apply false`

This could then be applied to the project with blowdryerPluginVersions[Check|Apply], with blowdryerPluginVersionsCheck hooked into check. Within the settings.gradle, the tasks would parse for pluginManagement { plugins { and wipe out everything there, and the same for plugins { below that.

Problem with easiest (A) - fighting over versions

It has to be easy for the user to sync with and override blowdryer. There are three cases:

case code
blowdryer wants it, I don't // exclude com.diffplug.foo
I want it, blowdryer doesn't id 'com.diffplug.foo' version '3.7.0' // extra
I want a different version id 'com.diffplug.foo' version '3.7.0' // override 3.5.0

All together:

pluginManagement {
  plugins {
    // exclude com.diffplug.spotless-changelog
    id 'com.diffplug.spotless' version '3.27.0' // override 3.25.0
    id 'com.diffplug.image-grinder' version '2.1.0' // extra
    ...

Problem with easiest (B) - local would be better

It might be better if each script plugin, rather than doing apply plugin: 'com.diffplug.foo', could instead do 干.applyPlugin('com.diffplug.foo', '1.0.0'), and blowdryer could aggregate these recursively throughout the project into the plugin versions that it requests. That way you're only declaring the plugins you need, and it also makes makes things more modular in general.

However, this can't bootstrap itself - until the plugins have been set, the buildscript will fail, so we won't be able to find out what versions we need. In order to make this work, we would need to first implement #6. If we could read a build.gradle just to the level of "it calls out to these scripts, which call to these scripts", then we could read those for 干.applyPlugin('com.diffplug.foo', '1.0.0'), and bubble all of that back up to the root.

Minimum viable PR

Would be the easiest possible thing, along with an implementation of the "fighting over versions" system. It would be enabled in blowdryerSetup { setPluginVersions() }. In the future, we would still have the option to implement blowdryerSetup { setPluginVersionsLocally() }. It would be fine to jump straight to setPluginVersionsLocally() if #6 has already been implemented and merged. It's also fine if only Groovy or only Kotlin is implemented. Once one is implemented, someone else can finish the other.

@nedtwigg
Copy link
Member Author

Published in 1.7.0 (docs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pr-welcome Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant