How to use a Bintray user repo (correctly) for a dependency from gradle?
Asked Answered
S

1

7

This is more of a 'am I doing it right' question.

Quick back story: I have built a gradle plugin (in a standalone gradle/groovy project). I am using it in a different java project. The client project was referring to it via something like:

buildScript
{
      flatDir {
            dirs '../my-gradle-plugin/build/libs'
      }

      classpath name: 'gradle-my-plugin'
}

So I didn't want the relative reference to the plugin project (nor make plugin part of the client). I thought I'd see if I can put it up in a BinTray and refer to like a 'real' plugin.

So set up BinTray and after much trial and error, I got it to work, but I don't think I did correct. Here is what I did:

  1. Made a maven repo: MyStuff
  2. Made a package: gradle-my-plugin
  3. Made a version: 0.1
  4. uploaded a file for that version, but specified a target path like "org/fhw/gradle-my-plugin/0.1"

My buildScript block looks like this:

buildScript {
    repositories {
        maven {
            url 'http://dl.bintray.com/my-bintray-id/MyStuff
        }
    }    
    dependencies {
        classpath 'org.fhw:gradle-my-plugin:0.1'
   }
}

So what I am curious about is the hack I did with the target on BinTray. W/O this, the proper path wasn't in place for uploaded files/jars (for a version).

So is this a correct, process for BinTray and Gradle dependencies?

Stroke answered 8/9, 2014 at 0:22 Comment(2)
so far so okay. But you can ease the process by using the gradle bintray plugin for uploading your plugin to bintray. Using the plugin, you won't need to manually create paths etc.Fadiman
Yeah, I am familiar with the plugin(s); but haven't tried them yet. Also I am familiar with some chatter that maybe one of the plugins is superfluous (github.com/davidmc24/gradle-bintray-plugin) and that vanilla gradle can (with mavenPublisher, perhaps) publish to BinTray. The other plugin (github.com/bintray/gradle-bintray-plugin) is that what you are suggesting? So I am a nexus user, and found it awkward to have to specify the path with my 'group id'; while nexus seems to hide this. This makes me think I am doing BinTray wrong.Stroke
K
5

What you did is OK, although using the official Bintray plugin could make your life much easier. It's getting better by the day, adding features and doing more and more work for you (e.g. it can lazily create a package and a version for you if they aren't exist).

Another thing to consider is including your package to jcenter. One of the benefits of this inclusion will be a free account in oss.jfrog.org for your development process. It's a free Artifactory account (like nexus, but so much better).

Please also note that you can include your plugin the Gradle plugins portal. Once you do that, the usage of your plugin is down to

plugins {
  id "org.fhw.gradle-my-plugin" version "0.1"
}

Here are the inclusion instructions.

P.S. Regarding the group id that nexus 'hides' - Bintray is not limited to Maven artifacts layout, you can deploy files in any layout that you need, that's why you need to provide the path when uploading files via the UI. Saying that, when Bintray encounters a pom file among the uploaded files, it sets up the path automatically. The path is also optional when using maven or maven-publish with the Bintray plugin - it calculates the path from artifacts once it's clear that those are Maven files.

Kirven answered 14/9, 2014 at 7:2 Comment(2)
So my biggest concern was that I wanted my 'client' build files to have normal gradle deps stuff. I am ok with futzing on the publish step to make it work 'naturally'. Having said that, I plan to dig into the plugin; now that I know the how the basic process works manually. Oh agreed about nexus v. artifactory; I find the latter much easier to work with. (Oh and I plan to jcenter it -- when it matures a bit more). THANKS FOR YOUR FEED BACK.Stroke
You're welcome to ask for inclusion even for non-mature package (or package without versions at all). We want to help you develop it and give you the oss.jfrog.org for that purpose, but only when you're included in jcenter.Kirven

© 2022 - 2024 — McMap. All rights reserved.