自定义Gradle任务失败 - 无法找到GitPush

时间:2013-05-08 17:28:25

标签: git groovy push task gradle

我正在尝试在Gradle任务中推送到远程git仓库。我找到的最好方法是使用此处找到的插件Gradle-Git:https://github.com/ajoberstar/gradle-git

我基本上只是试图能够运行推送任务,然后从那里配置它以在我的项目中使用。

这是我的build.gradle脚本的样子。

apply plugin: 'eclipse'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'base'

import org.ajoberstar.gradle.git.tasks.*

repositories {
    mavenCentral()
    maven {
        url "[my custom repository repo]"
    }
}

dependencies {
    compile 'org.ajoberstar:gradle-git:0.4.0' 
}

task push(type: GitPush) {
    println "Test"
}

我的错误是

FAILURE: Build failed with an exception.

* Where:
Build file '[my_path]\build.gradle' line: 19

* What went wrong:
A problem occurred evaluating root project 'Name'.
> Could not find property 'GitPush' on root project 'Name'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

并使用--stacktrace运行会在此处生成异常日志:http://pastebin.com/uqjf5U5k

1 个答案:

答案 0 :(得分:1)

您没有按照插件网站上的说明进行操作

要向构建本身添加内容,您需要有buildscript

buildscript {
  repositories { mavenCentral() }
  dependencies { classpath 'org.ajoberstar:gradle-git:0.4.0' }
}