-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Building your own Android library
We can use the Maven plugin to release snapshots or releases.
apply plugin: 'maven'
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getOutputDir() {
if (isReleaseBuild()) {
return "${project.buildDir}/releases"
} else {
return "${project.buildDir}/snapshots"
}
}
def getDestUrl() {
if (isReleaseBuild()) {
return "s3://yourmavenrepo-bucket/android/releases"
} else {
return "s3://yourmavenrepo-bucket/android/snapshots"
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file:///" + getOutputDir())
}
}
}
task copyToS3(type: Exec) {
commandLine 'aws', 's3', 'cp', '--recursive', getOutputDir(), getDestUrl()
}
copyToS3.dependsOn uploadArchivesCurrently the Gradle/Amazon S3 integration does not support IAM roles. You will need to provide an access key or secret. To circumvent this issue, you can output the repository to a private repo and use the AWS command-line client to copy the snapshot dirs.
For the app, add the entry to your build.gradle file:
allprojects {
repositories {
jcenter()
maven {
url "s3://yourmavenrepo-bucket/android/snapshots"
credentials(AwsCredentials) {
accessKey "<ACCESS KEY>"
secretKey "<SECRET KEY>"
}
}
}If you are trying to access a private Amazon S3 repository, you may see an AWS authentication requires a valid Date or x-amz-date header error. It is a known issue with Gradle and Java versions.
To fix this issue, you will need to upgrade to Gradle v2.8 by editing your gradle/wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zipCreated by CodePath with much help from the community. Contributed content licensed under cc-wiki with attribution required. You are free to remix and reuse, as long as you attribute and use a similar license.
Finding these guides helpful?
We need help from the broader community to improve these guides, add new topics and keep the topics up-to-date. See our contribution guidelines here and our topic issues list for great ways to help out.
Check these same guides through our standalone viewer for a better browsing experience and an improved search. Follow us on twitter @codepath for access to more useful Android development resources.