pablisco / auto-module

A Gradle plugin to generate a module graph and include them modules
MIT License
110 stars 11 forks source link

cannot apply plugin #9

Open nkiesel opened 3 years ago

nkiesel commented 3 years ago

I removed all my includes from settings.gradle and added id("com.pablisco.gradle.automodule") version "0.15" as the last entry in my existing top-level build.gradle. However, when running gradle jar I now get

An exception occurred applying plugin request [id: 'com.pablisco.gradle.automodule', version: '0.15'] > Failed to apply plugin [id 'com.pablisco.gradle.automodule'] > org.gradle.api.internal.project.DefaultProject_Decorated cannot be cast to org.gradle.api.initialization.Settings

This is with Gradle 5.6.4

BTW: I first tried to add the plugin into settings.gradle because the instructions say: "replace includes with the plugin line" but that was not working either. Thus added to build.gradle instead. Perhaps you can improve the instructions to make it clearer where to add the plugin line.

pablisco commented 3 years ago

What error do you get when applying it to the settings.gradle file? It should not be used in the top level build script... You can see from the error that it's expecting a Settings scope.

Can you provide some code of what have you tried? Also, it may be helpful to see how it's used inside the demo folder :)

pablisco commented 3 years ago

Also, I think the instructions are ok, but I welcome any improvement as a PR :)

nkiesel commented 3 years ago

I added it at line 1 in settings.gradle:

plugins {
    id("com.pablisco.gradle.automodule") version "0.15"
}

The error I get is:

  • Where: Settings file '/home/nkiesel/work/Platform/settings.gradle' line: 1
  • What went wrong: Could not compile settings file '/home/nkiesel/work/Platform/settings.gradle'. startup failed: settings file '/home/nkiesel/work/Platform/settings.gradle': 1: Only Project build scripts can contain plugins {} blocks See https://docs.gradle.org/5.6.4/userguide/plugins.html#sec:plugins_block for information on the plugins {} block

For the record: currently, my settings.gradle starts with

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven {
            name "ext-release-local"
            url "http://msjenkins:8081/artifactory/ext-release-local"
        }
    }

    plugins {
        id "com.gradle.build-scan" version Versions.com_gradle_build_scan_gradle_plugin
        id "org.sonarqube" version Versions.org_sonarqube_gradle_plugin
        id "de.fayard.buildSrcVersions" version Versions.de_fayard_buildsrcversions_gradle_plugin
        id "com.palantir.jacoco-full-report" version Versions.com_palantir_jacoco_full_report_gradle_plugin
        id "org.ajoberstar.grgit" version Versions.org_ajoberstar_grgit_gradle_plugin
        id "com.github.voplex95.lesscompiler" version Versions.com_github_voplex95_lesscompiler_gradle_plugin
        id "com.moowork.node" version Versions.com_moowork_node_gradle_plugin
        id "com.moowork.grunt" version Versions.com_moowork_grunt_gradle_plugin
        id "com.bmuschko.cargo" version Versions.com_bmuschko_cargo_gradle_plugin
        id "org.jetbrains.kotlin.jvm" version Versions.org_jetbrains_kotlin_jvm_gradle_plugin
        id "org.jlleitschuh.gradle.ktlint" version Versions.org_jlleitschuh_gradle_ktlint_gradle_plugin
        id "io.gitlab.arturbosch.detekt" version Versions.io_gitlab_arturbosch_detekt
        id 'net.ltgt.errorprone' version Versions.net_ltgt_errorprone_gradle_plugin
    }
}
nkiesel commented 3 years ago

Any suggestions on how to proceed?