Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lot of fixes and update with current version of gradle #4

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
184 changes: 86 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
**Publish an aar file to jCenter with Gradle:**
**Publish an aar file to jCenter and Maven Central with Gradle:**
----------------------------------------------------------------------
Firstly I thank [JBaruch](http://stackoverflow.com/users/402053/jbaruch), who patiently drove me all along the process of publishing (see the [stackoverflow question](http://stackoverflow.com/questions/28383415/publish-an-aar-file-to-maven-central-with-gradle-not-working)).

Now I'm going to list how to publish an Android libray to jCenter and then syncronize it with Maven Central:

1. I use "Android Studio" and I have this simple android lib that I would like to be available on maven: [CircularImageView](https://github.com/lopspower/CircularImageView)

1. I use "Android Studio" and I have this simple android lib that I would like to be available on maven: [Android-Update-Checker](https://github.com/danielemaddaluno/Android-Update-Checker)
2. In the library folder(module) I have the lib code abovementioned. And applying in the build.gradle of this folder `apply plugin: 'com.android.library'` I got as output an .aar in the build/outputs/aar/ directory of the module's directory

2. In the library folder(module) I have the lib code abovementioned. And applying in the build.gradle of this folder `apply plugin: 'com.android.library'` i got as output an .aar in the build/outputs/aar/ directory of the module's directory
Warning: The module name is very important. So I renamed my module "CircularImageView-Library" in "circularimageview". Indeed, this name is your artifactId. ([Previous probleme](http://stackoverflow.com/questions/33104152/publish-github-android-library-to-maven-central/33121335))

3. Register to [Sonatype](https://issues.sonatype.org/secure/Dashboard.jspa), i registered with username `danielemaddaluno`
3. Register to [Sonatype](https://issues.sonatype.org/secure/Dashboard.jspa), I registered with username `lopspower`

4. In the [Sonatype OSS Repository](https://issues.sonatype.org/secure/Dashboard.jspa) I registered a project opening a new Issue:<br>
`Create → Create Issue → Community Support - Open Source Project Repository Hosting → New Project → with groupid com.github.danielemaddaluno`<br>
`Create → Create Issue → Community Support - Open Source Project Repository Hosting → New Project → with groupid com.github.lopspower`<br>
Remember that "only one JIRA issue per top-level groupId is necessary. You have all the necessary permissions to deploy any new artifacts to this groupId or any sub-groups".

5. Register to Bintray with a `username`, the one used by me is: `danielemaddaluno`
5. Register to Bintray with a `username`, the one used by me is: `lopspower`

6. Enable the automatically signing of the uploaded content:<br>
from Bintray [profile url](https://bintray.com/profile/edit) → GPG Signing → copy paste your gpg armored `public` and `private` keys.<br>
You can find respectively these two keys in files `public_key_sender.asc` and `private_key_sender.asc`
if you execute the following code (the `-a` or `--armor` option in `gpg`is used to generate ASCII-armored key pair):

UNIX/MAC:
You can find respectively these two keys in files `public_key_sender.asc` and `private_key_sender.asc`
if you execute the following code (the `-a` or `--armor` option in `gpg`is used to generate ASCII-armored key pair):

``` bash
gpg --gen-key # generates the key pair
gpg --list-keys # get your PubKeyId (this value is used in the line below)
gpg --keyserver hkp://pool.sks-keyservers.net --send-keys PubKeyId # publish your Key
gpg -a --export daniele.maddaluno@gmail.com > public_key_sender.asc
gpg -a --export-secret-key daniele.maddaluno@gmail.com > private_key_sender.asc
gpg -a --export lopez.mikhael@gmail.com > public_key_sender.asc
gpg -a --export-secret-key lopez.mikhael@gmail.com > private_key_sender.asc
```

WINDOWS:
Generated your gpg key with [http://www.gpg4win.org/](http://www.gpg4win.org/)

7. In the same [web page](https://bintray.com/profile/edit) you can configure the auto-signing from:<br>
`Repositories → Maven → Check the "GPG Sign uploaded files automatically" → Update`
Expand All @@ -37,8 +44,8 @@ if you execute the following code (the `-a` or `--armor` option in `gpg`is used

10. Add these two lines to the `build.gradle` in the root of your project
``` gradle
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1'
```
So that your `build.gradle` in the root looks like this:
``` gradle
Expand All @@ -47,9 +54,9 @@ So that your `build.gradle` in the root looks like this:
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1'
}
}

Expand All @@ -65,15 +72,14 @@ So that your `build.gradle` in the root looks like this:
apply plugin: 'com.android.library'

android {
compileSdkVersion 21
buildToolsVersion "21.0.0"
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
//applicationId "com.madx.updatechecker.lib"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0.0"
minSdkVersion 11
targetSdkVersion 23
versionCode 4
versionName "2.0.1"
}
buildTypes {
release {
Expand All @@ -85,30 +91,27 @@ So that your `build.gradle` in the root looks like this:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jsoup:jsoup:+'
}
```
To this one:


``` gradle
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"

// This is the library version used when deploying the artifact
version = "1.0.0"
version = "2.0.1"

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
//applicationId "com.madx.updatechecker.lib"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0.0"
minSdkVersion 11
targetSdkVersion 23
versionCode 4
versionName version
}
buildTypes {
release {
Expand All @@ -120,14 +123,11 @@ So that your `build.gradle` in the root looks like this:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jsoup:jsoup:1.8.1'
}


def siteUrl = 'https://github.com/danielemaddaluno/Android-Update-Checker' // Homepage URL of the library
def gitUrl = 'https://github.com/danielemaddaluno/Android-Update-Checker.git' // Git repository URL
group = "com.github.danielemaddaluno.androidupdatechecker" // Maven Group ID for the artifact

def siteUrl = 'https://github.com/lopspower/CircularImageView' // Homepage URL of the library
def gitUrl = 'https://github.com/lopspower/CircularImageView.git' // Git repository URL
group = "com.mikhaellopez" // Maven Group ID for the artifact

install {
repositories.mavenInstaller {
Expand All @@ -137,8 +137,8 @@ So that your `build.gradle` in the root looks like this:
packaging 'aar'

// Add your description here
name 'Android Update Checker'
description = 'The project aims to provide a reusable instrument to check asynchronously if exists any newer released update of your Android app on the Store.'
name 'com.mikhaellopez:circularimageview' // TODO
description = 'Description of your project HERE' // TODO
url siteUrl

// Set your license
Expand All @@ -150,16 +150,15 @@ So that your `build.gradle` in the root looks like this:
}
developers {
developer {
id 'danielemaddaluno'
name 'Daniele Maddaluno'
email 'daniele.maddaluno@gmail.com'
id 'lopspower' // TODO
name 'Mikhael Lopez' // TODO
email 'lopez.mikhael@gmail.com' // TODO
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl

}
}
}
Expand Down Expand Up @@ -197,7 +196,7 @@ So that your `build.gradle` in the root looks like this:
pkg {
repo = "maven"
// it is the name that appears in bintray when logged
name = "androidupdatechecker"
name = "com.mikhaellopez:circularimageview" // TODO
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
Expand All @@ -207,82 +206,71 @@ So that your `build.gradle` in the root looks like this:
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
}
// mavenCentralSync {
// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
// user = properties.getProperty("bintray.oss.user") //OSS user token
// password = properties.getProperty("bintray.oss.password") //OSS user password
// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
// }
}
}
}
```

12. Add to the `local.properties` in the root of the project the following lines (remember that this file should never be uploaded on your public repository):

``` gradle
bintray.user=<your bintray username>
bintray.apikey=<your bintray api key>

bintray.gpg.password=<your gpg signing password>
bintray.oss.user=<your sonatype username>
bintray.oss.password=<your sonatype password>
```

13. Add to the PATH the default gradle 2.2.1 actually used by "Android Studio", for example:
``` bash
sudo gedit .bashrc
```
Add to the bottom of file `.bashrc` the following line (verify your gradle path):<br> `PATH=$PATH:/etc/android-studio/gradle/gradle-2.2.1/bin`

14. Open "Android Studio" terminal and execute:
13. Open "Android Studio" terminal and execute:

``` bash
gradle bintrayUpload
gradlew bintrayUpload
```

15. From [Bintray](https://bintray.com/) → My Recent Packages → androidupdatechecker (this is here only after the execution of the previous point 14 ) → Add to Jcenter → Check the box → Group Id = "com.github.danielemaddaluno.androidupdatechecker".<br>
This will request a review and public listing of your library on jCenter repository.
14. From [Bintray](https://bintray.com/) → My Recent Packages → com.mikhaellopez:circularimageview (this is here only after the execution of the previous point 13) → Add to Jcenter → Check the box → Group Id = "com.mikhaellopez".<br>
This will request a review and public listing of your library on jCenter repository. This request can be quite long. You will receive a confirmation email but you can check [jcenter.bintray.com](http://jcenter.bintray.com/) to see if your library is syncronise.

16. Finally Sync all with Maven Central following: Bintray → My Recent Packages → androidupdatechecker → Maven Central → Sync.
Now you can import your library with jcenter like that :

17. Now your library should be automatically imported both from Maven Central and from Bintray, you can import with something like this:<br>
**Automatically with Gradle**
build.gradle (Project):
``` gradle
dependencies {
repositories {
mavenCentral()
// maven {
// url 'http://dl.bintray.com/danielemaddaluno/maven/'
// }
}
compile 'com.github.danielemaddaluno.androidupdatechecker:library:+'
repositories {
jcenter()
}
```
If you use the default of Android Studio, jcenter() you could simply import like this (for me it doesn't work without the exactly version, i.e. with the plus gives me an error)
``` gradle

build.gradle (Module):
``` gradle
dependencies {
compile 'com.github.danielemaddaluno.androidupdatechecker:library:1.0.3'
compile 'com.mikhaellopez:circularimageview:2.0.1'
}
```
**Automatically with Maven**
``` xml

<project>
...
<repositories>
<repository>
<id>danielemaddaluno</id>
<name>Daniele Maddaluno Bintray Repository</name>
<url>http://dl.bintray.com/danielemaddaluno/maven/</url>
</repository>
</repositories>
...
<dependecies>
<dependency>
<groupId>com.github.danielemaddaluno.androidupdatechecker</groupId>
<artifactId>library</artifactId>
<version>1.0.0</version>
</dependency>
</dependecies>
...
</project>
If you use the default of Android Studio, jcenter() you could simply import like this (for me it doesn't work without the exactly version, i.e. with the plus gives me an error). To do that you need to sync with Maven Central (Next Step)

``` gradle
dependencies {
compile 'com.mikhaellopez:circularimageview:+'
}
```

15. Finally Sync all with Maven Central following: Bintray → My Recent Packages → com.mikhaellopez:circularimageview → Maven Central → Sync. You can check [repo.maven.apache.org/maven2/](https://repo.maven.apache.org/maven2/) to see if your library is syncronise.

Warning : It isn't clear but the "User token password" actually corresponds to the password of your Sonatype account.

16. Now your library should be automatically imported both from Maven Central and from Bintray, you can import with something like this:<br>

build.gradle (Project):
``` gradle
repositories {
mavenCentral()
}
```

build.gradle (Module):
``` gradle
dependencies {
compile 'com.mikhaellopez:circularimageview:+'
}
```