我正在开发基于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