I know that people use GitHub to deploy Maven artifacts (in a new branch) but since we are using Gradle I would like to know if there is a simple way of handling those dependecies as well?
We have different little projects that are independent but used by our main project and we want to manage those dependencies without including them locally.
Thank you.
There is an unofficial gradle plugin called Gradle Git Repo plugin that claims to do what you're looking for. Note however, that I did not play with it myself to verify that it works.
You could use JitPack to include your GitHub projects as dependencies. The idea is that JitPack provides a Maven repository where each package comes from a GitHub project.
It doesn't require that you upload files so it's quite easy to use. Instead when you request a file it builds it from source code.
There are two requirements to start using:
1. You need to have a build file in your project (Gradle or Maven)
2. You shoud create a GitHub release so that your project gets a version
Related
I have an Android private project (not open source) hosted on GitHub and I need to link it by an Android gradle dependency. I saw a couple of services to dot it like Jitpack.io but it's not free for private repositories. Do you know any free service to do it? Or do you know the way to host my own private project dependency?
You can use Git Submodules - it is absolutely free and quite easy to use.
I think, you have two ways to do it:
You can setup your own Artifactory server, secure it and host
your dependencies there. You should be able to publish new artifact from the GitHub repo. Nevertheless, it requires some work and machine, where you can host your repositories. I found an article regarding that at: https://inthecheesefactory.com/blog/how-to-setup-private-maven-repository/en.
You can generate *.jar or *.aar file from your library and put it manually to your project into the lib/ directory. Unfortunately, it's not so convenient like using Artifactory or Maven Central. Nevertheless, you can automate your build in such case via Bash scripts, Gradle and/or Jenkins, so manual work (like copying files) can be avoided.
In addition to the above answers, I want to add that you can host your Android artifacts on GitHub packages. and I would recommend this tutorial as a start for doing this.
I'm using Android Studio 1.5.1 to build a self-contained library (no external dependencies). Let's call it "myLib.aar".
I've been asked to modify my Gradle build to push the .AAR file into the company's private, local Artifactory repository. I am an experienced developer but know very little about Java repositories.
There are a lot of search hits on this topic, but none of them have so far resulted in a solution for my particular situation. Even more troubling, I can't find any two posts that implement a solution the same way.
I'm further confused why one can't just use an/the Artifactory plugin. Apparently one must ALSO use a Maven plugin -- but why? Some use third-party Maven plugins, some use something which appears to be built into Android Studio.
So my question is simply what lines to add to which Gradle files in order to push my .AAR file into Artifactory?
You should use Artifactory plugin.
Re Maven plugin. The role of Maven plugin is to generate metadata about your package (the pom.xml file). Other option is using Ivy plugin to generate the metadata in an alternative format (the ivy.xml file). One way or another your package needs metadata. Select one of them (by applying maven, maven-publish, ivy, or ivy-publish plugin).
The instructions about Artifactory plugin show configuration examples for all the possible options.
JFrog GitHub repo contains project examples for all the possible options.
Hope that helps.
I am with JFrog, the company behind Bintray and [artifactory], see my profile for details and links.
I have created a new module in Android Studio, and wrote my code in it. Now i want to upload it on github and get a gradle dependency which others can include in their project and use my library. How can i get it?
PS. I know how to use git, i just don't know how to upload just the library module and get the gradle dependency.
The esiest way is to create a git repository in Github and upload it there.
After that, you can use jitpack.io to use it with gradle.
The long old way, it is to create a Bintray project, and deploy it at MavenCentral and/or JCentre.
What do you need to do is upload your project to Bintray or sonatype
See here a good tutorial:
how-to-upload-library-to-jcenter-maven-central-as-dependency
I would like to open source a library project that I am working on in android studio (hosted on GitHub) and allow others to include the project as a dependency.
Example:
dependencies {
compile 'com.test:myproject:1.0'
}
I've done some research, and have only discovered how to create a module and import it locally within my project. Does anyone know the necessary steps to take to achieve what I want?
Basicly you can publish your app on a public repository like maven or jCenter. The easiest way is to published on bintray, it's free for open source public library. You can use the following library to help you
Also, look into jitpack.io. It is easily the quickest way for getting a JVM projects up and ready especially if you're already using Github. Here's the extra docs for it as well.
I'm a beginner in Android programing, and I'm working with android studio...now i wander what is the best way for installing open sources libraries from gitHub.
my question is from organization principles point of view-
should i create a new package for every library and put all the library source code as is in that package? should the package be in the source.main.java folder?? (the one that the android studio creates automaticly).
sorry for the dumb question...it's just that im taking my first baby steps in a big scale program and i don't want to loose my head in the future because of bad organization practices.
There's no right answer to this question. A few wrong ways to do it, but common sense will guide you.
My advice:
Start by having the source of this open source code checked into your company's source control system somewhere and capable of being built or re-built as needed. Not necessarily in your project, but just getting the code checked in so it can't be lost or confused with the original author's ever evolving changes on GitHub.
As to how you consume it, you have several options.
Build the open source in it's own project (checked into source control, but separate from your main project). Then just take the drop of compiled files (.class, .jar, .lib, etc...) and check that into your main project. This is the most flexible option if you don't think you are ever going to need to change the open source code that often. Has the side benefit of being managed for several projects.
Drop the source code as-is directly into your project. This means you will always be rebuilding the code. This gives the most flexibility with evolving and changing the the code specific to your project needs.
There's probably hybrid solutions of these options as well.
The bottom line is that whatever you use needs to be copied and building in your own system. Because the code you pulled down from GitHub could go away or change significantly at any time.
A simple solution would be to use JitPack to import those GitHub projects into your gradle build.
First you need to add the repository:
repositories {
maven { url "https://jitpack.io" }
}
and then all the GitHub repositories as dependencies:
dependencies {
compile 'com.github.RepoOwner:Repo:Version'
// more dependencies...
}
Behind the scenes JitPack will check out the code and compile it.
I think you are looking for this. If you are using eclipse, you should check this
If you are looking for adding jar file to your lib, you can simply create a lib folder in your project and add jar file into the library and you must add the line compile files('jarfile.jar') in the build file(gradle build). If you are using eclipse you can follow this
By the way, creating a package for each library and putting all library source codes doesn't look sane to me. It is almost equivalent to recreating the project. I'm sure that it is not the proper approach.
If the third-party code is packaged as a .jar or a .aar and made available in public-facing maven repository (e.g. maven central), then you should add the library as a dependency in your build.gradle file.
If it is not available as a maven/gradle dependency, you could add the library's code to your project as suggested in other answers here. I have never liked that solution at all.
You could also build the .jar or .aar and add that to your project's lib directory, as also suggested by other answers here. For a small, simple project with few dependencies, that might make sense.
What I like to do for larger, longer-lived projects, is to set up my own Nexus server (a Maven repo server), and put the third-party dependencies there.