Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compile find a bad version of gradle

I use spring boot 2. In a multi java project.

I try to build my main library (no yet java file)

apply plugin: 'java-library-distribution'


plugins {
    id 'org.springframework.boot' version '2.0.0.M7'
}

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}


dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.0.M7'
    compile group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
        testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.0.0.M7'
}

distributions {
    main{
        baseName = 'common-model'
    }
}

sourceCompatibility = 1.8

tasks.withType(JavaCompile) {
    options.compilerArgs = ["-Xlint:unchecked", "-Xlint:deprecation", "-parameters"]
}

In my gradle/wrapper, i have

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip

error i get

caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'org.springframework.boot']

Caused by: org.gradle.api.GradleException: Spring Boot plugin requires Gradle 4.0 or later. The current version is Gradle 2.13

i don't find any 2.13 version

In my main project i have

buildscript {
    ext {
        springBootVersion = '2.0.0.M7'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

mainClassName = 'com.zirgon.EmailApplication'

group = 'com.zirgon'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

tasks.withType(JavaCompile) {
    options.compilerArgs = ["-Xlint:unchecked", "-Xlint:deprecation", "-parameters"]
}

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')

    compile project(':common-model')
    compile('org.springframework.boot:spring-boot-starter-mail')

    compile group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}
like image 370
robert trudel Avatar asked Dec 12 '17 03:12

robert trudel


2 Answers

It's possible you might be building the project with gradle installed locally instead of using the wrapper i.e. using gradle build instead of ./gradlew build.

like image 163
Pankaj Gadge Avatar answered Oct 08 '22 15:10

Pankaj Gadge


These are the steps I took to fix the same problem.

  1. I had a new project with a build.gradle file, but did not have a copy of gradle wrapper in my project directory. I think this caused the default gradle version for my IDE to be used (IntelliJ) and this is an older version.
  2. Gradle was already installed on my system.
  3. Ran "gradle wrapper" in my project directory.
  4. Edited ./gradle/wrapper/gradle-wrapper.properties and made sure "distributionUrl" was pointed at the gradle version I wanted (4.6 in my case).
  5. Reran my build and the correct version was then downloaded and installed. Problem fixed.

I hope this helps someone!

I copied my gradle wrapper folder over from another project, and edited ./gradle/wrapper/gradle-wrapper.properties

like image 3
Guerry Avatar answered Oct 08 '22 15:10

Guerry