如何在新创建插件中应用现有插件

时间:2018-02-14 14:06:07

标签: gradle groovy build.gradle gradlew

我正在构建一个插件,但是我想问一下,可以在一个实现插件接口的groovy类中应用另一个现有的插件。

例如,编写一个报告插件,我想使用现有的插件“com.github.qwazer.markdown-confluence”如何在我的插件中使用它。

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.????????
}

现有的插件有这样的扩展名,

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')
        }
    }
}

我试过了,

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')
            }
        }
    }
}

没用。

0 个答案:

没有答案