Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build.gradle: compile group vs compile, buildscript, classpath

Tags:

java

gradle

What is the difference between "compile group" and "compile"? Just another way to define a dependency?

Ex:

compile group: 'org.slf4j', name: 'slf4j-jcl', version: '1.7.21' 

And i think this also will work:

compile("org.slf4j:slf4j-jcl:1.7.21") 

Why do i have the declare mavenCentral() again and another dependencies block inside the buildscript block?

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

From my point of view, when you compile something it will be in your classPath?

like image 207
yooouuri Avatar asked Sep 13 '16 23:09

yooouuri


People also ask

What is compile classpath in Gradle?

A configuration is simply a named set of dependencies. The compile configuration is created by the Java plugin. The classpath configuration is commonly seen in the buildSrc {} block where one needs to declare dependencies for the build. gradle, itself (for plugins, perhaps).

What is Buildscript in build Gradle?

The buildscript is for the build.gradle file itself. So, this would contain dependencies for say creating RPMs, Dockerfile , and any other dependencies for running the tasks in all the dependent build.gradle.

What is difference between compile group and implementation in Gradle?

Fortunately, the implementation dependency configuration provides the same functionality as compile. You should always use implementation rather than compile for dependencies, as compile is now deprecated or removed in the case of Gradle 7+.

What is difference between compile and compileOnly Gradle?

The compileOnly configuration is used to itemize a dependency that you need to compile your code, same as compile above. The difference is that packages your java code use from a compileOnly dependency will not be listed as Import-Package manifest entries.


1 Answers

compile specifies an external dependency for the project you are building. compile requires group, name, and version. These can either be broken out or specified using the short form "group:name:version". see Gradle Dependency Management Basics

The buildscript block declares the dependencies of your gradle build itself while the normal dependencies block declares the dependencies of the project you are going to build

like image 105
larsgrefer Avatar answered Sep 30 '22 19:09

larsgrefer