# Cannot exclude root project from build

**URL:** https://discuss.gradle.org/t/cannot-exclude-root-project-from-build/24187
**Category:** Help/Discuss
**Created:** [September 25, 2017, 9:09am UTC](https://discuss.gradle.org/t/cannot-exclude-root-project-from-build/24187 "2017-09-25T09:09:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Strannik](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Strannik](https://discuss.gradle.org/u/Strannik)
#### Post date: [September 25, 2017, 9:09am UTC](https://discuss.gradle.org/t/cannot-exclude-root-project-from-build/24187/1 "2017-09-25T09:09:49Z")

</div>

Hi

I am using Gradle 4.2 for Spring Boot application. I would like to apply Spring Boot plugin to sub-projects of my project so I put this plugin into subprojects section. How my overall build fails because Spring Boot plugin is executed for root project, could not find main class and generates error.  
Please advise how specify this plugin for sub-projects only.

```
plugins { id "io.spring.dependency-management" version "1.0.3.RELEASE" apply false }
plugins { id 'org.springframework.boot' version '1.5.7.RELEASE' }

allprojects {
  apply plugin: 'maven'

  group = 'test'
}

subprojects {
  apply plugin: 'java'
  apply plugin: 'io.spring.dependency-management'
  apply plugin: 'org.springframework.boot'
  
  sourceCompatibility = 1.8
  targetCompatibility = 1.8

  ext {
      springVersion = '4.3.11.RELEASE'
      springBootVersion = '1.5.7.RELEASE'
  } 
  
  repositories {
    mavenLocal()
    
    mavenCentral()
  } 

  dependencies {
     compile("org.springframework.boot:spring-boot-devtools:${springBootVersion}")
  }
}
```

---

<div class="post-metadata">

### Author: ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)
#### Post date: [September 25, 2017, 10:07am UTC](https://discuss.gradle.org/t/cannot-exclude-root-project-from-build/24187/2 "2017-09-25T10:07:06Z")

</div>

The script is missing `apply false` for the boot plugin in the plugins block at the very top. That’s why it is applied to your root project.

---

<div class="post-metadata">

### Author: ![Strannik](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Strannik](https://discuss.gradle.org/u/Strannik)
#### Post date: [September 25, 2017, 10:28am UTC](https://discuss.gradle.org/t/cannot-exclude-root-project-from-build/24187/3 "2017-09-25T10:28:22Z")

</div>

Thank you, @st_oehme

It works now. Does that mean if I add some plugin this way I don’t need to specify it in allprojects section as well?

plugins { id ‘org.springframework.boot’ version ‘1.5.7.RELEASE’ }

---

<div class="post-metadata">

### Author: ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)
#### Post date: [September 25, 2017, 7:58pm UTC](https://discuss.gradle.org/t/cannot-exclude-root-project-from-build/24187/4 "2017-09-25T19:58:59Z")

</div>

You still need to, otherwise it is only applied to the root project. We will improve this syntax so it can be used consistently everywhere instead of mixing `plugins {}` and `apply plugin`
