diff --git a/.drone.yml b/.drone.yml index 839b04860..c48801f3b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,8 +11,9 @@ pipeline: commands: - emulator -avd android-27 -no-window -no-audio & - ./wait_for_emulator.sh + - ./gradlew assembleDebug - ./gradlew jacocoTestDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit" - - ./gradlew assembleDebug installDebugAndroidTest + - ./gradlew installDebugAndroidTest - ./gradlew createDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT" - ./gradlew combinedTestReport - curl -o codecov.sh https://codecov.io/bash @@ -43,6 +44,6 @@ pipeline: services: server: - image: nextcloudci/server:server-1 + image: nextcloudci/server:server-3 branches: master diff --git a/build.gradle b/build.gradle index 66c2fa663..164689830 100644 --- a/build.gradle +++ b/build.gradle @@ -2,20 +2,40 @@ buildscript { repositories { google() jcenter() + maven { + url 'https://oss.sonatype.org/content/repositories/snapshots/' + } + mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.3.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' + classpath('com.dicedmelon.gradle:jacoco-android:0.1.3') { + exclude group: 'org.codehaus.groovy', module: 'groovy-all' + } } } apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'findbugs' +apply plugin: 'jacoco-android' repositories { google() jcenter() + maven { url "https://jitpack.io" } + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + + flatDir { + dirs 'libs' + } +} + +configurations.all { + exclude group: 'com.google.firebase', module: 'firebase-core' + // check for updates every build + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } dependencies { @@ -27,33 +47,25 @@ dependencies { findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.8.0' findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3' + + testImplementation 'junit:junit:4.12' + testImplementation 'org.mockito:mockito-core:2.23.4' + + androidTestImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:rules:1.1.1' + androidTestImplementation 'androidx.test:runner:1.1.1' + + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1' } android { compileSdkVersion 28 - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src'] - resources.srcDirs = ['src'] - aidl.srcDirs = ['src'] - renderscript.srcDirs = ['src'] - res.srcDirs = ['res'] - assets.srcDirs = ['assets'] + buildTypes { + debug { + testCoverageEnabled true } - - // Move the tests to tests/java, tests/res, etc... - // instrumentTest.setRoot('tests') - - // Move the build types to build-types/ - // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... - // This moves them out of them default location under src//... which would - // conflict with src/ being used by the main source set. - // Adding new build types or product flavors should be accompanied - // by a similar customization. - debug.setRoot('build-types/debug') - release.setRoot('build-types/release') } lintOptions { @@ -65,13 +77,18 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 28 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}" + testInstrumentationRunnerArgument "TEST_SERVER_USERNAME", "${NC_TEST_SERVER_USERNAME}" + testInstrumentationRunnerArgument "TEST_SERVER_PASSWORD", "${NC_TEST_SERVER_PASSWORD}" } tasks.register("findbugs", FindBugs) { ignoreFailures = false effort = "max" reportLevel = "medium" - classes = fileTree("$project.buildDir/intermediates/javac/debug/compileDebugJavaWithJavac/classes/") + classes = fileTree("$project.buildDir/intermediates/javac/debug/compileDebugJavaWithJavac/") excludeFilter = file("${project.rootDir}/scripts/analysis/findbugs-filter.xml") source = fileTree('src/main/java') pluginClasspath = project.configurations.findbugsPlugins @@ -87,4 +104,26 @@ android { } } } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +task combinedTestReport(type: JacocoReport) { + reports { + xml.enabled = true + html.enabled = true + } + + def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*'] + def debugTree = fileTree(dir: "$project.buildDir/intermediates/javac/debug/compileDebugJavaWithJavac/classes/", excludes: fileFilter) + def mainSrc = "$project.projectDir/src/main/java" + + sourceDirectories = files([mainSrc]) + classDirectories = files([debugTree]) + executionData = fileTree(dir: project.buildDir, includes: [ + 'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/debugAndroidTest/connected/*coverage.ec' + ]) } diff --git a/gradle.properties b/gradle.properties index d1a19db61..e22ec2e3f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,7 @@ +# can be overriden by ~/.gradle/gradle.properties +NC_TEST_SERVER_BASEURL=http://server +NC_TEST_SERVER_USERNAME=test +NC_TEST_SERVER_PASSWORD=test android.enableJetifier=true android.useAndroidX=true android.debug.obsoleteApi=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e386abc94..627e66bd8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip -distributionSha256Sum=36bf7ff499223d5139f005822130ccca784c91591b514677fd376eed966c907e +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip +distributionSha256Sum=336b6898b491f6334502d8074a6b8c2d73ed83b92123106bd4bf837f04111043 diff --git a/sample_client/gradle/wrapper/gradle-wrapper.properties b/sample_client/gradle/wrapper/gradle-wrapper.properties index e386abc94..627e66bd8 100644 --- a/sample_client/gradle/wrapper/gradle-wrapper.properties +++ b/sample_client/gradle/wrapper/gradle-wrapper.properties @@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip -distributionSha256Sum=36bf7ff499223d5139f005822130ccca784c91591b514677fd376eed966c907e +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip +distributionSha256Sum=336b6898b491f6334502d8074a6b8c2d73ed83b92123106bd4bf837f04111043 diff --git a/sample_client/gradlew.bat b/sample_client/gradlew.bat index aec99730b..8a0b282aa 100644 --- a/sample_client/gradlew.bat +++ b/sample_client/gradlew.bat @@ -1,90 +1,90 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/sample_client/src/main/AndroidManifest.xml b/sample_client/src/main/AndroidManifest.xml index 906ac38db..581955c95 100644 --- a/sample_client/src/main/AndroidManifest.xml +++ b/sample_client/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - - + package="com.owncloud.android.lib.sampleclient" + android:versionCode="1" + android:versionName="1.0"> - + - + - + diff --git a/sample_client/src/main/res/layout/file_in_list.xml b/sample_client/src/main/res/layout/file_in_list.xml index 44fecf97e..6eecd3332 100644 --- a/sample_client/src/main/res/layout/file_in_list.xml +++ b/sample_client/src/main/res/layout/file_in_list.xml @@ -1,5 +1,4 @@ - - - + + android:layout_height="wrap_content" /> diff --git a/sample_client/src/main/res/layout/main.xml b/sample_client/src/main/res/layout/main.xml index 19036f46a..34868d4dc 100644 --- a/sample_client/src/main/res/layout/main.xml +++ b/sample_client/src/main/res/layout/main.xml @@ -1,5 +1,4 @@ - - - + + android:layout_height="match_parent">