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

Settings plugin: tag and push task creation could be done a little earlier #200

Closed
jnehlmeier opened this issue Dec 7, 2023 · 0 comments · Fixed by #201
Closed

Settings plugin: tag and push task creation could be done a little earlier #200

jnehlmeier opened this issue Dec 7, 2023 · 0 comments · Fixed by #201

Comments

@jnehlmeier
Copy link

I am working on a settings convention plugin that applies reckon and foojay plugins via code to root project. Also as soon as subprojects are available it applies the base plugin and configures the reckonTagCreate task to depend on check task. However this code seems to run too early as it cannot find the reckonTagCreate task.

The following is what I do

var pluginManager = settings.getPluginManager();
pluginManager.apply(ReckonSettingsPlugin.class);
pluginManager.apply(FoojayToolchainsConventionPlugin.class);

var extensions = settings.getExtensions();
configureReckon(extensions);

settings.getGradle().rootProject(rootProject -> {
  configureRootProject(rootProject);
  rootProject.subprojects(this::configureSubProject);
});

private void configureSubProject(Project subProject) {
    var pluginManager = subProject.getPluginManager();
    pluginManager.apply(BasePlugin.class);
    pluginManager.withPlugin("base", plugin -> {
      subProject.getRootProject().getTasks().named(ReckonSettingsPlugin.TAG_TASK,
          task -> task.dependsOn(subProject.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME)));
    });
  }

It seems like that Gradle.rootProject.subprojects runs earlier than Gradle.projectsLoaded, which the reckon settings plugin uses to register its tasks.

Maybe you can check if the above would work if reckon would use Gradle.rootProject instead of Gradle.projectsLoaded since reckon only configures tasks on the root project anyways.

As a workaround I will now also use Gradle.projectsLoaded.

ajoberstar added a commit that referenced this issue Dec 30, 2023
@jnehlmeier noticed that it can be difficult to create other settings
plugins that build off the tag/push tasks that reckon registers due to
them being registered after projectLoaded.

Since these are only added to the root project, its a trivial tweak to
just register directly on rootProject and avoid the extra ordering
confusion for downstream authors.

Fixes #200
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 a pull request may close this issue.

1 participant