来自:http://www.gcssloop.com/course/jitpack-sources-javadoc

很早之前写过一篇用JitPack发布Android开源库的文章,有小伙伴反馈说发布到JitPack上的开源库没有文档注释,使用起来很不方便,这是我的失误,上一篇文章只是讲解了如何使用JitPack发布开源库,最终发布的只有arr(即编译好的动态链接库),不仅没有文档注释(Javadoc),也没有源码(sources),本次就教大家如何在发布同时添加上注释和源码。

由于JitPack本身就是一个自定义Maven仓库,所以与上传Maven的配置方式基本一样。

配置项目的 build.gradle

项目的 build.gradle 配置和上一篇一样,没有变化。

buildscript { 
  dependencies {
    // 重点就是下面这一行(上面两行是为了定位这一行的添加位置)
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 

配置 Library 的 build.gradle

完整示例(重点内容已经用注释标出):

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven' // 添加这个

group='com.github.GcsSloop'	// 指定group,com.github.<用户名>

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
}

//---------------------------------------------

// 指定编码
tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
}

// 打包源码
task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    failOnError  

相关文章:

  • 2021-11-27
  • 2021-12-14
  • 2021-11-27
  • 2021-11-27
  • 2021-06-27
  • 2021-12-09
  • 2021-11-17
猜你喜欢
  • 2022-02-21
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2021-05-25
  • 2021-10-09
相关资源
相似解决方案