0

I'm learning gradle and saw a build.gradle which i'd really like to understand. I tried searching through the docs but couldn't figure this out.

configurations {
    provided
}

sourceSets {
    main {
        compileClasspath += configurations.provided
    }
}
  1. Is the configurations documented somewhere? Is provided just a list of dependencies available at runtime ? (I read about provided but didn't know if it was the same)

A run task is also defined:

task run(type: JavaExec, dependsOn: classes) {
    main = mainClassFile
    classpath sourceSets.main.runtimeClasspath
    classpath configurations.runtime
}

The mainClassFile is defined in the gradle.properties file:

mainClassFile=template.project.Main
  1. Where does the configurations.runtime come from?

  2. Finally, the following plugins are used:

plugins {
    id 'java'
    id 'com.github.johnrengelman.shadow' version '1.2.3'
}

apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'idea'

Is the java plugin needed if we use a scala plugin? Or defining both a better approach? I understand that we should use either plugins {} or apply but just copy-ing what the build.gradle has so I can understand it.

Panda
  • 329
  • 3
  • 14
  • This documentation may help: [Managing Dependency Configurations](https://docs.gradle.org/current/userguide/managing_dependency_configurations.html). It looks like the project you're looking at added a custom `provided` configuration. As for where the (deprecated) `runtime` configuration comes from, it's [added by the `java` plugin](https://docs.gradle.org/current/userguide/java_plugin.html#tab:configurations). – Slaw Jul 17 '19 at 00:24
  • Means the same as in Maven: [Difference between maven scope compile and provided for JAR packaging](https://stackoverflow.com/q/6646959/5221149) – Andreas Jul 17 '19 at 00:27
  • It seems like someone added the `provided` configuration to provide a similarity to the `provided` scope in Maven. However, such a configuration already exists in Gradle and it is called `compileOnly` – Lukas Körfer Jul 17 '19 at 00:35

0 Answers0