Gradle not able to detect osdetector plugin

2020-04-16 05:08发布

问题:

I am using OpenSSL for my Java GRPC project which uses gradle.

I read the documetation which mentions that we should make security settings as mentioned in this link.

I have included the osdetector plugin in the build.gradle file.

But when I build the project, gradle is not able to resolve the osdetector plugin and throwing error

> Failed to apply plugin [id 'com.google.protobuf']
   > Plugin with id 'osdetector' not found.

My gradle file is as follows:

def neo4jVersion = "2.3.3"

apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'com.google.protobuf'
apply plugin: 'idea'
apply plugin: 'com.google.osdetector'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.3'
        classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
    }
}

protobuf {
    protoc {
        // The version of protoc must match protobuf-java. If you don't depend on
        // protobuf-java directly, you will be transitively depending on the
        // protobuf-java version that grpc depends on.
        artifact = "com.google.protobuf:protoc:3.0.0-beta-2"
    }
    plugins {
        grpc {
            artifact = 'io.grpc:protoc-gen-grpc-java:0.12.0'
        }
    }
    generateProtoTasks {
        all()*.plugins {
            grpc {}
        }
    }
    generatedFilesBaseDir = "$projectDir/src/generated"
}

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile 'io.grpc:grpc-all:0.12.0'
    compile "org.neo4j:neo4j:${neo4jVersion}"
    compile "org.neo4j:neo4j-ogm-core:2.0.1"
    compile "org.neo4j:neo4j-ogm-http-driver:2.0.1"
    compile 'com.google.apis:google-api-services-storage:v1-rev71-1.22.0'
    compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
    compile 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork14:' + osdetector.classifier
}

The compile dependency alone is getting resolved however.

I think I am missing something basic here. Please let me know the solution.

Updated

回答1:

protobuf-gradle-plugin is not compatible with osdetector-gradle-plugin-1.4.0, since that version changed the name of the plugin. Swapping to version osdetector 1.2.1 should fix the problem.