自定义Gradle Publishing插件

时间:2018-03-16 20:45:25

标签: gradle plugins publish nexus

我正在尝试创建一个插件来捕获我们在多个应用程序中执行的一些自定义发布。

这是自定义插件:

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.tasks.bundling.Zip

class NexusDeployPlugin implements Plugin<Project> {
    @Override
    void apply(Project project) {

        project.tasks.create('zipManifests', Zip) {
            baseName project.name
            from 'manifests'
        }


        project.tasks.withType(MavenPublishPlugin) {
            project.plugins.apply(MavenBasePublishPlugin)

            dependsOn project.assemble

            project.publishing {
                publications {
                    mavenJava(MavenPublication) {
                        artifactId project.name
                        from components.java

                        artifact zipManifests {
                            artifactId project.name
                            classifier 'manifests'
                        }
                    }

                }
            }
            project.repositories {
                maven {
                    url "http://myrepo/content/repositories/fakeLocation/"
                    credentials {
                        username 'username'
                        password 'password'
                    }
                    authentication {
                        basic(BasicAuthentication)
                    }
                }
            }
        }
    }

}

需要此项目的build.gradle只有:

apply plugin: NexusDeployPlugin

所有内容都会编译,但当我执行./gradlew tasks时,发布任务不会显示。

有什么想法吗?

0 个答案:

没有答案