title: Gradle building Spring Boot library without Main Class
body: <p>I am trying to build a Spring Boot/Gradle project and create a jar without a main class. My purpose is that this project is a library that will be pulled in by other projects therefore the library project does not require a main class to run. Unfortunately, no matter what kind of gradle config I write I keep getting errors when I try to <code>build install</code> about not having a main class or not being able to find the <code>bootJar</code> task.</p>
  
  <p>Here's what my gradle file looks like:</p>
  
  <pre><code>plugins {
      id 'org.springframework.boot' version '2.1.7.RELEASE' apply false
  }
  
  apply plugin: 'io.spring.dependency-management'
  apply plugin: 'maven'
  
  dependencyManagement {
      imports {
          mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
      }
  }
  
  repositories {
      mavenCentral()
  }
  
  jar {
      enabled = true
  }
  
  bootJar.dependsOn fooTask
  </code></pre>
  
  <p>But when I run this I get the following error:</p>
  
  <blockquote>
    <p>Could not get unknown property 'bootJar' for root project
    'foo-library' of type org.gradle.api.Project.</p>
  </blockquote>
  
  <p>What in my configuration needs to change?</p>