How to apply existing plugin in newly creating plugin

plugins

(AmrutaD) #1

I’m building a plugin, however I want to ask wether it’s possible to apply another existing plugin in a groovy class which Implements the Plugin interface.

For eg writing a report plugin and I want to use an existing plugin “com.github.qwazer.markdown-confluence” how do I use it in my plugin.

class ReportPlugin impelments Plugin<Project>{
//some code

// here I would like to call the existing plugin with its properties defined in extension how do i write this
project.plugins.????????
}

existing plugin has extensions like this,

confluence {
    authentication 'base64-encoded user:pass'
    restApiUrl 'https://confluence.acme.com/rest/api/'
    spaceKey 'SAMPLE'
    sslTrustAll true
    pageVariables = ['project.name': project.name]

    pages {
        page {
            parentTitle  'projectName'
            title "projectName-${project.version}"
            srcFile  file('release-notes.md')
            labels = ['release-notes', project.name]
        }
        page {
            parentTitle = 'Home'
            title = 'projectName'
            srcFile = file('README.md')
        }
    }
}

I tried

class ReportPlugin implements Plugin<Project>{
project.configure(project){
          apply plugin: 'com.github.qwazer.markdown-confluence'

 confluence {
        authentication 'base64-encoded user:pass'
        restApiUrl 'https://confluence.acme.com/rest/api/'
        spaceKey 'SAMPLE'
        sslTrustAll true
        pageVariables = ['project.name': project.name]

        pages {
            page {
                parentTitle  'projectName'
                title "projectName-${project.version}"
                srcFile  file('release-notes.md')
                labels = ['release-notes', project.name]
            }
            page {
                parentTitle = 'Home'
                title = 'projectName'
                srcFile = file('README.md')
            }
        }
    }
}

But didnt work