Skip to content

Commit

Permalink
Merge pull request #3 from Workday/bintray-upload
Browse files Browse the repository at this point in the history
Upload artifacts to bintray
  • Loading branch information
ndtaylor committed Jul 27, 2015
2 parents a65e14b + 1197e12 commit 7f7082a
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 9 deletions.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,25 @@ public class MyParcelable implements Parcelable {

That's all you need to do get Postman working!

## Postman Idioms
## How to Use Postman

The above example demonstrates the most common way you will use Postman: annotate the class in question with `@Parceled`. Postman will pick up all member fields in the class and write them to or read them from the Parcel when `Postman.writeToParcel(Object, Parcel)` or `Postman.readFromParcel(Class, Parcel)` is called.
Add the following lines to your `build.gradle`

```
repositories {
maven {
url "http://dl.bintray.com/workday/workday-oss"
}
}
dependencies {
compile 'com.workday:postman:0.9'
}
```

### Postman Idioms

The previous example demonstrates the most common way you will use Postman: annotate the class in question with `@Parceled`. Postman will pick up all member fields in the class and write them to or read them from the Parcel when `Postman.writeToParcel(Object, Parcel)` or `Postman.readFromParcel(Class, Parcel)` is called.

Unfortunately, there is still some boiler plate code you have to deal with. In your parcelable class, you must include the following lines:

Expand All @@ -108,21 +124,21 @@ public void writeToParcel(Parcel dest, int flags) {

replacing MyParcelable with your own class name. We hope you agree though that this is much less painful than writing the full implementations yourself.

### What if there's a field I don't want to include in the Parcel?
#### What if there's a field I don't want to include in the Parcel?

In that case, annotate the offending field with `@NotParceled`.

### What if I don't want to include most of the fields in the Parcel?
#### What if I don't want to include most of the fields in the Parcel?

No problem. In that case, instead of annotating the class with `@Parceled`, annotate the fields you want included with `@Parceled`. All other fields will be ignored.

## Things to Watch Out For
### Things to Watch Out For

* Postman cannot access private fields. Any field you want to include in the Parcel must be either package-private (aka default) or public. If you annotate a private field with `@Parceled`, Postman will generate a compilation error. A private field in a class annotated with `@Parceled` will generate a compiler warning.
* Postman cannot populate final fields. If you annotate a final field with `@Parceled`, Postman will generate a compilation error. A final field in a class annotated with `@Parceled` will generate a compiler warning.
* Postman requires a public or package-private, no arg constructor in order to instantiate the class. A class marked with `@Parceled` that does not have default constructor will generate a compilation error.

## Working with Proguard
### Working with Proguard

If you're using [ProGuard](http://proguard.sourceforge.net/), you must add the following line to your ProGuard rules

Expand Down
4 changes: 3 additions & 1 deletion demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.library'

repositories {
maven {
url "http://dl.bintray.com/workday/workday-oss"
}
mavenCentral()
}

dependencies {
compile project(':postman')
compile fileTree(dir: '../libs', include: 'metajava.jar')

testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.0-rc2'
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VERSION_NAME=0.9

GROUP=com.workday
POM_ARTIFACT_ID=postman
42 changes: 42 additions & 0 deletions gradle/bintray-upload.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apply plugin: 'maven-publish'

task sourceJar(type: Jar) {
from sourceSets.main.allJava
}

publishing {
publications {
MavenJava(MavenPublication) {

groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME

from components.java

artifact sourceJar {
classifier "sources"
}

}
}
}

final bintrayUser = hasProperty('BINTRAY_USER') ? BINTRAY_USER : ""
final bintrayKey = hasProperty('BINTRAY_API_KEY') ? BINTRAY_API_KEY : ""

bintray {
user = bintrayUser
key = bintrayKey

publications = ['MavenJava']
dryRun = false
publish = false
pkg {
repo = 'workday-oss'
name = POM_ARTIFACT_ID
userOrg = 'workday'
version.name = VERSION_NAME
version.gpg.sign = true
}
}
Binary file removed libs/metajava.jar
Binary file not shown.
13 changes: 11 additions & 2 deletions postman/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
plugins {
id "com.jfrog.bintray" version "1.2"
}
apply plugin: 'java'
apply plugin: 'idea'
apply from: file('../gradle/bintray-upload.gradle')

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

repositories {
maven {
url "http://dl.bintray.com/workday/workday-oss"
}
mavenCentral()
}

group = GROUP
version = VERSION_NAME

configurations {
provided
}
Expand All @@ -29,6 +39,5 @@ dependencies {
compile 'com.google.guava:guava:18.0'
compile 'com.squareup:javawriter:2.5.0'
compile 'org.apache.commons:commons-lang3:3.3.2'

compile fileTree(dir: '../libs', include: 'metajava.jar')
compile 'com.workday:metajava:0.9'
}

0 comments on commit 7f7082a

Please sign in to comment.