java - Gradle Plugin 与 android 发布插件

标签 java android maven plugins gradle

我正在开发一个基于 Android 项目的自定义 gradle 插件。我想通过另一个插件( https://plugins.gradle.org/docs/publish-plugin )发布我的插件,这是我的 build.gradle:

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

最佳答案

抱歉,我真正想做的事情描述如下:

http://code.tutsplus.com/tutorials/creating-and-publishing-an-android-library--cms-24582

发布我的 Android 库,以便任何人都可以通过 gradle 访问它

关于java - Gradle Plugin 与 android 发布插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34814050/

相关文章:

java - 在Java中从文件中读取windows文件名

java - 我使用 Canvas 创建了一个绘图实用程序。有什么方法可以合并 JButtons、JTextFields 等

java - Google App Engine 服务器将数据发送到云数据存储,即使它通过本地主机运行 :8080

java - Android 中的 "foreign application"是什么?

java - 使用 org.zalando.logbook 打印带有 multipart/form-data 的请求

javascript - 已安装 React Native 应用程序但在主屏幕或应用程序屏幕上不可见

java - 非法参数异常 : Only Interface endpoint definitions are supported

android - android Framelayout 中的 ScrollView

java - Maven:确保某些代码仅包含在快照中(而不是发布)?

maven - spring 集成测试无法加载上下文 "Another resource already exists with name dataSource"