diff --git a/.circleci/config.yml b/.circleci/config.yml index f90b6ee..483aba1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,6 +20,15 @@ jobs: - run: name: Run Tests command: ./gradlew lint test + - run: + name: Publish on Maven + command: | + VERSION=$(git tag --points-at HEAD) # Get current tag if any + # Check correct tag format, strip leading "v" and publish + if [[ $VERSION =~ ^v(.*)$ ]]; then + VERSION=${BASH_REMATCH[1]} + ./gradlew bintrayUpload -PgitVersion=$VERSION + fi - store_artifacts: path: build/reports destination: reports diff --git a/README.md b/README.md index f3d6e89..91076e5 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,27 @@ # sardine-android [![Build Status](https://circleci.com/gh/thegrizzlylabs/sardine-android.svg?&style=shield)](https://circleci.com/gh/thegrizzlylabs/sardine-android) +[![Version number](https://img.shields.io/bintray/v/guillaume-tgl/maven/sardine-android.svg) ](https://bintray.com/guillaume-tgl/maven/sardine-android/_latestVersion) A WebDAV client for Android, using [OkHttp](https://github.com/square/okhttp) as HTTP client. ## Getting started -- Check out this repository and add it to your Android project -- Include this Android library into your app by editing your `build.gradle`: +- Edit your app-level `build.gradle` (see top of this page for the latest version): ``` dependencies { ... - implementation project(':sardine-android') + implementation 'com.thegrizzlylabs.sardine-android:sardine-android:' } ``` + - Create a `Sardine` client: ``` Sardine sardine = new OkHttpSardine(); sardine.setCredentials("username", "password"); ``` + - Use the client to make requests to your WebDAV server: ``` List resources = sardine.list("http://webdav.server.com"); @@ -32,5 +34,3 @@ Originally forked from [Sardine](https://github.com/lookfirst/sardine) [Apache HTTP Client](http://hc.apache.org/) was replaced by [OkHttp](https://github.com/square/okhttp) JAXB was replaced by [SimpleXml](http://simple.sourceforge.net/) - - diff --git a/build.gradle b/build.gradle index 71a9176..ceb1592 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' } } @@ -14,18 +15,15 @@ repositories { } apply plugin: 'com.android.library' +apply plugin: 'maven-publish' +apply plugin: 'com.jfrog.bintray' android { compileSdkVersion 27 defaultConfig { minSdkVersion 15 - targetSdkVersion 27 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - consumerProguardFiles 'proguard-rules.pro' } } @@ -42,3 +40,62 @@ dependencies { testImplementation 'junit:junit:4.12' } + +task sourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs +} + +publishing { + publications { + MyPublication(MavenPublication) { + if (project.hasProperty('gitVersion')) { + version "$gitVersion" + } + groupId 'com.thegrizzlylabs.sardine-android' + artifactId 'sardine-android' + + artifact bundleRelease + artifact sourcesJar + + pom.withXml { + def dependenciesNode = asNode().appendNode('dependencies') + // Iterate over the implementation dependencies (we don't want the test ones), adding a node for each + configurations.implementation.allDependencies.each { + // Ensure dependencies such as fileTree are not included. + if (it.name != 'unspecified') { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + } + } + } + } +} + +bintray { + // Get Bintray credential from environment variable + user = System.getenv('BINTRAY_USER') + key = System.getenv('BINTRAY_API_KEY') + dryRun = false + override = false + publish = true + pkg { + repo = 'maven' + name = 'sardine-android' + userOrg = user + licenses = ['Apache-2.0'] + desc = 'A WebDAV library for Android' + vcsUrl = 'https://github.com/thegrizzlylabs/sardine-android.git' + + version { + if (project.hasProperty('gitVersion')) { + name = "$gitVersion" //Bintray logical version name + vcsTag = "v$gitVersion" + } + } + } + publications = ['MyPublication'] +}