2013-05-08 103 views
0

我试图推送到Gradle任务中的远程git仓库。我发现的最好的方法是使用插件Gradle-Git在这里找到:https://github.com/ajoberstar/gradle-git自定义Gradle任务失败 - 无法找到GitPush

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

这是我的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

您还没有跟上的插件站点上的说明

为了增加一些东西到构建本身,你需要有一个buildscript

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

谢谢,这个作品完美!我认为,因为我已经有了存储库和依赖关系块,我可以将这些行添加到这些部分,而不是创建单独的构建脚本块。 – twbbas 2013-05-08 18:05:37

相关问题