What is the "compile group" for gradle dependencies? And what do the different components do?

Viewed 3973

I have included the build.gradle for the tutorial application that I am working through. Everything works with it, the only question that I have is what the "compile group" down at the bottom does, and what the different parts of it does? I was told to just copy the code, but I wanted to know more about what this actually did. (I copied the compile group from the maven repository website, so I know that it is valid code)

group 'PledgeToVote'
version '1.0-SNAPSHOT'

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

apply plugin: 'java'
apply plugin: 'org.springframework.boot'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.5.RELEASE'
}

Thank you for any help you can provide!

1 Answers

compile is a configuration in Gradle terminology.

Configurations have different roles in Gradle:

  • a bucket of dependencies
  • Resolvable: that is a dependency graph can be computed and used, for example to generate a classpath
  • Consumable: this is how projects share artifacts and dependencies.

For more information on these topics, I recommend the following webinar (Note: I am a co-presenter in this webinar).

In addition, compile has been deprecated in favour of implementation and api for a while. See the documentation for more details on this.

Related