• Android发布依赖到 Jitpack


    前言 

    我们在日常开发中,经常会用到第三方开源的库文件,有的来自JCenter,Maven Central,google等。但是随着JCenter的弃用,现在用的最多的还是Maven Central,google。今天我们就自己亲自发布一个依赖。

    现在网络上有很多的文章,是关于如何发布Android依赖到 Jitpack的,但是大多数都是比较早的,而且随着gradle版本的更新迭代,很多旧的插件已经不支持使用了。比如旧版本的 gradle 可以使用com.github.dcendents:android-maven-gradle-plugin:2.1,但是现在gradle 版本到 7.0 之后,这些插件就不适用了,而且坑很多,我创建了多个项目进行尝试,最终都失败了。也根据网络上的资料配置了jitpack.yml 文件,去指定在 Jitpack 需要编译的Jdk版本,可是还是失败。后来也参照了Jitpack官方文档以及官方项目jitpack.io还是失败,因为我发现Jitpack官方项目都是好几年前的版本,根本无法适用于gradle 版本到7.0 之后的,这一点还是希望,Jitpack官方可以随时更新维护一下项目和使用文档才好。

    废话就不多说,下面开始我们创建自己的发布依赖之旅吧。

    创建项目

    首先,打开AS我们创建一个项目,这个很简单,如下图所示:

    为了后面演示方便,我这里保留了lib模块以及app模块。

    项目创建完毕后,就开始准备工作了,第一步就是要检查我的gradle版本以及gradle插件版本,以及sdk 的版本。

    检查gradle版本

     1、我的gradle版本是 gradle-7.5(项目根目录->gradle->wrapper->gradle-wrapper.properties)

      distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
    
    2、gradle 的插件版本 (项目根目录->build.gradle)
      classpath 'com.android.tools.build:gradle:7.4.2'
    
    3、jdk 采用 1.8.0_221 (这个我们本地的不影响 jitpack 编译,到时候通过 jitpack.yml 去指定编译的 jdk 版本就可以了,提示:jitpack 默认是采用 1.8 的jdk进行编译的)
    
    4、Android Studio Giraffe | 2022.3.1 Patch 1
    Build #AI-223.8836.35.2231.10671973, built on August 17, 2023
    Runtime version: 17.0.6+0-17.0.6b829.9-10027231 aarch64
    VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
    macOS 13.5.1
    GC: G1 Young Generation, G1 Old Generation
    Memory: 1280M
    Cores: 8
    Metal Rendering is ON
    Registry:
        external.system.auto.import.disabled=true
        debugger.new.tool.window.layout=true
        ide.text.editor.with.preview.show.floating.toolbar=false
        ide.experimental.ui=true
    

    注意事项:注意gradle版本,Android studio版本,以及gradle 插件版本要相对应,具体版本对应关系可以参考Google的android开发平台的Android Gradle 插件版本说明。对照对应关系表修改三者的对应关系。如下图所示:

    Android Gradle 插件版本所需的 Gradle 版本:

    Android Gradle 插件和 Android Studio 兼容性

    依赖库的配置

    检查完本地的gradle相关的版本对应关系后,下面我们就可以开始配置依赖库。注意这里的依赖库shapeimageviewlib是我事先已经完善好了的功能模块,这里就以shapeimageviewlib来做依赖配置讲解。

    在做依赖库的配置前,需要满足一下俩个要求。


    1、需要有 jitpack 账号,可以去jitpack官网自行注册
    2、需要有 github 账号 或者是 码云 gitee 账号,可以去码云titee或者github自行注册

    做为一个开发者,我想大家都有GitHub,Gitee,以及Jitpick账户吧,如果没有赶快去注册一个,注册流程很简单,这里就不做解说。

    一:配置shapeimageviewlib的build.gradle

    打开shapeimageviewlib 目录下的 build.gradle 文件,并在 plugins{} 标签中加入 id 'maven-publish'

    1. plugins {
    2. id 'com.android.library'
    3. id 'maven-publish'
    4. }

    然后加入打包源码的task,如下所示:

    1. task generateSourcesJar(type: Jar){
    2. from android.sourceSets.main.java.srcDirs
    3. classifier 'sources'
    4. }

    默认情况下,Gradle将每24小时刷新一次快照依赖项。

    如果版本以-SNAPSHOT后缀结尾,Gradle将自动将依赖项识别为快照。例如:

    1. dependencies {
    2. compile group: "aGroup", name: "anArtifact", version: "1.0-SNAPSHOT"
    3. }

    但是,如果依赖项的版本字符串不以-SNAPSHOT结尾,则需要告知Gradle它是带有changing参数的快照。例如:

    1. dependencies {
    2. compile group: "aGroup", name: "anArtifact", version: "1.0", changing: true
    3. }

    覆盖Gradle下载快照的频率

    覆盖默认的24小时策略的唯一机制是将Gradle配置为更频繁地使依赖项缓存无效(并因此下载新的SNAPSHOT)。例如:

    1. configurations.all {
    2. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
    3. }

    动态版本化的依赖项缓存将需要单独配置

    如果您使用任何动态版本,例如:

    1. dependencies {
    2. compile group: "aGroup", name: "anArtifact", version: "1.+", changing: true
    3. }

    您需要分别为这些依赖项配置缓存无效,如下所示:

    1. configurations.all {
    2. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
    3. resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
    4. }

    建立绩效影响:
    需要注意的一件事是,缓存依赖项的时间越短,Gradle检索该 Artifact 的频率就越高。如果完全禁用了缓存,则它将在每次执行期间获取依赖项。

    关于maven - 有关快照的Gradle缓存问题的解决方案?,我在Stack Overflow上找到一个类似的问题: maven - Solution around gradle cache issues with snapshots? - Stack Overflow

    至于是否使用快照,自己可以更具实际情况而定。

    下面就是最核心的配置了,也就是发布上传配置。

    二:配置上传publishing

    同样操作,我们需要在shapeimageviewlib的build.gradle配置如下:

    1. afterEvaluate {
    2. publishing {
    3. publications {
    4. // Creates a Maven publication called "release".
    5. group = 'com.github.hirezy'
    6. version = '1.0.0'
    7. //发布release版本
    8. release(MavenPublication) {
    9. // Applies the component for the release build variant.
    10. from components.release
    11. //groupId通常是自己的gitee或者GitHub的账户地址
    12. groupId = group
    13. //artifactId通常是指待发布项目的名称,也就是别名
    14. artifactId = 'ShapeImageView'
    15. //version通常是指待发布项目的版本号,这里是写死的,通常我们取项目versionName
    16. version = version
    17. }
    18. //发布debug版本
    19. debug(MavenPublication) {
    20. // Applies the component for the release build variant.
    21. from components.debug
    22. groupId = group
    23. artifactId = 'ShapeImageView-debug'
    24. version = version
    25. }
    26. }
    27. }
    28. }

    注意:网上有博主说,直接把afterEvaluate模块放在android{ //...todo}模块,这里我想特别提醒一下,不能放在android{ //...todo}模块,切记只能放在根模块,就是和android{ //...todo}同级。

    本以为到了这里就万事大吉了,但是后来发布后遇到了下面的问题:

    仔细分析报错日志,发现报了如下俩个错误


    1:Gradle 'publishToMavenLocal' task not found. Please add the 'maven-publish' or 'maven' plugin.

    2:
    * What went wrong:
    A problem occurred configuring root project 'ShapeImageView'.
    > Could not resolve all files for configuration ':classpath'.
       > Could not resolve com.android.tools.build:gradle:7.4.2.
         Required by:
             project :
          > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but:
              - Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally:
                  - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
                  - Other compatible attribute:
                      - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
              - Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
                  - Incompatible because this component declares documentation and the consumer needed a library
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java version (required compatibility with Java 8)
                      - Doesn't say anything about its elements (required them packaged as a jar)
                      - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
              - Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
                  - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
                  - Other compatible attribute:
                      - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
              - Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
                  - Incompatible because this component declares documentation and the consumer needed a library
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java version (required compatibility with Java 8)
                      - Doesn't say anything about its elements (required them packaged as a jar)
                      - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
    
    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 533ms
    Build tool exit code: 0
    Looking for artifacts...
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    Looking for pom.xml in build directory and ~/.m2
    2023-09-06T17:54:45.227812499Z
    Exit code: 0
    
    ⚠️ ERROR: No build artifacts found

    可是我分明已经加入了maven-publish插件,为什么会报Gradle 'publishToMavenLocal' task not found。

    而且我明明也指定了jdk版本为未java11啊,为什么说我是用的是java8了。这真的一度让我怀疑人生,不敢在相信Jitpack了。

    1. compileOptions {
    2. sourceCompatibility JavaVersion.VERSION_11
    3. targetCompatibility JavaVersion.VERSION_11
    4. }

    可是本本着不服输的想法我再次查阅了jitpack.io文档,终于让我找到了解决办法。如下图所:

    然后,我试着加入jitpack.yml文件,内容如下:

    1. jdk:
    2. - openjdk11
    3. before_install:
    4. - sdk install java 11.0.10-open
    5. - sdk use java 11.0.10-open
    6. install:
    7. - echo "Running a custom install command"
    8. - ./gradlew clean install -xtest
    9. env:
    10. MYVAR: "custom environment variable"

    结果神奇的发现,问题2解决了,但是问题依然存在。

    后来试着在android{ //...todo}模块加入如下指令,竟然神奇发现,编译竟然通过了:

    1. publishing {
    2. singleVariant("release")
    3. singleVariant("debug")
    4. }
    5. buildTypes {
    6. release {
    7. minifyEnabled false
    8. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    9. }
    10. debug{
    11. minifyEnabled false
    12. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    13. }
    14. }

    走到这一步,我真的要吐血了,甚至有冲动不想在使用Jitpick了,在这里真心希望jitpack团队可以及时更新文档,更新simple。

    三:将代码同步到 github/gitee上

    我们只要按照以下步骤执行命令即可把我们工程上传到GitHub或者gitee上,这里不做过多讲解。

    echo "”>>README.md
         git init
         git add .
         git commit -m "first commit"
         git remote add origin git@github.com:hirezy/ShapeImageView.git
         git push -u origin master

    注意:

    github 现在推送代码,是采用了 token 的形式,可以去后端生成 token,然后去 android studio 等工具使用,否则无法提交代码,原本的密码账号的形式,已经被废弃了。可以参考:GitHub不再支持密码验证解决方案:SSH免密与Token登录配置,讲解的非常详细。

    代码同步完成后,我们就去创建一个 Releases 版本,如下所示图:

    这里是我提前已经准备好的一个Releases,版本号是v.1.0.0,下面我带大家创建一个新的Release版本,版本是v1.0.1

    四:创建Releases

    创建Releases版本前,我们需要先创建一个Tag,创建Tag命令如下:

    git tag v1.0.1
    

    提交这个tag到远程。

    git push origin v1.0.1
    

    提交成功,就会看到下图所示信息,提示我们新创建的tag已经成功提交远程仓库:

    如果,你对git的Tag操作不熟悉,可以参考Git优雅使用:git tag操作

    查看远程仓库,你会发现,远程会多了一个Tag,我们只需点击图上圈着的Release按钮,就会跳转到创建页面,如果非第一次创建,可以看到如下页面,点击【Draft a new release】按钮去创建一个版本。(注意:我这里你看见有Release有俩个,那是因为我我提交了一个配置文件,每当我提交Tag到远程,Github会自动帮我Releases出一个对应的版本,后面我会给大家分享这个config文件)。

    当我们点击【Release】按钮,就会来到如下界面

    因为不是第一次创建,所以点击【Draft a new release】按钮去创建一个版本,如下图所示:

    五:如何快速生成Releases:

    上面介绍了,生成Releases版本,除了通过打Tag方式来生产Releases,还可以通过配置config文件,在我们提交本地Tag到远程的时候系统自动帮我们快速生成对应版本的Releases

    怎么做了,其实很简单,我们只需要在我们的项目的根目录新建这样的文件目录就好了,如下图所示:

    并在release.yml这个文件加入如下内容即可:

    1. name: publish release
    2. on:
    3. push:
    4. tags:
    5. - "*"
    6. jobs:
    7. release:
    8. runs-on: ubuntu-latest
    9. permissions:
    10. contents: write
    11. steps:
    12. - uses: ncipollo/release-action@v1
    13. with:
    14. generateReleaseNotes: true

    注意:一定要在项目的根目录下.github/workflows目录下新建release.yml文件,并加上面的内容方可自动快速帮我们创建releases.

    六:将代码关联到 Jitpack,生成依赖库。

    准备工作完毕后,我们直接登陆到Jitpack,然后复制我们的项目仓库地址,可以是https形式,也可以是SSH形式,如下图所示:

    这里我采用ssh方式。复制地址后,来到Jitpack,在下图所示输入栏输入我们复制的项目地址信息,接着点击 【Loop up】 按钮,接着可以看到你Github上,最新的几个版本在这里(我这里是因为我之前上传过,所以有这么多),分别点击右侧的【Get it】按钮,如果没有看见loading,则多点几次,刷网页也可以。

    在依次点击【Loop up】 按钮 -》Get it】按钮,等待loading介绍即可:

    编译结束,我们就会看到下图所示的结果,如果编译成功,就会看到log一列对应的版本就是绿色的,如果编译失败,就会看到log所在列会有红色失败提示,我们只需要点击那个像书籍一样的按钮,就可以看见相信的编译信息,如下图所示:

    编译日志如下:

    1. Build starting...
    2. Start: Thu Sep 7 10:34:10 UTC 2023 91be4e2ca99f
    3. Git:
    4. v1.0.0-0-g9130e5c
    5. commit 9130e5cf40ee555c45bf763a07572fc166f2bece
    6. Author: hirezy
    7. Date: Thu Sep 7 11:29:26 2023 +0800
    8. rename file
    9. Init SDKMan
    10. Found Android manifest
    11. Android SDK version: . Build tools:
    12. Found gradle
    13. Gradle build script
    14. Found gradle version: 7.5.
    15. Using gradle wrapper
    16. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    17. Downloading https://services.gradle.org/distributions/gradle-7.5-bin.zip
    18. .10%.20%.30%.40%.50%.60%.70%.80%.90%.100%
    19. ------------------------------------------------------------
    20. Gradle 7.5
    21. ------------------------------------------------------------
    22. Build time: 2022-07-14 12:48:15 UTC
    23. Revision: c7db7b958189ad2b0c1472b6fe663e6d654a5103
    24. Kotlin: 1.6.21
    25. Groovy: 3.0.10
    26. Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
    27. JVM: 11.0.2 (Oracle Corporation 11.0.2+9)
    28. OS: Linux 4.14.63-xxxx-std-ipv6-64 amd64
    29. 0m3.920s
    30. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    31. openjdk version "11.0.2" 2019-01-15
    32. OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
    33. OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
    34. Getting tasks: ./gradlew tasks --all
    35. Tasks: publishToMavenLocal,
    36. Running: ./gradlew clean -Pgroup=com.github.hirezy -Pversion=v1.0.1 -xtest -xlint assemble publishToMavenLocal
    37. Checking the license for package Android SDK Build-Tools 30.0.3 in /opt/android-sdk-linux/licenses
    38. License for package Android SDK Build-Tools 30.0.3 accepted.
    39. Preparing "Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)".
    40. "Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)" ready.
    41. Installing Android SDK Build-Tools 30.0.3 in /opt/android-sdk-linux/build-tools/30.0.3
    42. "Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)" complete.
    43. "Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)" finished.
    44. Checking the license for package Android SDK Platform 30 in /opt/android-sdk-linux/licenses
    45. License for package Android SDK Platform 30 accepted.
    46. Preparing "Install Android SDK Platform 30 (revision: 3)".
    47. "Install Android SDK Platform 30 (revision: 3)" ready.
    48. Installing Android SDK Platform 30 in /opt/android-sdk-linux/platforms/android-30
    49. "Install Android SDK Platform 30 (revision: 3)" complete.
    50. "Install Android SDK Platform 30 (revision: 3)" finished.
    51. > Task :clean UP-TO-DATE
    52. > Task :app:clean UP-TO-DATE
    53. > Task :shapeimageviewlib:clean UP-TO-DATE
    54. > Task :app:preBuild UP-TO-DATE
    55. > Task :app:preDebugBuild UP-TO-DATE
    56. > Task :shapeimageviewlib:preBuild UP-TO-DATE
    57. > Task :shapeimageviewlib:preDebugBuild UP-TO-DATE
    58. > Task :shapeimageviewlib:preReleaseBuild UP-TO-DATE
    59. > Task :app:preReleaseBuild UP-TO-DATE
    60. > Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
    61. > Task :shapeimageviewlib:compileDebugAidl NO-SOURCE
    62. > Task :app:compileDebugAidl NO-SOURCE
    63. > Task :shapeimageviewlib:packageDebugRenderscript NO-SOURCE
    64. > Task :app:compileDebugRenderscript NO-SOURCE
    65. > Task :app:dataBindingMergeDependencyArtifactsDebug
    66. WARNING: [Processor] Library '/home/jitpack/.gradle/caches/modules-2/files-2.1/com.github.JessYanCoding/AndroidAutoSize/v1.2.1/a44df9822e0cb91242358f070ef813714fd81c05/AndroidAutoSize-v1.2.1.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
    67. Example of androidX reference: 'androidx/fragment/app/FragmentManager$FragmentLifecycleCallbacks'
    68. Example of support library reference: 'android/support/v4/app/FragmentManager$FragmentLifecycleCallbacks'
    69. > Task :app:generateDebugResValues
    70. > Task :app:generateDebugResources
    71. > Task :shapeimageviewlib:compileDebugRenderscript NO-SOURCE
    72. > Task :shapeimageviewlib:generateDebugResValues
    73. > Task :shapeimageviewlib:generateDebugResources
    74. > Task :shapeimageviewlib:packageDebugResources
    75. > Task :app:generateDebugBuildConfig
    76. > Task :app:javaPreCompileDebug
    77. > Task :app:mapDebugSourceSetPaths
    78. > Task :shapeimageviewlib:writeDebugAarMetadata
    79. > Task :app:createDebugCompatibleScreenManifests
    80. > Task :app:mergeDebugResources
    81. > Task :app:checkDebugAarMetadata
    82. > Task :app:dataBindingGenBaseClassesDebug
    83. > Task :app:extractDeepLinksDebug
    84. > Task :shapeimageviewlib:extractDeepLinksDebug
    85. > Task :shapeimageviewlib:processDebugManifest
    86. > Task :shapeimageviewlib:compileDebugLibraryResources
    87. > Task :app:processDebugMainManifest
    88. > Task :app:processDebugManifest
    89. > Task :shapeimageviewlib:generateDebugBuildConfig
    90. > Task :shapeimageviewlib:javaPreCompileDebug
    91. > Task :app:mergeDebugShaders
    92. > Task :app:compileDebugShaders NO-SOURCE
    93. > Task :app:generateDebugAssets UP-TO-DATE
    94. > Task :shapeimageviewlib:mergeDebugShaders
    95. > Task :shapeimageviewlib:compileDebugShaders NO-SOURCE
    96. > Task :shapeimageviewlib:generateDebugAssets UP-TO-DATE
    97. > Task :shapeimageviewlib:packageDebugAssets
    98. > Task :shapeimageviewlib:parseDebugLocalResources
    99. > Task :app:mergeDebugAssets
    100. > Task :app:processDebugManifestForPackage
    101. > Task :app:compressDebugAssets
    102. > Task :app:processDebugJavaRes NO-SOURCE
    103. > Task :shapeimageviewlib:processDebugJavaRes NO-SOURCE
    104. > Task :shapeimageviewlib:bundleLibResDebug NO-SOURCE
    105. > Task :shapeimageviewlib:generateDebugRFile
    106. > Task :app:checkDebugDuplicateClasses
    107. > Task :app:processDebugResources
    108. > Task :shapeimageviewlib:compileDebugJavaWithJavac
    109. > Task :shapeimageviewlib:bundleLibCompileToJarDebug
    110. > Task :app:desugarDebugFileDependencies
    111. > Task :app:compileDebugJavaWithJavac
    112. > Task :app:mergeDebugJavaResource
    113. > Task :shapeimageviewlib:bundleLibRuntimeToJarDebug
    114. > Task :app:mergeDebugJniLibFolders
    115. > Task :app:dexBuilderDebug
    116. > Task :shapeimageviewlib:mergeDebugJniLibFolders
    117. > Task :app:mergeLibDexDebug
    118. > Task :shapeimageviewlib:mergeDebugNativeLibs NO-SOURCE
    119. > Task :shapeimageviewlib:copyDebugJniLibsProjectOnly
    120. > Task :app:mergeProjectDexDebug
    121. > Task :app:validateSigningDebug
    122. > Task :app:mergeDebugNativeLibs NO-SOURCE
    123. > Task :app:stripDebugDebugSymbols NO-SOURCE
    124. > Task :app:writeDebugAppMetadata
    125. > Task :app:writeDebugSigningConfigVersions
    126. > Task :shapeimageviewlib:compileReleaseAidl NO-SOURCE
    127. > Task :shapeimageviewlib:mergeReleaseJniLibFolders
    128. > Task :shapeimageviewlib:mergeReleaseNativeLibs NO-SOURCE
    129. > Task :shapeimageviewlib:stripReleaseDebugSymbols NO-SOURCE
    130. > Task :shapeimageviewlib:copyReleaseJniLibsProjectAndLocalJars
    131. > Task :shapeimageviewlib:compileReleaseRenderscript NO-SOURCE
    132. > Task :shapeimageviewlib:generateReleaseResValues
    133. > Task :shapeimageviewlib:extractDeepLinksForAarRelease
    134. > Task :shapeimageviewlib:generateReleaseBuildConfig
    135. > Task :shapeimageviewlib:generateReleaseResources
    136. > Task :shapeimageviewlib:packageReleaseResources
    137. > Task :shapeimageviewlib:parseReleaseLocalResources
    138. > Task :shapeimageviewlib:javaPreCompileRelease
    139. > Task :shapeimageviewlib:mergeReleaseShaders
    140. > Task :shapeimageviewlib:compileReleaseShaders NO-SOURCE
    141. > Task :shapeimageviewlib:generateReleaseAssets UP-TO-DATE
    142. > Task :shapeimageviewlib:processReleaseManifest
    143. > Task :shapeimageviewlib:packageReleaseAssets
    144. > Task :shapeimageviewlib:packageReleaseRenderscript NO-SOURCE
    145. > Task :shapeimageviewlib:prepareLintJarForPublish
    146. > Task :shapeimageviewlib:prepareReleaseArtProfile
    147. > Task :shapeimageviewlib:generateReleaseRFile
    148. > Task :shapeimageviewlib:processReleaseJavaRes NO-SOURCE
    149. > Task :app:mergeExtDexDebug
    150. > Task :shapeimageviewlib:extractReleaseAnnotations
    151. > Task :shapeimageviewlib:compileReleaseJavaWithJavac
    152. > Task :shapeimageviewlib:mergeReleaseGeneratedProguardFiles
    153. > Task :shapeimageviewlib:mergeReleaseConsumerProguardFiles
    154. > Task :app:compileReleaseAidl NO-SOURCE
    155. > Task :shapeimageviewlib:writeReleaseAarMetadata
    156. > Task :shapeimageviewlib:mergeReleaseJavaResource
    157. > Task :app:compileReleaseRenderscript NO-SOURCE
    158. > Task :shapeimageviewlib:syncReleaseLibJars
    159. > Task :shapeimageviewlib:bundleReleaseLocalLintAar
    160. > Task :app:dataBindingMergeDependencyArtifactsRelease
    161. > Task :app:generateReleaseResValues
    162. > Task :app:generateReleaseResources
    163. > Task :app:generateReleaseBuildConfig
    164. > Task :app:mapReleaseSourceSetPaths
    165. > Task :app:createReleaseCompatibleScreenManifests
    166. > Task :app:extractDeepLinksRelease
    167. > Task :shapeimageviewlib:extractDeepLinksRelease
    168. > Task :app:checkReleaseAarMetadata
    169. > Task :app:javaPreCompileRelease
    170. > Task :app:processReleaseMainManifest
    171. > Task :app:processReleaseManifest
    172. > Task :app:extractProguardFiles
    173. > Task :shapeimageviewlib:bundleLibResRelease NO-SOURCE
    174. > Task :shapeimageviewlib:bundleLibRuntimeToJarRelease
    175. > Task :shapeimageviewlib:bundleLibCompileToJarRelease
    176. > Task :app:packageDebug
    177. > Task :shapeimageviewlib:compileReleaseLibraryResources
    178. > Task :app:createDebugApkListingFileRedirect
    179. > Task :app:assembleDebug
    180. > Task :shapeimageviewlib:createFullJarRelease
    181. > Task :shapeimageviewlib:writeReleaseLintModelMetadata
    182. > Task :app:mergeReleaseJniLibFolders
    183. > Task :shapeimageviewlib:copyReleaseJniLibsProjectOnly
    184. > Task :app:mergeReleaseNativeLibs NO-SOURCE
    185. > Task :app:stripReleaseDebugSymbols NO-SOURCE
    186. > Task :app:extractReleaseNativeSymbolTables NO-SOURCE
    187. > Task :app:mergeReleaseNativeDebugMetadata NO-SOURCE
    188. > Task :app:desugarReleaseFileDependencies
    189. > Task :app:checkReleaseDuplicateClasses
    190. > Task :app:mergeReleaseResources
    191. > Task :app:dataBindingGenBaseClassesRelease
    192. > Task :app:mergeReleaseShaders
    193. > Task :app:compileReleaseShaders NO-SOURCE
    194. > Task :app:generateReleaseAssets UP-TO-DATE
    195. > Task :app:mergeReleaseAssets
    196. > Task :app:compressReleaseAssets
    197. > Task :app:processReleaseJavaRes NO-SOURCE
    198. > Task :app:collectReleaseDependencies
    199. > Task :app:sdkReleaseDependencyData
    200. > Task :app:writeReleaseAppMetadata
    201. > Task :app:writeReleaseSigningConfigVersions
    202. > Task :shapeimageviewlib:stripDebugDebugSymbols NO-SOURCE
    203. > Task :shapeimageviewlib:copyDebugJniLibsProjectAndLocalJars
    204. > Task :shapeimageviewlib:extractDebugAnnotations
    205. > Task :shapeimageviewlib:extractDeepLinksForAarDebug
    206. > Task :shapeimageviewlib:mergeDebugGeneratedProguardFiles
    207. > Task :shapeimageviewlib:mergeDebugConsumerProguardFiles
    208. > Task :shapeimageviewlib:prepareDebugArtProfile
    209. > Task :app:processReleaseManifestForPackage
    210. > Task :shapeimageviewlib:mergeDebugJavaResource
    211. > Task :shapeimageviewlib:syncDebugLibJars
    212. > Task :app:mergeReleaseArtProfile
    213. > Task :shapeimageviewlib:bundleDebugAar
    214. > Task :shapeimageviewlib:assembleDebug
    215. > Task :shapeimageviewlib:bundleReleaseAar
    216. > Task :shapeimageviewlib:mapReleaseSourceSetPaths
    217. > Task :shapeimageviewlib:mergeReleaseResources
    218. > Task :shapeimageviewlib:generateMetadataFileForDebugPublication
    219. > Task :shapeimageviewlib:generatePomFileForDebugPublication
    220. > Task :shapeimageviewlib:publishDebugPublicationToMavenLocal
    221. > Task :shapeimageviewlib:generateMetadataFileForReleasePublication
    222. > Task :shapeimageviewlib:generatePomFileForReleasePublication
    223. > Task :shapeimageviewlib:publishReleasePublicationToMavenLocal
    224. > Task :shapeimageviewlib:publishToMavenLocal
    225. > Task :app:processReleaseResources
    226. > Task :shapeimageviewlib:verifyReleaseResources
    227. > Task :app:compileReleaseJavaWithJavac
    228. > Task :app:mergeExtDexRelease
    229. > Task :app:dexBuilderRelease
    230. > Task :shapeimageviewlib:assembleRelease
    231. > Task :shapeimageviewlib:assemble
    232. > Task :app:mergeReleaseJavaResource
    233. > Task :app:optimizeReleaseResources
    234. > Task :app:mergeDexRelease
    235. > Task :app:compileReleaseArtProfile
    236. > Task :app:packageRelease
    237. > Task :app:createReleaseApkListingFileRedirect
    238. > Task :app:lintVitalAnalyzeRelease
    239. > Task :app:lintVitalReportRelease
    240. > Task :app:lintVitalRelease
    241. > Task :app:assembleRelease
    242. > Task :app:assemble
    243. BUILD SUCCESSFUL in 1m 28s
    244. 137 actionable tasks: 134 executed, 3 up-to-date
    245. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    246. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    247. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    248. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    249. Note: Some input files use or override a deprecated API.
    250. Note: Recompile with -Xlint:deprecation for details.
    251. Note: [1] Wrote GeneratedAppGlideModule with: [com.bumptech.glide.integration.okhttp3.OkHttpLibraryGlideModule]
    252. Note: /home/jitpack/build/app/src/main/java/com/hirezy/shapeimageview/ScaleTypeActivity.java uses or overrides a deprecated API.
    253. Note: Recompile with -Xlint:deprecation for details.
    254. Note: /home/jitpack/build/app/src/main/java/com/hirezy/shapeimageview/MyImageLoader.java uses unchecked or unsafe operations.
    255. Note: Recompile with -Xlint:unchecked for details.
    256. Note: Some input files use or override a deprecated API.
    257. Note: Recompile with -Xlint:deprecation for details.
    258. Note: [1] Wrote GeneratedAppGlideModule with: [com.bumptech.glide.integration.okhttp3.OkHttpLibraryGlideModule]
    259. Note: /home/jitpack/build/app/src/main/java/com/hirezy/shapeimageview/ScaleTypeActivity.java uses or overrides a deprecated API.
    260. Note: Recompile with -Xlint:deprecation for details.
    261. Note: /home/jitpack/build/app/src/main/java/com/hirezy/shapeimageview/MyImageLoader.java uses unchecked or unsafe operations.
    262. Note: Recompile with -Xlint:unchecked for details.
    263. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    264. Publication: com.github.hirezy:ShapeImageView-debug:1.0.0
    265. Publication: com.github.hirezy:ShapeImageView:1.0.0
    266. Build tool exit code: 0
    267. Looking for artifacts...
    268. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    269. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    270. Looking for pom.xml in build directory and ~/.m2
    271. Found artifact: com.github.hirezy:ShapeImageView-debug:1.0.0
    272. Found artifact: com.github.hirezy:ShapeImageView:1.0.0
    273. Found artifact: com.github.hirezy:ShapeImageView-debug:1.0.0
    274. Found artifact: com.github.hirezy:ShapeImageView:1.0.0
    275. 2023-09-07T10:36:21.971608584Z
    276. Exit code: 0
    277. ✅ Build artifacts:
    278. com.github.hirezy.ShapeImageView:ShapeImageView:v1.0.1
    279. com.github.hirezy.ShapeImageView:ShapeImageView-debug:v1.0.1
    280. Files:
    281. com/github/hirezy/ShapeImageView/ShapeImageView/v1.0.1
    282. com/github/hirezy/ShapeImageView/ShapeImageView/v1.0.1/ShapeImageView-v1.0.1.aar
    283. com/github/hirezy/ShapeImageView/ShapeImageView/v1.0.1/ShapeImageView-v1.0.1.module
    284. com/github/hirezy/ShapeImageView/ShapeImageView/v1.0.1/ShapeImageView-v1.0.1.pom
    285. com/github/hirezy/ShapeImageView/ShapeImageView/v1.0.1/ShapeImageView-v1.0.1.pom.md5
    286. com/github/hirezy/ShapeImageView/ShapeImageView/v1.0.1/ShapeImageView-v1.0.1.pom.sha1
    287. com/github/hirezy/ShapeImageView/ShapeImageView-debug/v1.0.1
    288. com/github/hirezy/ShapeImageView/ShapeImageView-debug/v1.0.1/ShapeImageView-debug-v1.0.1.aar
    289. com/github/hirezy/ShapeImageView/ShapeImageView-debug/v1.0.1/ShapeImageView-debug-v1.0.1.module
    290. com/github/hirezy/ShapeImageView/ShapeImageView-debug/v1.0.1/ShapeImageView-debug-v1.0.1.pom
    291. com/github/hirezy/ShapeImageView/ShapeImageView-debug/v1.0.1/ShapeImageView-debug-v1.0.1.pom.md5
    292. com/github/hirezy/ShapeImageView/ShapeImageView-debug/v1.0.1/ShapeImageView-debug-v1.0.1.pom.sha1

    七:如何使用

    首先,在要引用的项目的根目录的build.gradle文件下加入JitPack repository(Add the JitPack repository to your build file)

    1. allprojects {
    2. repositories {
    3. ...
    4. maven { url 'https://jitpack.io' }
    5. }
    6. }

    接着Add the dependency:

    1. dependencies {
    2. implementation 'com.github.hirezy:ShapeImageView:Tag'
    3. }

    注意:如果你使用的是1.0.0版本就是

    1. dependencies {
    2. implementation 'com.github.hirezy:ShapeImageView:1.0.0'
    3. }

    使用1.0.1版本就是

    1. dependencies {
    2. implementation 'com.github.hirezy:ShapeImageView:1.0.1'
    3. }

    依次类推。

    总结:

    要想成功顺利的将我们的lib发布到Jitpack,必须具备以下条件:

    1. 首先要注册相关账号,比如GitHub账号,Gitee账户,Jitpack账户
    2. 掌握基本的git命令,以及属性groovy编译工具的语法
    3. 正确配置gradle版本,gradle插件版本,Android studio 版本的对应关系
    4. 总重要的一点就是要有足够的耐心,发现问题,分析问题,解决问题
  • 相关阅读:
    C++11特性——类型推导
    Windows环境下安装Hadoop3.1.0全过程(超详细手把手一条龙教学)
    1.Linux环境
    开发者专访|我从「人间地狱」的算法岗内卷中,倔强地踏出了一条路 前路漫漫,星芒万里
    基于SSM的图书商城网站设计与实现
    《Coding Monkey的自我修养》之MyBatis批量插入数据的三种方法
    《c++ Primer Plus 第6版》读书笔记(3)
    JAVA情侣飞行棋小程序:增强情侣间的默契与感情
    《单片机原理及应用》-片外拓展
    SpringBoot整合Redis的方法分享
  • 原文地址:https://blog.csdn.net/ljx1400052550/article/details/132740197