Skip to content

Instantly share code, notes, and snippets.

@jitpack-io
Last active October 14, 2025 07:11
Show Gist options
  • Select an option

  • Save jitpack-io/f928a858aa5da08ad9d9662f982da983 to your computer and use it in GitHub Desktop.

Select an option

Save jitpack-io/f928a858aa5da08ad9d9662f982da983 to your computer and use it in GitHub Desktop.
Publish an existing jar file to jitpack
install:
- FILE="-Dfile=jars/my-library.jar"
- mvn install:install-file $FILE -DgroupId=com.github.user -DartifactId=repo -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
@jitpack-io
Copy link
Copy Markdown
Author

jitpack-io commented Mar 26, 2019

For this to work the root directory also needs to have a pom.xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
			    http://maven.apache.org/maven-v4_0_0.xsd">
	<groupId>com.github.user</groupId>
	<artifactId>repo</artifactId>
	<version>1.0</version>
</project>

@mpdude
Copy link
Copy Markdown

mpdude commented Apr 2, 2019

@jitpack-io Do I need to repeat this for all the .jars? Should they all share the same artifactId, or use a unique one for each jar?

@ozymand1as
Copy link
Copy Markdown

But what about .aars? Do I just need to change all instances of jar to aar?

@matyasforian
Copy link
Copy Markdown

dont you need mvn deploy to deploy things to a remote? mvn install installs it locally.

@JRWilding
Copy link
Copy Markdown

this appears to be a file you add to the root of your repo that reconfigures the jitpack build process to use this artifact instead (or as well as? not sure) of building one itself

@jitpack-io how do we dynamically define the version?

@hemanthkaipaa
Copy link
Copy Markdown

Always getting this erro.

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.github.hemanthkaipaa:sapostore:1.1.1.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.github.hemanthkaipaa:sapostore:1.1.1.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.github.hemanthkaipaa:sapostore:1.1.1.
Show Details
Affected Modules: app

@hemanthkaipaa
Copy link
Copy Markdown

hemanthkaipaa commented Jan 23, 2020

I have a dependency of 3rd party aar. I'm not aware how to deal with it.

@kekru
Copy link
Copy Markdown

kekru commented Jun 5, 2020

Isn't there any kind of authentication required?
Can everyone upload artifacts named with every github username?
This would be a huge security issue

@jitpack-io
Copy link
Copy Markdown
Author

@kekru the groupId and artifactId will be overwritten by JitPack at the time of build. If you put another username then the groupId will still be 'com.github.YourUsername'

@a914-gowtham
Copy link
Copy Markdown

a914-gowtham commented Mar 16, 2021

@jitpack-io I published an aar by following that example. but after I used the dependency url and I can't reach the classes that exist on the aar file. it doesn't even available in library folder

Screenshot from 2021-03-16 23-38-32

@chk017
Copy link
Copy Markdown

chk017 commented Apr 15, 2025

@jitpack-io I published an aar by following that example. but after I used the dependency url and I can't reach the classes that exist on the aar file. it doesn't even available in library folder

Screenshot from 2021-03-16 23-38-32

@a914-gowtham @jitpack-io same for me as well. I have published jar file, but class files are not shown.
If you have any solution by now, Please suggest me. Please refer to the screenshot below for your reference.
image

@farfromrefug
Copy link
Copy Markdown

farfromrefug commented Oct 13, 2025

this is how i managed to do it with a simple gradle build:
build.gradle

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.12.1' // match your Gradle version
    }
}

plugins {
    id 'de.undercouch.download' version '5.1.1'
    id 'maven-publish'
}

// Pass GitHub release URL and version as properties
def libVersion = project.findProperty("version") ?: System.getenv("VERSION") ?: ""
def aarUrl = project.findProperty("aarUrl") ?: System.getenv("AAR_URL") ?: ""

if (!aarUrl) {
    throw new GradleException("You must provide -PaarUrl=<url-to-aar>")
}
if (!libVersion) {
    throw new GradleException("You must provide -Pversion=<version>")
}
def downloadedAar = layout.buildDirectory.file("downloads/external-lib.aar")

tasks.register('downloadExternalAar', de.undercouch.gradle.tasks.download.Download) {
    src aarUrl
    dest downloadedAar
    onlyIfModified true
    doLast {
        println "Downloaded AAR: ${downloadedAar.get().asFile}, size: ${downloadedAar.get().asFile.length()} bytes"
    }
}
publishing {
   
    publications {
        release(MavenPublication) {
            groupId = 'com.carto'
            artifactId = 'carto-mobile-sdk'
            version = libVersion

            artifact(downloadedAar) {
                builtBy(tasks.named("downloadExternalAar"))
                extension = 'aar'
            }
        }
    }

    repositories {
        maven {
            // This points to the Maven local repository that JitPack reads
            url = uri(System.getProperty("user.home") + "/.m2/repository")
        }
    }
}

and jitpack.yml

jdk:
  - openjdk17

gradle:
  wrapper: true

install:
  - ./gradlew publish
env:
   VERSION: "5.0.0-rc.13"
   AAR_URL: "https://github.com/Akylas/mobile-sdk/releases/download/v5.0.0-rc.13/carto-mobile-sdk-android-5.0.0-rc.13.aar"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment