Home > Software design >  Gradle 7.5 cannot build project with compile configuration problem
Gradle 7.5 cannot build project with compile configuration problem

Time:07-19

I got a project and it is built with gradle 6 or older version.

I've checked the other stakeoverflow discussion with compile/testCompile problem in gradle 7, and I change all the dependencies from compile/testCompile to api/testImplementation.

But it still doesn't work when I'm doing gradle build.

It still return with Configuration with name 'compile' not found

I've checked this:

  1. Build error with gradle Could not find method testCompile()
  2. What's the difference between implementation, api and compile in Gradle?

Here is my root gradle configuration:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        // https://github.com/google/protobuf-gradle-plugin
        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10'
    }
}

plugins {
    id 'application'
    id 'java'
    id 'java-library'
    id "com.google.protobuf" version "0.8.10"
}

group 'com.ght'
version '61'

mainClassName = 'com.application'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    // jcenter() is no longer support.
//    jcenter()
    mavenCentral()
}

sourceSets {
    main {
        proto {
            srcDir 'src/main/protobuf'
            include '**/*.protodevel'
        }
    }
}

dependencies {
    testImplementation group: 'junit', name: 'junit', version: '4.12'

    implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.0.0'

    // https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
    implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.3'

    // https://mvnrepository.com/artifact/ch.qos.logback/logback-core
    implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.1.3'

    // https://mvnrepository.com/artifact/org.slf4j/slf4j-implementation
    implementation group: 'org.slf4j', name: 'slf4j-implementation', version: '1.7.26'

    // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.2.1'

    // https://mvnrepository.com/artifact/org.locationtech.jts/jts-core
    implementation group: 'org.locationtech.jts', name: 'jts-core', version: '1.16.0'

    // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'

    // https://mvnrepository.com/artifact/com.vividsolutions/jts
    implementation group: 'com.vividsolutions', name: 'jts', version: '1.13'

    // https://mvnrepository.com/artifact/com.google.guava/guava
    implementation group: 'com.google.guava', name: 'guava', version: '19.0'

    // https://mvnrepository.com/artifact/org.apache.commons/commons-math3
    implementation group: 'org.apache.commons', name: 'commons-math3', version: '3.5'

    // https://mvnrepository.com/artifact/commons-logging/commons-logging
    implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'

}

protobuf {
    // Configure the protoc executable
    protoc {
        // Download from repositories
        artifact = 'com.google.protobuf:protoc:3.0.0'
    }
    generatedFilesBaseDir = "$projectDir/gen"
}

clean {
    delete protobuf.generatedFilesBaseDir
}

jar{

    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }

    manifest {
        attributes('Manifest-Version': archiveVersion, 'Main-Class': 'com.application')
    }

    exclude 'logback-test.xml'
    exclude '**/schema/**'
    exclude '**.proto'


}

Here is build error message:

A problem occurred configuring root project 'application'.
> Configuration with name 'compile' not found.

* Try:
> Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'application'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:84)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:77)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:55)
    at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:255)
.
.
.
Caused by: org.gradle.api.artifacts.UnknownConfigurationException: Configuration with name 'compile' not found.
    at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.createNotFoundException(DefaultConfigurationContainer.java:108)
    at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:333)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.getByName(DefaultConfigurationContainer.java:98)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.getByName(DefaultConfigurationContainer.java:50)
.
.
.
at com.google.protobuf.gradle.ProtobufPlugin$_setupExtractIncludeProtosTask_closure21.doCall(ProtobufPlugin.groovy:369)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.gradle.util.internal.ClosureBackedAction.execute(ClosureBackedAction.java:73)
    at org.gradle.util.internal.ConfigureUtil.configureTarget(ConfigureUtil.java:155)
    at org.gradle.util.internal.ConfigureUtil.configureSelf(ConfigureUtil.java:131)
    at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:666)
    at org.gradle.api.DefaultTask.configure(DefaultTask.java:309)
.
.
.


gradle version: gradle 7.5

gradle JVM version: GraalVM version 17.0.3

IDE: intellij ide 2022.1.3

Thank you for any help.

CodePudding user response:

You're using a very outdated version of the Protobuf Gradle plugin. Version 0.8.10 (2019) predates Gradle 7 (2021). The issue you're facing is likely to be fixed by upgrading the plugin.

plugins {
  id "com.google.protobuf" version "0.8.19"
}
  • Related