Skip to content

namnh-0652/MultipleJitPackLibs

Repository files navigation

MultipleJitPackLibs

Testing release multiple libraries to Jitpack

Add maven plugin to project

In settings.gradle

pluginManagement {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' } // Add this maven
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' } // Add this maven
    }
}

In root project build.gradle

buildscript {
    dependencies {
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    }
}

Create gradle.properties to manage each library version

groupId=com.github.USER.REPOS
artifactId=YOUR_ATIFACT_ID
versionName=YOUR_ATIFACT_VERSION_NAME
versionCode=YOUR_ATIFACT_VERSION_CODE

For each library/build.gradle

plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
    id 'maven-publish' // => Add this plugin
}
group = findProperty('groupId') // set groupId for your library

android {
    namespace 'your.library.namespace'
    compileSdk 33

    defaultConfig {
        minSdk 23 // your minSdk
        targetSdk 33 // your targetSdk
        versionName = findProperty('versionName')
        versionCode = findProperty('versionCode')

        // other settings
    }
}

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release
                groupId = findProperty('groupId')
                artifactId = findProperty('artifactId')
                version = findProperty('versionName')
            }
        }
    }
}

Setting Java version

By default, Jitpack uses Java 8. If your library uses other Java version, create file jitpack.yml to root project.

// Example for Java 11
jdk:
  - openjdk11

To exclude specific module

By default, Jitpack provides some default env & support you to custom env, see here for detail. You can exclude any submodule by ignore it in settings.gradle by checking specific env value.

For example, we can ignore Jitpack build sample module like:

// Build sample if not build by JITPACK
if (!System.env.JITPACK)
    include ':sample'

Create release tag to publish library to Jitpack

From your repository create a release tag to publish your library to Jitpack

About

Testing release multiple libraries to Jitpack

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages