of you application. • Alpha - Internal testing • Beta - External testing • Demo - A free trial version • etc…. Each ﬂavor can also share a similar codebase that can vary in behavior based on the product ﬂavor
version and scope of all your project’s external dependencies • Organize into existing conﬁgurations (i.e., scopes) or create your own • Apply dependencies throughout the build using conﬁgurations • Model project relationships using the same declarative style as external dependencies
artifacts from any known binary repository, from public to private to local. • Gradually transition from other build systems by mixing and matching repository types. • Maven Repositories • Maven Central • jCenter • Bintray • Local • Ivy Repositories • Custom & Legacy • Flat Files
parts: • The group identiﬁer: e.g. com.google.dagger or com.52inc • Organization/Company identiﬁer, usually their main domain • The artifact identiﬁer: e.g. dagger or 52Kit • This is the project/library identiﬁer. • The version code: e.g. 2.0.0 or 0.1.+ • This is the version of said library you are trying to load. You can specify the full version number/name or you can use the + identiﬁer to specify the latest for the Major, Minor, or Build version numbers (if you follow Semantic Versioning).
// Remote binary dependency compile 'com.android.support:appcompat-v7:22.0.0' // Local binary dependency compile fileTree(dir: 'libs', include: ['*.jar']) } Here are the most common ways you will see dependencies declared
for different behavior. • Common conﬁgurations are: • compile - Normal conﬁguration • debugCompile - debug build only conﬁgurations • releaseCompile- release build only conﬁgurations • <build_type>Compile • You can prepend any build type your create to the Compile command to limit dependencies to that build type. • provided - This dependency is need for compilation, and it shouldn't be distributed with it. • This is typically used for annotation pre-processors
library, but how do you wield it? • You could import it as a local module in your project // Module dependency compile project(":lib") • You could export the binary .aar ﬁle and load it in your project // Local binary dependency compile fileTree(dir: 'libs', include: ['*.aar']) • Or we can use a public central repository for free!
of knowledge” • Maven itself is a build system/tool with dependency management • Maven is Gradle’s predecessor • Gradle still uses POM (Project Object Model) XML descriptor ﬁles for fetching dependencies
to Maven Central? 1. Create a Sonatype account at https://oss.sonatype.org Add your username and password to your ~/.gradle/gradle.properties global conﬁg ﬁle. NEXUS_USERNAME=r0adkll NEXUS_PASSWORD=somepassword 2. Create a new group JIRA Ticket: http://goo.gl/s8dgmn Here you will want to choose a unique Group Id that can be reused for future projects • com.r0adkll or com.52inc
Enter your email, same sonatype.org email, and other info from prompts. Export the secring.gpg ﬁle $gpg2 —-export-secret-keys > secring.gpg List your keys to get your keyId using this command: $gpg2 —-list-keys firstname.lastname@example.org Add the following data to your global grade.properties ﬁle signing.keyId=BBBBBBBB signing.password=password signing.secretKeyRingFile=/Users/drew.heavner/.gnupg/secring.gpg
To enable the sonatype servers to verify the key, the public key needs to be sent to the standard key servers. $gpg2 —-keyserver pgp.mit.edu —-send-keys A2AAD1B1 Use the save key ID that you used in the previous step
root Then add the following properties of your project to it: VERSION_NAME=2.0.3 VERSION_CODE=7 GROUP=com.r0adkll POM_DESCRIPTION=Some Description Here POM_URL=https://github.com/r0adkll/Slidr POM_SCM_URL=https://github.com/r0adkll/Slidr.git POM_SCM_CONNECTION=scm:email@example.com:r0adkll/Slidr.git POM_SCM_DEV_CONNECTION=scm:firstname.lastname@example.org:r0adkll/Slidr.git POM_LICENCE_NAME=The Apache Software License, Version 2.0 POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo POM_DEVELOPER_ID=r0adkll POM_DEVELOPER_NAME=Drew Heavner
Then add the following properties of your project to it: POM_NAME=Slidable Activity POM_ARTIFACT_ID=slidableactivity POM_PACKAGING=aar This deﬁnes the artifact identiﬁer for each project that we talked about earlier
gradle-mvn-push/master/gradle-mvn-push.gradle' Add the following command to the end of your sub-module build.gradle ﬁle to apply it 7. Build and push your library to maven central $ gradle clean build uploadArchives
repository • Go to https://oss.sonatype.org and Login • Then go to ‘Staging Repositories’ and ﬁnd the entry that has your group Id in it, i.e. com.r0adkll • Then ‘Close’ it and wait for it to ﬁnish • Then ‘Release’ it and wait for it to ﬁnish • It will take up to 2 hours to ﬁnish syncing with the central repository for it to become available
to-use binaries to your application. • Uses GitHub’s tag and releases for versioning • Why? Because publishing to a central repository can be…difﬁcult. • This is actually really cool! Easy to use package repository for Gradle, Maven and Android projects
HTTP & SPDY client for Android and Java • Retroﬁt - A high level type-safe REST client for Android and Java • Dagger - A fast dependency injector for Android and Java • Picasso - A powerful image downloading and caching library for Android • Otto - An enhanced Guava-based event bus with emphasis on Android support. • ButterKnife - View "injection" library for Android. • Timber - A logger with a small, extensible API which provides utility on top of Android's normal Log class. • RxJava - Reactive Extensions for the JVM • Ollie - Compile-time active record ORM for Android with RxJava support • LoganSquare - Screaming fast JSON parsing and serialization library for Android.