Skip to content

Commit

Permalink
maven to kotlin dsl migration part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodo1981 committed Nov 8, 2018
1 parent 40f4746 commit f582575
Show file tree
Hide file tree
Showing 20 changed files with 167 additions and 120 deletions.
14 changes: 0 additions & 14 deletions benchmark/build.gradle

This file was deleted.

17 changes: 17 additions & 0 deletions benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
31 changes: 31 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@ 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 {
// testing
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}"
Expand All @@ -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}"
}
6 changes: 0 additions & 6 deletions converters/date-rfc3339/build.gradle

This file was deleted.

8 changes: 8 additions & 0 deletions converters/date-rfc3339/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
java
}

dependencies {
implementation(project(":core"))
testCompile(Deps.junit)
}
6 changes: 0 additions & 6 deletions converters/htmlescape/build.gradle

This file was deleted.

8 changes: 8 additions & 0 deletions converters/htmlescape/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
java
}

dependencies {
implementation(project(":core"))
testCompile(Deps.junit)
}
7 changes: 0 additions & 7 deletions core/build.gradle

This file was deleted.

9 changes: 9 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
java
}

dependencies {
compile(Deps.okio)
testImplementation(Deps.junit)
testImplementation(Deps.assertj)
}
45 changes: 23 additions & 22 deletions core/src/test/java/com/tickaroo/tikxml/TypeConvertersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.IOException;
import java.util.Date;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -30,37 +31,37 @@
*/
public class TypeConvertersTest {

@Rule
public ExpectedException exception = ExpectedException.none();
@Rule
public ExpectedException exception = ExpectedException.none();

static class TestConverter implements TypeConverter<Object> {
@Override
public Object read(String value) throws Exception {
return null;
}
static class TestConverter implements TypeConverter<Object> {
@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);


}
}
}
3 changes: 1 addition & 2 deletions core/src/test/java/com/tickaroo/tikxml/TypesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ interface StringIntegerMap extends Map<String, Integer> {
}

@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);
}
Expand Down
8 changes: 0 additions & 8 deletions processor-common/build.gradle

This file was deleted.

10 changes: 10 additions & 0 deletions processor-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
java
id("kotlin")
}

dependencies {
compile(project(":annotation"))
compile(Deps.kotlinStdLib)
implementation(Deps.kotlinReflect)
}
19 changes: 0 additions & 19 deletions processor/build.gradle

This file was deleted.

22 changes: 22 additions & 0 deletions processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,22 @@ import org.junit.Test
*/
class XmlCharactersTest {


@Test
fun test(){
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(">"));


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("<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("\""))

Assert.assertTrue(XmlCharacters.containsXmlCharacter("a'"))
Assert.assertTrue(XmlCharacters.containsXmlCharacter("'a"))
Assert.assertTrue(XmlCharacters.containsXmlCharacter("'"))
}
}
12 changes: 0 additions & 12 deletions retrofit-converter/build.gradle

This file was deleted.

14 changes: 14 additions & 0 deletions retrofit-converter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

0 comments on commit f582575

Please sign in to comment.