Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

only build script and other plugins script blocks are allowed before plugins

Tags:

plugins

gradle

I want to use gradle plugin having this syntax

 plugins {   id "id" version "version" } 

but i have the error of

only build script and other plugins script blocks are allowed before plugins  

I moved it to the bloc buildscript but still not working.

How can i apply this kind of plugin ?

This is the plugin that I want to include in my project

gradle git properties plugin

and here is the output of my gradle version

    Gradle 4.3.1 ------------------------------------------------------------  Build time:   2017-11-08 08:59:45 UTC Revision:     e4f4804807ef7c2829da51877861ff06e07e006d  Groovy:       2.4.12 
like image 957
Toumi Avatar asked Feb 04 '18 17:02

Toumi


People also ask

Which are the two types of plugins in Gradle?

There are two general types of plugins in Gradle, binary plugins and script plugins.

What is plugin in build Gradle?

The Android Gradle plugin (AGP) is the official build system for Android applications. It includes support for compiling many different types of sources and linking them together into an application that you can run on a physical Android device or an emulator.

What is buildScript block in Gradle?

The buildScript block determines which plugins, task classes, and other classes are available for use in the rest of the build script. Without a buildScript block, you can use everything that ships with Gradle out-of-the-box.

How do I enable debug mode in Gradle?

To do that, just pick the Gradle Remote Debug configuration and then click the Debug icon on the project to be debugged. For more info, you can read the Gradle documentation. Follow us for more productivity tools & ideas for Android, Kotlin & Gradle projects.


1 Answers

Whenever you write a build.gradle script and use the new plugins script block, you need to put it as first block in the file. The only exceptions from this rule are other plugins blocks or the special buildScript block, which always must go first.

As an example, this script is fine:

plugins {     // ... }  dependencies {     // ... } 

This one is also fine:

buildScript {     // ... }  plugins {     // ... }  repositories {     // ... } 

But this one is invalid:

repositories {      // ... }  plugins {     // ... } 
like image 103
Lukas Körfer Avatar answered Sep 20 '22 11:09

Lukas Körfer