Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #188 from vimeo/develop
Browse files Browse the repository at this point in the history
Release 2.6.0
  • Loading branch information
anthonycr authored Oct 25, 2018
2 parents 42c168b + 64ed936 commit ea61874
Show file tree
Hide file tree
Showing 155 changed files with 2,294 additions and 1,138 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
codecov:
branch: develop
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ jdk:
android:
components:
- tools
- build-tools-27.0.2
- android-27
- build-tools-28.0.3
- android-28
- extra-android-support
- extra-android-m2repository
# workaround for Google changing android-27 package and causing a checksum mismatch
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Change Log
==========

Version 2.6.0 *(2018-10-25)*
----------------------------
- Improved formatting of generated code.
- Improved logging by putting all debug logging behind the `stagDebug` flag.
- Improve integration of library by switching to new nullability annotations library.
- Wrote unit tests for `KnownTypeAdapters`.
- Fixed bug where code generation was non deterministic by switching to linked versions of `HashSet` and `HashMap`.
- Added support for turning on/off serialization of `null` with `stag.serializeNulls` compiler option. Default is off, which is a behavior change from version 2.5.1.

Version 2.5.1 *(2018-01-17)*
----------------------------
- Fixed bug where types with wildcards caused compilation to fail.
Expand Down
48 changes: 38 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ buildscript {
apply plugin: 'net.ltgt.apt'
dependencies {
def stagVersion = '2.5.1'
def stagVersion = '2.6.0'
compile "com.vimeo.stag:stag-library:$stagVersion"
apt "com.vimeo.stag:stag-library-compiler:$stagVersion"
}
Expand All @@ -45,19 +45,42 @@ dependencies {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
aptOptions.processorArgs = [
stagAssumeHungarianNotation: "true",
stagGeneratedPackageName : "com.vimeo.sample.stag.generated",
stagDebug : "true"
"stagAssumeHungarianNotation": "true",
"stagGeneratedPackageName" : "com.vimeo.sample.stag.generated",
"stagDebug " : "true",
"stag.serializeNulls" : "true",
]
}
}
```

### Android Gradle
### Kotlin Gradle
```groovy
apply plugin: 'kotlin-kapt'
dependencies {
def stagVersion = '2.6.0'
compile "com.vimeo.stag:stag-library:$stagVersion"
kapt "com.vimeo.stag:stag-library-compiler:$stagVersion"
}
kapt {
correctErrorTypes = true
// Optional annotation processor arguments (see below)
arguments {
arg("stagDebug", "true")
arg("stagGeneratedPackageName", "com.vimeo.sample.stag.generated")
arg("stagAssumeHungarianNotation", "true")
arg("stag.serializeNulls", "true")
}
}
```

### Android Gradle (Java)

```groovy
dependencies {
def stagVersion = '2.5.1'
def stagVersion = '2.6.0'
compile "com.vimeo.stag:stag-library:$stagVersion"
annotationProcessor "com.vimeo.stag:stag-library-compiler:$stagVersion"
}
Expand All @@ -70,9 +93,10 @@ android {
javaCompileOptions {
annotationProcessorOptions {
arguments = [
stagAssumeHungarianNotation: 'true'
stagGeneratedPackageName : 'com.vimeo.sample.stag.generated',
stagDebug : 'true'
"stagAssumeHungarianNotation": 'true',
"stagGeneratedPackageName" : 'com.vimeo.sample.stag.generated',
"stagDebug" : 'true',
"stag.serializeNulls" : 'true'
]
}
}
Expand All @@ -91,6 +115,10 @@ android {
Stag will look for members named `set[variable_name]` and `get[variable_name]`. If your member variables are named using Hungarian notation,
then you will need to pass true to this parameter so that for a field named `mField`, Stag will look for `setField` and `getField` instead
of `setMField` and `getMField`. Default is false.
- `stag.serializeNulls`: By default this is set to false. If an object has a null field and you send it to be serialized by Gson, it is optional
whether or not that field is serialized into the JSON. If this field is set to `false` null fields will not be serialized, and if set to `true`,
they will be serialized. Prior to stag version 2.6.0, null fields were always serialized to JSON. This should not affect most models. However, if
you have a model that has a nullable field that also has a non null default value, then it might be a good idea to turn this option on.

## Features

Expand Down Expand Up @@ -228,7 +256,7 @@ class Herd {
* You parse the list from JSON using
* Gson.
*/
MyParsingClass {
class MyParsingClass {
private Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(new Stag.Factory())
.create();
Expand Down
28 changes: 14 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

ext.kotlinVersion = '1.2.20'
ext.jacocoVersion = '0.7.9' // See http://www.eclemma.org/jacoco/
ext.gsonVersion = '2.8.2'

// android dependencies
ext.targetSdk = 27
ext.minSdk = 14
ext.buildTools = "27.0.2"

ext {
kotlinVersion = '1.2.71'
jacocoVersion = '0.7.9' // See http://www.eclemma.org/jacoco/
gsonVersion = '2.8.2'
assertJ = '3.9.1'

// android dependencies
targetSdk = 28
minSdk = 14
buildTools = "28.0.3"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "net.ltgt.gradle:gradle-apt-plugin:0.11"
classpath 'net.ltgt.gradle:gradle-apt-plugin:0.15'
}
}

Expand All @@ -43,5 +43,5 @@ allprojects {

subprojects {
group = 'com.vimeo.stag'
version = '2.5.1'
version = '2.6.0'
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 25 13:24:54 EDT 2017
#Thu Oct 25 11:29:47 EDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
9 changes: 5 additions & 4 deletions integration-test-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ android {
}

dependencies {
testImplementation 'junit:junit:4.12'

implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:support-annotations:27.0.2'
implementation 'org.jetbrains:annotations-java5:16.0.2@jar'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'

implementation project(':stag-library')
annotationProcessor project(':stag-library-compiler')

implementation "com.google.code.gson:gson:$gsonVersion"

testImplementation 'junit:junit:4.12'
}

gradle.projectsEvaluated {
Expand Down
4 changes: 1 addition & 3 deletions integration-test-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<manifest
package="com.vimeo.integration_test_android"
xmlns:android="http://schemas.android.com/apk/res/android" />
<manifest package="com.vimeo.integration_test_android" />
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.Test;

import verification.Utils;

/**
* Created by restainoa on 2/2/17.
*/
Expand All @@ -12,4 +14,4 @@ public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ClassWithMapTypes.class);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import org.junit.Test;

import verification.Utils;

public class ComplexGenericClassExtendedTest {

@Test
public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ComplexGenericClassExtended.class);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.Test;

import verification.Utils;

/**
* Created by restainoa on 2/2/17.
*/
Expand All @@ -12,4 +14,4 @@ public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ComplexGenericClass.class);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.Test;

import verification.Utils;

/**
* Unit tests for {@link TestModel}.
*/
Expand All @@ -11,4 +13,4 @@ public class TestModelTest {
public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(TestModel.class);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.Test;

import verification.Utils;

/**
* Unit tests for {@link UnserializablePlatformType}.
*/
Expand All @@ -11,4 +13,4 @@ public class UnserializablePlatformTypeTest {
public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(UnserializablePlatformType.class);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.vimeo.integration_test_android;
package verification;

import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
Expand Down
5 changes: 3 additions & 2 deletions integration-test-java-cross-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ apply plugin: "net.ltgt.apt"

dependencies {
implementation "com.google.code.gson:gson:$gsonVersion"
implementation 'com.android.support:support-annotations:27.0.2'
implementation 'org.jetbrains:annotations-java5:16.0.2@jar'
implementation 'com.android.support:support-annotations:28.0.0'

implementation project(':stag-library')
apt project(':stag-library-compiler')
annotationProcessor project(':stag-library-compiler')

implementation project(':integration-test-java')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<manifest
package="com.vimeo.sample.integration_test_android"
xmlns:android="http://schemas.android.com/apk/res/android" />
<manifest package="com.vimeo.sample.integration_test_android" />
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class NestedClass {
* classes to explicitly specify the annotation in order to enable generation.
*/
public static class NestedExtension extends NestedClass {

String field;
}

Expand Down Expand Up @@ -42,4 +43,4 @@ public static class NestedWithoutAnnotation {
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

/**
* Example where Object is one of the member variables
*
*/
@UseStag
public class ObjectExample {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
*/
public class OuterClassWithInnerModel {

@UseStag
public static class InnerModel {
@UseStag
public static class InnerModel {

public int version;
public int version;

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.ArrayList;

@SuppressWarnings("FieldNameHidesFieldInSuperclass")
@UseStag
public class SubClassWithSameVariableName extends ClassWithArrayTypes {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

public class TestDeserializer implements JsonDeserializer<BasicModel2> {

@Override
public BasicModel2 deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return context.deserialize(json, BasicModel2.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
/**
* Since this class is not annotated with @UseStag, this will use TypeToken for its adapter generation.
* As it is of paramterized type, this will use TypeToken.getParameterized() instead of TypeToken.get()
*
* @param <T>
*/
public class ParameterizedData<T> {

@SerializedName("list")
public List<T> list;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.vimeo.sample.model;

import com.vimeo.sample.Utils;
import verification.Utils;

import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.vimeo.sample.model;

import com.vimeo.sample.Utils;
import verification.Utils;

import org.junit.Test;

Expand Down
Loading

0 comments on commit ea61874

Please sign in to comment.