diff --git a/benchmark/build.gradle b/benchmark/build.gradle deleted file mode 100644 index cfef711a..00000000 --- a/benchmark/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -apply plugin: "java" - -dependencies { - implementation rootProject.kotlinStdLib - implementation rootProject.kotlinReflect - implementation rootProject.javaPoet - implementation group: "com.fasterxml.jackson.dataformat", name: "jackson-dataformat-xml", version: "2.9.7" - implementation group: "org.simpleframework", name: "simple-xml", version: "2.7.1" - implementation project(":processor") - implementation project(":processor-common") - implementation project(":core") - implementation project(":annotation") - implementation group: "net.trajano.caliper", name: "caliper", version: "1.2.1" -} diff --git a/benchmark/build.gradle.kts b/benchmark/build.gradle.kts new file mode 100644 index 00000000..bb2a9451 --- /dev/null +++ b/benchmark/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + java +} + +dependencies { + implementation(project(":core")) + implementation(project(":processor")) + implementation(project(":annotation")) + implementation(project(":processor-common")) + + implementation(Deps.caliper) + implementation(Deps.javaPoet) + implementation(Deps.simpleXml) + implementation(Deps.jacksonXml) + implementation(Deps.kotlinStdLib) + implementation(Deps.kotlinReflect) +} diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 91ddaed5..cacc9286 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -6,6 +6,15 @@ object Versions { const val javaPoet = "1.11.1" const val compileTesting = "0.15" const val truth = "0.42" + const val jackson = "2.9.7" + const val simpleXml = "2.7.1" + const val caliper = "1.2.1" + const val okio = "2.1.0" + const val assertj = "3.11.1" + const val guava = "27.0-jre" + const val mockito = "2.23.0" + const val retrofit = "2.4.0" + const val mockWebserver = "3.11.0" } object Deps { @@ -13,6 +22,8 @@ object Deps { const val junit = "junit:junit:${Versions.junit}" const val compileTesting = "com.google.testing.compile:compile-testing:${Versions.compileTesting}" const val truth = "com.google.truth:truth:${Versions.truth}" + const val assertj = "org.assertj:assertj-core:${Versions.assertj}" + const val mockito = "org.mockito:mockito-core:${Versions.mockito}" // google auto const val autoService ="com.google.auto.service:auto-service:${Versions.autoService}" @@ -24,5 +35,25 @@ object Deps { const val kotlinReflect = "org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlin}" const val kotlinTestJunit = "org.jetbrains.kotlin:kotlin-test-junit:${Versions.kotlin}" + // okio + const val okio = "com.squareup.okio:okio:${Versions.okio}" + + // retrofit + const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofit}" + + // mockwebserver + const val mockWebserver = "com.squareup.okhttp3:mockwebserver:${Versions.mockWebserver}" + + // guava + const val guava = "com.google.guava:guava:${Versions.guava}" + + // parser + const val jacksonXml = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${Versions.jackson}" + const val simpleXml = "org.simpleframework:simple-xml:${Versions.simpleXml}" + + // code generation const val javaPoet = "com.squareup:javapoet:${Versions.javaPoet}" + + // benachmark + const val caliper = "net.trajano.caliper:caliper:${Versions.caliper}" } \ No newline at end of file diff --git a/converters/date-rfc3339/build.gradle b/converters/date-rfc3339/build.gradle deleted file mode 100644 index 9b45ac83..00000000 --- a/converters/date-rfc3339/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -apply plugin: 'java' - -dependencies { - implementation project(':core') - testCompile rootProject.junit -} diff --git a/converters/date-rfc3339/build.gradle.kts b/converters/date-rfc3339/build.gradle.kts new file mode 100644 index 00000000..504a802d --- /dev/null +++ b/converters/date-rfc3339/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + java +} + +dependencies { + implementation(project(":core")) + testCompile(Deps.junit) +} diff --git a/converters/htmlescape/build.gradle b/converters/htmlescape/build.gradle deleted file mode 100644 index 9b45ac83..00000000 --- a/converters/htmlescape/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -apply plugin: 'java' - -dependencies { - implementation project(':core') - testCompile rootProject.junit -} diff --git a/converters/htmlescape/build.gradle.kts b/converters/htmlescape/build.gradle.kts new file mode 100644 index 00000000..504a802d --- /dev/null +++ b/converters/htmlescape/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + java +} + +dependencies { + implementation(project(":core")) + testCompile(Deps.junit) +} diff --git a/core/build.gradle b/core/build.gradle deleted file mode 100644 index 761b4c5b..00000000 --- a/core/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -apply plugin: 'java' - -dependencies { - compile rootProject.okio - testImplementation rootProject.junit - testImplementation rootProject.assertj -} \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts new file mode 100644 index 00000000..f70e33d8 --- /dev/null +++ b/core/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + java +} + +dependencies { + compile(Deps.okio) + testImplementation(Deps.junit) + testImplementation(Deps.assertj) +} \ No newline at end of file diff --git a/core/src/test/java/com/tickaroo/tikxml/TypeConvertersTest.java b/core/src/test/java/com/tickaroo/tikxml/TypeConvertersTest.java index bf20441c..c56a7c6d 100644 --- a/core/src/test/java/com/tickaroo/tikxml/TypeConvertersTest.java +++ b/core/src/test/java/com/tickaroo/tikxml/TypeConvertersTest.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.Date; + import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -30,37 +31,37 @@ */ public class TypeConvertersTest { - @Rule - public ExpectedException exception = ExpectedException.none(); + @Rule + public ExpectedException exception = ExpectedException.none(); - static class TestConverter implements TypeConverter { - @Override - public Object read(String value) throws Exception { - return null; - } + static class TestConverter implements TypeConverter { + @Override + public Object read(String value) { + return null; + } - @Override - public String write(Object value) throws Exception { - return null; + @Override + public String write(Object value) { + return null; + } } - } - @Test - public void addAndGetTypeConverter() throws IOException { + @Test + public void addAndGetTypeConverter() throws IOException { - TypeConverters converters = new TypeConverters(); + TypeConverters converters = new TypeConverters(); - exception.expect(IOException.class); - converters.get(TestConverter.class); + exception.expect(IOException.class); + converters.get(TestConverter.class); - TestConverter converter = new TestConverter(); + TestConverter converter = new TestConverter(); - converters.add(Object.class, converter); - Assert.assertTrue(converter == converters.get(Object.class)); + converters.add(Object.class, converter); + Assert.assertSame(converter, converters.get(Object.class)); - exception.expect(IOException.class); - converters.get(Date.class); + exception.expect(IOException.class); + converters.get(Date.class); - } + } } diff --git a/core/src/test/java/com/tickaroo/tikxml/TypesTest.java b/core/src/test/java/com/tickaroo/tikxml/TypesTest.java index 80afaded..765dba14 100644 --- a/core/src/test/java/com/tickaroo/tikxml/TypesTest.java +++ b/core/src/test/java/com/tickaroo/tikxml/TypesTest.java @@ -123,8 +123,7 @@ interface StringIntegerMap extends Map { } @Test public void mapKeyAndValueTypes() throws Exception { - Type mapOfStringIntegerType = TypesTest.class.getDeclaredField( - "mapOfStringInteger").getGenericType(); + Type mapOfStringIntegerType = TypesTest.class.getDeclaredField("mapOfStringInteger").getGenericType(); assertThat(Types.mapKeyAndValueTypes(mapOfStringIntegerType, Map.class)) .containsExactly(String.class, Integer.class); } diff --git a/processor-common/build.gradle b/processor-common/build.gradle deleted file mode 100644 index 32f5af83..00000000 --- a/processor-common/build.gradle +++ /dev/null @@ -1,8 +0,0 @@ -apply plugin: "java" -apply plugin: "kotlin" - -dependencies { - api project(":annotation") - api rootProject.kotlinStdLib - implementation rootProject.kotlinReflect -} diff --git a/processor-common/build.gradle.kts b/processor-common/build.gradle.kts new file mode 100644 index 00000000..3cd02443 --- /dev/null +++ b/processor-common/build.gradle.kts @@ -0,0 +1,10 @@ +plugins { + java + id("kotlin") +} + +dependencies { + compile(project(":annotation")) + compile(Deps.kotlinStdLib) + implementation(Deps.kotlinReflect) +} diff --git a/processor/build.gradle b/processor/build.gradle deleted file mode 100644 index 13e8ecaf..00000000 --- a/processor/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -apply plugin: "java" -apply plugin: "kotlin" - -dependencies { - compile project(":core") - compile project(":annotation") - compile project(":processor-common") - implementation rootProject.autoService - implementation rootProject.kotlinStdLib - implementation rootProject.kotlinReflect - implementation rootProject.javaPoet - implementation rootProject.guava - - testImplementation rootProject.compileTesting - testImplementation rootProject.truth - testImplementation rootProject.mockito - testImplementation rootProject.kotlinTestJunit - testImplementation rootProject.junit -} diff --git a/processor/build.gradle.kts b/processor/build.gradle.kts new file mode 100644 index 00000000..adca303e --- /dev/null +++ b/processor/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + java + id("kotlin") +} + +dependencies { + compile(project(":core")) + compile(project(":annotation")) + compile(project(":processor-common")) + + implementation(Deps.guava) + implementation(Deps.javaPoet) + implementation(Deps.autoService) + implementation(Deps.kotlinStdLib) + implementation(Deps.kotlinReflect) + + testImplementation(Deps.junit) + testImplementation(Deps.truth) + testImplementation(Deps.mockito) + testImplementation(Deps.compileTesting) + testImplementation(Deps.kotlinTestJunit) +} diff --git a/processor/src/test/java/com/tickaroo/tikxml/processor/TestUtils.kt b/processor/src/test/java/com/tickaroo/tikxml/processor/TestUtils.kt index 9b453348..5d0567d3 100644 --- a/processor/src/test/java/com/tickaroo/tikxml/processor/TestUtils.kt +++ b/processor/src/test/java/com/tickaroo/tikxml/processor/TestUtils.kt @@ -27,15 +27,15 @@ fun expectException(errorMsg: String? = null, blockToExecute: () -> Unit) { try { blockToExecute() fail("Expected an exception, but no exception has been thrown") - } catch(error: AssertionError) { + } catch (error: AssertionError) { throw error - } catch(t: ProcessingException) { + } catch (t: ProcessingException) { if (errorMsg != null && errorMsg != t.message) { fail("Expected an error message \n\"$errorMsg\"\nbut got:\n\"${t.message}\"") } - } catch(other: Throwable) { + } catch (other: Throwable) { other.printStackTrace() fail("Expected another type of exception, see stacktrace above") } diff --git a/processor/src/test/java/com/tickaroo/tikxml/processor/XmlCharactersTest.kt b/processor/src/test/java/com/tickaroo/tikxml/processor/XmlCharactersTest.kt index 47649e6b..d1d09c2c 100644 --- a/processor/src/test/java/com/tickaroo/tikxml/processor/XmlCharactersTest.kt +++ b/processor/src/test/java/com/tickaroo/tikxml/processor/XmlCharactersTest.kt @@ -9,25 +9,22 @@ import org.junit.Test */ class XmlCharactersTest { - @Test - fun test(){ - Assert.assertTrue(XmlCharacters.containsXmlCharacter("a<")); - Assert.assertTrue(XmlCharacters.containsXmlCharacter("")); - Assert.assertTrue(XmlCharacters.containsXmlCharacter(">a")); - Assert.assertTrue(XmlCharacters.containsXmlCharacter(">")); - - - Assert.assertTrue(XmlCharacters.containsXmlCharacter("a\"")); - Assert.assertTrue(XmlCharacters.containsXmlCharacter("\"a")); - Assert.assertTrue(XmlCharacters.containsXmlCharacter("\"")); - - Assert.assertTrue(XmlCharacters.containsXmlCharacter("a'")); - Assert.assertTrue(XmlCharacters.containsXmlCharacter("'a")); - Assert.assertTrue(XmlCharacters.containsXmlCharacter("'")); + fun test() { + Assert.assertTrue(XmlCharacters.containsXmlCharacter("a<")) + Assert.assertTrue(XmlCharacters.containsXmlCharacter("")) + Assert.assertTrue(XmlCharacters.containsXmlCharacter(">a")) + Assert.assertTrue(XmlCharacters.containsXmlCharacter(">")) + + Assert.assertTrue(XmlCharacters.containsXmlCharacter("a\"")) + Assert.assertTrue(XmlCharacters.containsXmlCharacter("\"a")) + Assert.assertTrue(XmlCharacters.containsXmlCharacter("\"")) + + Assert.assertTrue(XmlCharacters.containsXmlCharacter("a'")) + Assert.assertTrue(XmlCharacters.containsXmlCharacter("'a")) + Assert.assertTrue(XmlCharacters.containsXmlCharacter("'")) } } \ No newline at end of file diff --git a/retrofit-converter/build.gradle b/retrofit-converter/build.gradle deleted file mode 100644 index 4544f1b4..00000000 --- a/retrofit-converter/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -apply plugin: 'java' - -dependencies { - compile project(':core') - compile project(':annotation') - compile rootProject.retrofit - compile rootProject.kotlinStdLib - implementation project(':processor-common') - testImplementation project(':processor') - testImplementation rootProject.mockWebserver - testImplementation rootProject.junit -} diff --git a/retrofit-converter/build.gradle.kts b/retrofit-converter/build.gradle.kts new file mode 100644 index 00000000..ab96b812 --- /dev/null +++ b/retrofit-converter/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + java +} + +dependencies { + compile(project(":core")) + compile(project(":annotation")) + compile(Deps.retrofit) + compile(Deps.kotlinStdLib) + implementation(project(":processor-common")) + testAnnotationProcessor(project(":processor")) + testImplementation(Deps.mockWebserver) + testImplementation(Deps.junit) +} diff --git a/retrofit-converter/src/test/java/com/tickaroo/tikxml/retrofit/Person.java b/retrofit-converter/src/test/java/com/tickaroo/tikxml/retrofit/Person.java index 9bb53dbc..65843bbb 100644 --- a/retrofit-converter/src/test/java/com/tickaroo/tikxml/retrofit/Person.java +++ b/retrofit-converter/src/test/java/com/tickaroo/tikxml/retrofit/Person.java @@ -18,13 +18,16 @@ package com.tickaroo.tikxml.retrofit; +import com.tickaroo.tikxml.annotation.PropertyElement; +import com.tickaroo.tikxml.annotation.Xml; /** * @author Hannes Dorfmann */ - +@Xml public class Person { - String name; + @PropertyElement + String name; }