could not resolve plugin artifact 'com.commercehub.gradle.plugin.avro:com.commercehub.gradle.plugin.avro.gradle.plugin:0.16.0') code example

Example: com.commercehub.gradle.plugin.avro.generate avro java task

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        //plugin needed to generate POJO from Avro schema
        classpath("com.commercehub.gradle.plugin:gradle-avro-plugin:0.14.2")
    }
}
 
 
apply plugin: "maven"
apply plugin: "java"
//dont forget to add plugin
apply plugin: "com.commercehub.gradle.plugin.avro-base"
 
group 'io.karengryg'
version '1.0-SNAPSHOT'
 
sourceCompatibility = 1.8
 
repositories {
    jcenter()
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
    maven { url "http://packages.confluent.io/maven/" }
}
 
dependencies {
    compile 'org.springframework:spring-core:5.0.8.RELEASE'
    compile 'org.springframework:spring-beans:5.0.8.RELEASE'
    //for gradle-avro-plugin to work correctly need avro version 1.8.2
    compile "org.apache.avro:avro:1.8.2"
    compile 'io.confluent:kafka-avro-serializer:4.1.1'
    testCompile 'junit:junit:4.12'
}
 
//gradle-avro-plugin setting
avro {
    //convert all string type to "java.lang.CharSequence"
    stringType = "CharSequence"
}
 
task generateAvro(type: com.commercehub.gradle.plugin.avro.GenerateAvroJavaTask) {
    //point plugin to folder with avro schemas
    source("src/main/resources/avro")
    //point plugin to folder with generated POJOs
    outputDir = file("src/main/java/avro")
}
 
compileJava.source(generateAvro.outputs)

Tags:

Java Example