diff --git a/build.gradle b/build.gradle index 0c47a8d1..9a8fdc44 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,17 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -apply from: 'dependencies.gradle' - buildscript { apply from: 'dependencies.gradle' repositories { jcenter() + maven { + url "https://plugins.gradle.org/m2/" + } } dependencies { classpath gradlePlugins.androidTools classpath gradlePlugins.kotlin + classpath gradlePlugins.ktlintGradle } } diff --git a/dependencies.gradle b/dependencies.gradle index a177610f..b4802ddc 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -5,6 +5,8 @@ ext.versions = [ buildTools : "25.0.3", androidTools : "2.3.3", + ktlint : "0.9.0", + ktlintGradle : "2.1.0", androidSupport : "22.2.1", @@ -23,6 +25,7 @@ ext.versions = [ ext.gradlePlugins = [ androidTools : "com.android.tools.build:gradle:$versions.androidTools", kotlin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin", + ktlintGradle : "gradle.plugin.org.jlleitschuh.gradle:ktlint-gradle:$versions.ktlintGradle", ] ext.androidSupport = [ diff --git a/gradle_scripts/code_quality.gradle b/gradle_scripts/code_quality.gradle new file mode 100644 index 00000000..df65df11 --- /dev/null +++ b/gradle_scripts/code_quality.gradle @@ -0,0 +1,10 @@ +// Applies code quality plugins when -Pqc is passed to the gradle +def isCodeQualityEnabled = project.hasProperty('qc') + +if (isCodeQualityEnabled) { + apply plugin: "org.jlleitschuh.gradle.ktlint" + + ktlint { + version = versions.ktlint + } +} \ No newline at end of file diff --git a/subsonic-api/build.gradle b/subsonic-api/build.gradle index 1091d2f5..fa4fe445 100644 --- a/subsonic-api/build.gradle +++ b/subsonic-api/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'kotlin' +apply from: '../gradle_scripts/code_quality.gradle' sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/ultrasonic/build.gradle b/ultrasonic/build.gradle index 258d5052..e9bcd67c 100644 --- a/ultrasonic/build.gradle +++ b/ultrasonic/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +apply from: "../gradle_scripts/code_quality.gradle" android { compileSdkVersion versions.compileSdk