我正在開發基於Android項目的自定義gradle插件。我想通過另一個插件發佈我的插件(https://plugins.gradle.org/docs/publish-plugin)這是我的build.gradle:Gradle插件發佈插件與Android
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: "com.gradle.plugin-publish"
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath "com.gradle.publish:plugin-publish-plugin:0.9.3"
}
}
repositories {
jcenter()
}
group = 'com.myplugin'
version = '1.0-SNAPSHOT'
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri('../repo'))
}
}
}
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 18
targetSdkVersion 19
}
lintOptions {
abortOnError false
}
}
dependencies {
compile gradleApi()
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
pluginBundle {
website = 'http://www.example.com/'
description = 'Welcome to bla bla'
tags = ['test', 'test']
plugins {
PluginName {
id = 'com.something'
displayName = 'My Plugin'
}
}
}
當我運行此:
./gradlew uploadArchives
我得到這個錯誤:
Parallel execution with configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'mylib'.
> The 'java' plugin has been applied, but it is not compatible with the Android plugins.
* 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: 1.543 secs
訪問它顯然插件,發佈插件添加Java插件,您已經添加了Android插件不喜歡。我認爲他們是不相容的。我很好奇 - 爲什麼你的插件項目有Android插件,如果你不打算建立一個Android的lib /應用程序? – RaGe
我實際上是在創建一個android lib –
那麼這是一個android lib還是一個gradle插件? gradle插件將被打包成一個jar,我想象一個android lib將會是aar?你如何爲插件創建一個單獨的項目,這取決於你的Android庫,但只是一個Java(或Groovy)項目? – RaGe