Installing 3rd party JAR's

(Thufir) #1

If I put a JAR on github for download, can I then use github itself as a repo which Gradle will pick up? Just me using my own JAR’s.

see also:

(Lance Java) #2

I use github as a poor man’s maven repository here. See the readme which states that maven/gradle must use the “raw” url. Eg:<user>/<project>/master

(Thufir) #3

I can use any project (which builds a library JAR) with this approach? Please elaborate on how to use this. You’re just showing an example where you do this?

(Lance Java) #4
apply plugin: 'java' 
repositories {
   maven {
      url "" 
dependencies {
   testCompile "org.tader:tader-core:0.0.1"

(Thufir) #5

Here’s the build for the library:

thufir@mordor:~/java/hello_api$ gradle clean build
:processResources UP-TO-DATE
:processTestResources UP-TO-DATE

net.bounceme.mordor.hello.TestJunit > testPrintMessage STANDARD_OUT
Hello World

net.bounceme.mordor.hello.TestJunit > testPrintMessage PASSED


Total time: 5.927 secs
thufir@mordor:~/java/hello_api$ jar -tf build/libs/hello_api-0.0.1.jar

The client of this hello world library fails to build:

thufir@mordor:~/java/hello_gradle$ gradle clean build
:processResources UP-TO-DATE

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all dependencies for configuration ‘:testCompile’.

Could not find net.bounceme.mordor:hello_api:0.0.1.
Searched in the following locations:
Required by:

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or
    –debug option to get more log output.


Total time: 22.745 secs

I see that there are binaries at:

which seems odd, because it’s not standard to include binaries in a repo,
is it?

I tried to upload my JAR to releases, but they only support ZIP – JAR
files are ZIP files, so, not sure what to make of that.

How do I upload my JAR file, hello_api, on to releases? Or, do I need to
make a “releases” repo on github and just add the JAR?

(Thufir) #6

I asked on one of the stackoverflow websites:

(Lance Java) #7

I see that there are binaries at:
which seems odd, because it’s not standard to include binaries in a repo, is it?

I’m confused, aren’t you specifically asking how to use github as a repository for your jars? I’m showing you how (and yes this is not what I’d call ‘standard’)

How do I upload my JAR file, hello_api, on to releases? Or, do I need to make a “releases” repo on github and just add the JAR?

Yes, that’s what I’ve done. I add jars via git commit and git push

(Thufir) #8

I see.

Ok, I’ll create a releases repo and upload the JAR. I was hoping that I
was overlooking some way of using github “releases” feature…

(Lance Java) #9

Ah, I finally understand what you want

You could do something like:

dependencies {
   compile fileTree("$buildDir/unzipped") 

ext.downloads = [
   [zip: "http:/", jar: "someJar.jar"], 
   [zip: "http:/", jar: "anotherJar.jar"]
task downloadAndUnzip {
   // setting this input property allows  up to date checking "downloads", downloads
   outputs.dir "$buildDir/unzipped"
   doLast {
      delete fileTree("$buildDir/unzipped") 
      downloads.each {
         // download $ to a temp dir
         // extract $it.jar to $buildDir/unzipped
compileJava.dependsOn downloadAndUnzip

(Thufir) #10

Thanks. I think I got it. What I don’t understand is why you have a “releases” repo. It seems that it is possible to upload JAR files to github through the “releases” tab.

Did this feature recently changed? I would swear that I tried to upload JAR files and was denied by github…

(Lance Java) #11

I initially wanted to host my jars on maven central but found the barrier to entry to high (lots of pom.xml requirements) so I figured out how to host a maven repository on github. I’ve since started hosting one library on bintray and plan to host the rest on bintray when I get the time.

I’m not convinced that the github releases tab can be used as a maven repository. Keep in mind that there’s not only your classes jar that requires hosting, there’s a pom file and also optional javadoc and sources jars too. It’s also likely you’d want more than one library per repository which doesn’t really align with the releases for a single project. Otherwise users of your libraries would need to configure a repository for each library.

(Thufir) #12

for what it’s worth, I went in another direction: jitpack. It seems ok, 90% there:

Thank you for the help. My computer died in the middle of your helping me, so it dragged out a bit.

(Thufir) #13


I took about 99 false paths, of course it was not complex at all, in retrospect.

It’s quite simple, using JitPack. Sample hello world here:

which pulls in another repo. No need to upload JAR’s at all! :slight_smile:

(Lance Java) #14

Interesting… I see jitpack is automatically building your github repo and publishing your artifacts

And my maven built jar is here (not a single line of config required!)