stoicflame / enunciate

Build-time enhancement tool for Java-based Web services projects
http://enunciate.webcohesion.com/
Other
480 stars 201 forks source link

How to configure multiple enunciate tasks in Gradle in Groovy format? #1159

Closed nithinbandaru1 closed 1 year ago

nithinbandaru1 commented 1 year ago

Hi here is the configuration done in build.gradle file

buildscript {
    ext {
        enunciateVersion = '2.14.0'
    }
}

plugins {
    id "com.webcohesion.enunciate" version "${enunciateVersion}"
}

apply plugin: 'com.webcohesion.enunciate'

configure(enunciate) {
    group 'documentation'
    description 'Generates web service API documentation using Enunciate.'
}

dependencies {
    compileOnly group: 'com.webcohesion.enunciate', name: 'enunciate-core-annotations', version: enunciateVersion
}

task enunciateModule1(type: com.webcohesion.enunciate.gradle.EnunciateTask) {
    def enunciateDistDir = file('build/docs1/javadoc/api')

   doFirst {
        enunciateDistDir.deleteDir()
        enunciateDistDir.mkdirs()
    }

    export('docs1', enunciateDistDir)
    configFileName = 'enunciate.xml'
}

task enunciateModule2(type: com.webcohesion.enunciate.gradle.EnunciateTask) {
    def enunciateDistDir = file('build/docs2/javadoc/api')

    doFirst {
        enunciateDistDir.deleteDir()
        enunciateDistDir.mkdirs()
    }

    export('docs2', enunciateDistDir)
    configFileName = 'enunciate2.xml'
}

It throws error saying

Cannot invoke "org.gradle.api.artifacts.Configuration.getFiles()" because "this.enunciateModuleConfiguration" is null

But when I define the task inside publishing block it works but it can have only one enunciate task

publishing {
    repositories { flatDir { dirs 'build/archive' } }
    tasks.enunciate {
        File enunciateDistDir = file("build/docs1/javadoc/api")
        doFirst {
            enunciateDistDir.deleteDir()
            enunciateDistDir.mkdirs()
        }
        export("docs", enunciateDistDir)
        configFileName = "enunciate.xml"
    }
}

Please help me to get this fixed

stoicflame commented 1 year ago

Duplicated at https://github.com/stoicflame/enunciate-gradle/issues/31