Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plugin with id spring-boot not found in parent build.gradle

I have below project structure:

java/
  build.gradle
  settings.gradle
  projectA/
    build.gradle
  projectB/
    build.gradle

When I put below codes in, e.g. projectA's build.gradle,

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
...

everything works fine.

But if I put the above code in Java's build.gradle:

subprojects {
    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
        }
    }

    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'spring-boot'
    ...
}

When running gradle clean build, it keeps reporting below error:

Plugin with id 'spring-boot' not found.

Anyone encountered this issue before? And why?

like image 212
Jerry Xue Avatar asked Nov 06 '15 06:11

Jerry Xue


People also ask

What is Spring Boot gradle plugin?

The Spring Boot Gradle Plugin provides Spring Boot support in Gradle. It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by spring-boot-dependencies .

What is bootJar in gradle?

bootJar on the other hand is a specific task added by Spring Boot Gradle plugin that, when the java plugin is present, attaches itself to the assemble lifecycle task. The assemble task is automatically configured to depend upon the bootJar task so running assemble (or build ) will also run the bootJar task.

How do I add a dependency in gradle?

To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.


2 Answers

I figured out a solution but don't know why. Will spent some time reading the docs during the weekend...

Change multi-project build.gradle to below:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
    }
}

subprojects {
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'spring-boot'
    ...
}

i.e move buildscript out of subprojects

like image 176
Jerry Xue Avatar answered Oct 05 '22 23:10

Jerry Xue


Try using fully qualified name as below:

plugins{
id 'org.springframework.boot' version '2.0.3.RELEASE'
id 'java'
}
like image 34
Nafeez Quraishi Avatar answered Oct 06 '22 00:10

Nafeez Quraishi