zoukankan      html  css  js  c++  java
  • 传一个jcenter

    格式仿佛是乱了……

    就这样吧……

    =========================================================

    工程的build.gradle下加上

    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
    classpath 'com.github.dcendents:android-maven-plugin:1.2'

    如果gradle版本在2.4.0以上,就把第二个改成[1]

    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

    ——以下加粗内容是需要自己修改的部分

    然后进入库模块的build.gradle,根节点里——以下不特别说明都是在根节点里——添加插件

    apply plugin: 'com.github.dcendents.android-maven'
    apply plugin: 'com.jfrog.bintray'

    定义版本

    version = "0.1"

    添加网站,其中siteUrl是项目官网,没有的话就用Github吧

    def siteUrl = 'https://github.com/<user>/<project>'
    def gitUrl = 'https://github.com/<user>/<project>.git'

    定义包名

    group = "com.user.project"

    添加打包脚本

    // 根节点添加
    install {
        repositories.mavenInstaller {
            // This generates POM.xml with proper parameters
            pom {
                project {
                    packaging 'aar'
                    name 'ProjectName'
                    url siteUrl
                    licenses {
                        license {
                            name 'The Apache Software License, Version 2.0'
                            url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        }
                    }
                    developers {
                        developer {
                            id 'myid'
                            name 'myname'
                            email 'email@host.com'
                        }
                    }
                    scm {
                        connection gitUrl
                        developerConnection gitUrl
                        url siteUrl
                    }
                }
            }
        }
    }

    添加文档和源码打包脚本

    task sourcesJar(type: Jar) {
        from android.sourceSets.main.java.srcDirs
        classifier = 'sources'
    }
    
    task javadoc(type: Javadoc) {
        source = android.sourceSets.main.java.srcDirs
        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    }
    
    task javadocJar(type: Jar, dependsOn: javadoc) {
        classifier = 'javadoc'
        from javadoc.destinationDir
    }
    
    artifacts {
        archives javadocJar
        archives sourcesJar
    }

    然后在local.properties里加上bintray上的用户名和密码,另外这个文件就不要往Github上传了

    bintray.user=username
    bintray.apikey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    然后回到库模块的build.gradle里继续添加

    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    bintray {
        user = properties.getProperty("bintray.user")
        key = properties.getProperty("bintray.apikey")
        configurations = ['archives']
        pkg {
            repo = "maven"
            name = "project name in jcenter"
            websiteUrl = siteUrl
            vcsUrl = gitUrl
            licenses = ["Apache-2.0"]
            publish = true
        }
    }

    于是就修改完成。

    然后依次跑

    javadocJar
    
    sourcesJar
    
    install
    
    bintrayUpload

    这四个脚本任务,用Android Studio右侧的Gradle栏直接双击执行更方便一点。

    不出问题的话Bintray上的last activity里就会显示你已经创建了一个新项目,进去之后把鼠标放在MavenCentral标签上会有提示,点一下get it included,之后等审核就行了。

    但出了问题的话。

    我也救不了你……

    感谢前人指路。给您磕个头。↓

    http://www.cnblogs.com/qianxudetianxia/p/4322331.html

    参考来源:

    [1]:http://stackoverflow.com/questions/30514274/cannot-build-library-project-bintray-gradle-classnotfoundexception

  • 相关阅读:
    win8及win8.1商店出现0X80073CF9的解决办法!
    Ubuntu 14.04 登陆界面循环问题解决
    Java学习笔记-Json
    Java学习笔记-Thread-线程
    git学习笔记
    Java学习笔记-File
    java学习笔记-set
    C# 实验4 数据库
    C#文件处理
    C#-实验3
  • 原文地址:https://www.cnblogs.com/chihane/p/4882912.html
Copyright © 2011-2022 走看看