Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinMoskala committed Jul 21, 2018
1 parent fb8b19f commit 7d01cb4
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 79 deletions.
4 changes: 1 addition & 3 deletions activitystarter-compiler/build.gradle
Expand Up @@ -36,6 +36,7 @@ dependencies {
implementation deps.autoservice
implementation deps.autocommon
implementation deps.javapoet
compileOnly files(org.gradle.internal.jvm.Jvm.current().getToolsJar())

testImplementation deps.junit
testImplementation deps.truth
Expand All @@ -48,9 +49,6 @@ dependencies {
repositories {
mavenCentral()
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}


// Fancy test print
Expand Down
@@ -1,7 +1,6 @@
package activitystarter.compiler.model.param

import activitystarter.compiler.model.param.FieldAccessor.Companion.hasNotPrivateMethodNamed
import com.sun.org.apache.xpath.internal.operations.Bool
import javax.lang.model.element.Element
import javax.lang.model.element.Modifier.PRIVATE
import javax.lang.model.element.TypeElement
Expand Down
144 changes: 78 additions & 66 deletions activitystarter/build.gradle
@@ -1,103 +1,115 @@
import org.gradle.internal.jvm.Jvm

buildscript {
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'

group='com.marcinmoskala'
group = 'com.marcinmoskala'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileSdkVersion rootProject.ext.compileSdkVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
minSdkVersion rootProject.ext.minSdkVersion

consumerProguardFiles 'proguard-rules.txt'
consumerProguardFiles 'proguard-rules.txt'

testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}
buildToolsVersion '27.0.3'
}

dependencies {
api project(':activitystarter-annotations')
implementation deps.supportAnnotations
implementation deps.supportCompat
implementation deps.supportAppcompatv7

androidTestImplementation deps.junit
androidTestImplementation deps.truth
androidTestImplementation deps.supportTestRunner

testImplementation deps.junit
testImplementation deps.truth
testImplementation deps.compiletesting
testImplementation project(':activitystarter-compiler')
testImplementation deps.kotlin
testImplementation deps.kotlin_junit
testImplementation deps.parceler
testImplementation deps.parceler_processor
api project(':activitystarter-annotations')
implementation deps.supportAnnotations
implementation deps.supportCompat
implementation deps.supportAppcompatv7

androidTestImplementation deps.junit
androidTestImplementation deps.truth
androidTestImplementation deps.supportTestRunner

testImplementation deps.junit
testImplementation deps.truth
testImplementation deps.compiletesting
testCompile files(getRuntimeJar())
testCompile files(Jvm.current().getToolsJar())
testImplementation project(':activitystarter-compiler')
testImplementation deps.kotlin
testImplementation deps.kotlin_junit
testImplementation deps.parceler
testImplementation deps.parceler_processor
}

def getRuntimeJar() {
try {
final File javaBase = new File(System.getProperty("java.home")).getCanonicalFile();
File runtimeJar = new File(javaBase, "lib/rt.jar");
if (runtimeJar.exists()) {
return runtimeJar;
}
runtimeJar = new File(javaBase, "jre/lib/rt.jar");
return runtimeJar.exists() ? runtimeJar : null;
} catch (IOException e) {
throw new RuntimeException(e);
}
}

// Fancy test print
tasks.withType(Test) {
testLogging {
// set options for log level LIFECYCLE
events "passed", "skipped", "failed", "standardOut"
showExceptions true
exceptionFormat "full"
showCauses true
showStackTraces true

// set options for log level DEBUG and INFO
debug {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat "full"
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat

afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
testLogging {
// set options for log level LIFECYCLE
events "passed", "skipped", "failed", "standardOut"
showExceptions true
exceptionFormat "full"
showCauses true
showStackTraces true

// set options for log level DEBUG and INFO
debug {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat "full"
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat

afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

artifacts {
archives sourcesJar
archives sourcesJar
}

install {
repositories.mavenInstaller {
pom.project {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
repositories.mavenInstaller {
pom.project {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}
}
}
}
7 changes: 3 additions & 4 deletions build.gradle
Expand Up @@ -5,12 +5,11 @@ ext {
buildToolsVersion = '25.0.2'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
androidToolsVersion = '25.2.0'
supportLibraryVersion = '25.1.0'
kotlinVersion = '1.2.41'
}

ext.androidToolsVersion = '25.2.0'
ext.supportLibraryVersion = '25.1.0'
ext.kotlinVersion = '1.1.4-2'

subprojects { project ->
group = GROUP
version = VERSION_NAME
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Expand Up @@ -14,3 +14,5 @@ POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=marcinmoskala
POM_DEVELOPER_NAME=Marcin Moskala

org.gradle.configureondemand=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
6 changes: 2 additions & 4 deletions sample/kotlinapp/build.gradle
Expand Up @@ -4,18 +4,16 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 25
compileSdkVersion 28
buildToolsVersion '27.0.3'

defaultConfig {
applicationId "com.marcinmoskala.kotlinapp"
minSdkVersion 18
targetSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
Expand Down

0 comments on commit 7d01cb4

Please sign in to comment.