当前位置: 首页 > 知识库问答 >
问题:

将android模块上传到bintray并链接到jcenter

章涵容
2023-03-14

update2:供参考,这是我的gradle.build in my module

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

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner     "android.support.test.runner.AndroidJUnitRunner"

    }
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-  core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
    compile 'com.android.support:appcompat-v7:25.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.volley:volley:1.0.0'
}

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
}

group = 'xxxx'
version = '0.0.1'

install {
    repositories.mavenInstaller {
        pom.project {
            name 'android-dbpatcher'
            description 'A library for updating SQLite database in android.'
            url 'https://sirqo.bintray.com/Android-DBPatcher'
            inceptionYear '2016'

            packaging 'aar'
            groupId 'xxxx'
            artifactId 'android-dbpatcher'
            version '0.0.1'

            licenses {
                license {
                    name "The Apache Software License, Version 2.0"
                    url "http://www.apache.org/licenses/LICENSE-2.0.txt"
                    distribution "repo"
                }
            }

            developers {
                developer {
                    id  'xxxx'
                    name 'xxxxx'
                    email 'xxxxxx@gmail.com'
                }
            }
        }
    }
}

Properties bintrayProperties = new Properties()
    bintrayProperties.load(project.rootProject.file('bintray.properties').newDa    taInputStream())

bintray {
    user = bintrayProperties.getProperty('user')
    key = bintrayProperties.get('key')
    configurations = ['archives']
    pkg {
        repo = 'Android-DBPatcher'
        name = 'android-dbpatcher'
        userOrg = 'xxxx'
        vcsUrl = 'https://github.com/sirqo/android-dbpatcher'
        publish = true
        version {
            name = '0.0.1'
            desc = 'Android SQLite Database Patcher'
            released = new Date()
            vcsTag = 'v0.0.1'
        }
    }
}

共有1个答案

符渊
2023-03-14

所以我想通了。为了参考,我将分享我的代码。

对于我的项目gradle.build

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id "com.jfrog.bintray" version "1.7.3"
}

allprojects {
    repositories {
        jcenter()
    }

}

task clean(type: Delete) {
    delete rootProject.buildDir
}

对于我的模块gradle.build

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

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.volley:volley:1.0.0'
}

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
}

group = 'xxxx' //bintray org/group name
version = '0.0.1' //version

install {
    repositories.mavenInstaller {
        pom.project {
            name 'xxxxx' //package name
            description 'A library for updating SQLite database in android.'
            url 'xxxxx'
            inceptionYear '2016'

            packaging 'aar'
            groupId 'xxxx' //group/org id
            artifactId 'xxxx' //your android module name
            version '0.0.1'

            licenses {
                license {
                    name "The Apache Software License, Version 2.0"
                    url "http://www.apache.org/licenses/LICENSE-2.0.txt"
                    distribution "repo"
                }
            }

            developers {
                developer {
                    id  'xxxxx' //developer username
                    name 'xxxxxx' //developer name
                    email 'xxxxxx@gmail.com' //developer email
                }
            }
            scm {
                connection 'xxxxxx' // YOUR GIT REPO
                developerConnection 'xxxxxx' // YOUR GIT REPO
                url 'xxxxxxx' // YOUR SITE

            }
        }
    }
}

Properties bintrayProperties = new Properties()
bintrayProperties.load(project.rootProject.file('bintray.properties').newDataInputStream())

bintray {
    user = bintrayProperties.getProperty('user')
    key = bintrayProperties.get('key')
    configurations = ['archives']
    pkg {
        repo = 'xxxxxx' //Bintray repository
        name = 'xxxxxx' //Bintray Package name
        userOrg = 'xxxxx'
        licenses = ['Apache-2.0']
        vcsUrl = 'xxxxxxxx'
        publish = true
        version {
            name = '0.0.1' //version
            desc = 'xxxxxx' //Description
            released = new Date()
            vcsTag = 'v0.0.1'
        }
    }
}
  • 如果存在某些错误,您可以在命令中附加--debug并重新输入该命令以跟踪错误

//如果没有其他失败,则发出此命令。/gradlew bintrayUpload*如果出现错误,则可以使用此命令并附加--debug来跟踪它。

在所有这些之后,您将收到一封电子邮件或其他东西,然后您可以继续下载您的库在其他项目。编码快乐!

 类似资料:
  • 我正在为NodeJS开发两个模块,第一个名为,第二个名为。第二个依靠第一个工作。我正在同时开发这两个模块,我想全局链接,这样我就可以像在npm注册表上一样使用它,并且我只是全局安装了它。要执行此NPM文档,我需要使用,但它不起作用。 文件验证人: 文件的模块: 首先,我将模块链接到全局: 如果我没有弄错的话,它创建了我的模块的全局引用,现在我可以在计算机中的任何地方使用这个模块。 然后我转到另一个

  • 问题内容: 我一直在寻找这个东西,对我没有任何帮助。 我正在尝试将图像从android应用上传到java servlet并将其保存在服务器中。我发现的每个解决方案都不适合我。 我的代码当前正在执行的操作:android应用程序正在将图像发送到servlet,当我尝试保存该图像时,该文件已创建,但它是空的:( 谢谢你的帮助! 我在android客户端中的代码(i_file是设备上的文件位置): 我在

  • 问题内容: 我是新手,我的项目需要pySerial和feedparser模块。我在跑美洲狮。 我遵循了以下教程,以便可以升级到python 2.7.3,然后使用上述模块。 http://hackercodex.com/guide/python-virtualenv-on-mac-osx-mountain- lion-10.8/ 我按照本教程进行操作,直到安装了pip。而不是安装Virtualenv

  • 问题内容: 我在main.storyboard上创建了一个UI元素,需要隐藏该元素,直到游戏结束,并且一旦玩家点击屏幕将其关闭即可。Main.storyboard链接到GameViewController,因此我所有的IBOutlet和IBActions都在其中,而我所有的游戏代码都在GameScene中。我如何将视图控制器链接到场景,以便弹出图像和按钮仅在游戏结束时出现。非常感谢您的帮助,我已经

  • Gradle是一个android模块,定义了几种自定义构建类型 Gradle是一个仅限于kotlin/java的模块: 模块A取决于模块B: 在源代码中,我需要知道使用它的确切方式,的当前

  • 问题内容: 我的HTML代码的摘录。 单击链接时蜂鸣器打开的模态: 是否有正确的方法将我的ID传递给模式? 问题答案: 传递,从数据库获取记录以进行传递并以模式显示的简单解决方案是; 简单的解决方案 模态通话按钮 模态HTML 将以下模式HTML放在上述调用按钮所在的页面内(最好在页面底部) 现在创建一个PHP文件并命名 通过模式调用按钮调用该文件 要删除模式中的数据或换句话说在打开下一个记录而不