Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.7k views
in Technique[技术] by (71.8m points)

gradle - all buildscript {} blocks must appear before any plugins {} blocks in the script

I am new to gradle 6.7 and trying to create a base file for creating a structure for my future project. I have re-arranged plugins location but i dont see any change in error i see :

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
  }

apply plugin: "io.spring.dependency-management"
apply plugin: "spring-boot"

buildscript {
  repositories {
    mavenCentral()
    jcenter()
  }
  dependencies {
    classpath "io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE"
    classpath "org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE"
  }
  
}

dependencyManagement {
  imports {
    mavenBom 'io.spring.platform:platform-bom:1.2.1.RELEASE'
  }
}

dependencies {
    api 'org.springframework:spring-core'
}

Getting the following error :

* Where:
Build file 'C:PlatformXpressxpress-baseuild.gradle' line: 17

* What went wrong:
Could not compile build file 'C:PlatformXpressxpress-baseuild.gradle'.
> startup failed:
  build file 'C:PlatformXpressxpress-baseuild.gradle': 17: all buildscript {} blocks must appear before any plugins {} blocks in the script

  See https://docs.gradle.org/6.7/userguide/plugins.html#sec:plugins_block for information on the plugins {} block

   @ line 17, column 1.
     buildscript {
     ^

  1 error

UPDATE

buildscript {
  repositories {
    mavenCentral()
    jcenter()
  }

  dependencies {
    classpath "io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE"
    classpath "org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE"
  }
  
}


apply plugin: "java"
apply plugin: "io.spring.dependency-management"
apply plugin: "spring-boot"


...

Rearranged in the above manner getting error :

* What went wrong:
A problem occurred evaluating root project 'xpress-base'.
> Failed to apply plugin 'io.spring.dependency-management'.
   > Could not create task ':dependencyManagement'.
      > Could not create task of type 'DependencyManagementReportTask'.
         > Unable to determine constructor argument #1: missing parameter of type StyledTextOutputFactory, or no service of type StyledTextOutputFactory.
question from:https://stackoverflow.com/questions/65898490/all-buildscript-blocks-must-appear-before-any-plugins-blocks-in-the-script

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...