我正在尝试开发自己的Android Studio Gradle插件。
要获得一些如何实现这一目标的经验,我正在关注this教程
我已经到了修改gradle.build
文件的地步,如下所示: -
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri('repo'))
}
}
}
我似乎在这一行有一个问题: -
repository(url: uri('repo'))
“存储库”带有下划线,我看到此消息: -
'mavenDeployer' cannot be applied to '(groovy.lang.Closure)'
我无法解决此问题
做错了什么?
更新
执行uploadArchives
任务时
我收到了这个错误: -
16:47:32: Executing external task 'uploadArchives'...
:compileJava NO-SOURCE
:compileGroovy FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> java.lang.ExceptionInInitializerError (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.817 secs
Conflicting module versions. Module [groovy-all is loaded in version 2.4.10 and you are trying to load version 2.3.11
16:47:33: External task execution finished 'uploadArchives'.
这是因为我的gradle.build
文件看起来像这样: -
group 'org.group.id'
version '1.0-SNAPSHOT'
apply plugin: 'groovy'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile gradleApi()
compile localGroovy()
}
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri('repo'))
}
}
}
当我删除“compile'org.codehaus.groovy:groovy-all:2.3.11'”并执行uploadArchives任务时,它开始正常工作。虽然我仍然有相同的消息'mavenDeployer'不能应用''(groovy.lang.Closure)'
执行uploadArchives任务时得到的输出是: -
16:52:00: Executing external task 'uploadArchives'...
:compileJava NO-SOURCE
:compileGroovy UP-TO-DATE
:processResources NO-SOURCE
:classes UP-TO-DATE
:jar UP-TO-DATE
:uploadArchives
BUILD SUCCESSFUL
Total time: 0.126 secs
16:52:00: External task execution finished 'uploadArchives'.