Skip to content

Commit

Permalink
RUMM-14 Initial drop with base gradle config
Browse files Browse the repository at this point in the history
  • Loading branch information
xgouchet committed Nov 4, 2019
0 parents commit 0db48d1
Show file tree
Hide file tree
Showing 24 changed files with 1,304 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# IntelliJ
*.iml
.idea/

# Android Studio 3+
.navigation/
captures/
.externalNativeBuild

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# MacOS garbage
.DS_Store

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Datadog Android SDK

Client-side Android logging library for Datadog.

## Features

- Use the library as a logger. Everything is forwarded to Datadog as JSON documents.
- Custom fields, meta and extra attributes
- Automatic Useragent, IP and network information sent
- Automatic bulk
- Network and battery life optimized

## Quick Start

TODO

26 changes: 26 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
buildscript {
repositories {
google()
mavenCentral()
maven { setUrl(com.datadog.gradle.Dependencies.Repositories.Gradle) }
jcenter()
}

dependencies {
classpath(com.datadog.gradle.Dependencies.ClassPaths.AndroidTools)
classpath(com.datadog.gradle.Dependencies.ClassPaths.Kotlin)
classpath(com.datadog.gradle.Dependencies.ClassPaths.KtLint)
}
}

allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}

task<Delete>("clean") {
delete(rootProject.buildDir)
}
18 changes: 18 additions & 0 deletions buildSrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Built application files
*.apk
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
build/
48 changes: 48 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
`kotlin-dsl`
id("com.github.ben-manes.versions") version ("0.27.0")
id("org.jlleitschuh.gradle.ktlint") version ("9.1.0")
}

buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41")
}
repositories {
mavenCentral()
}
}

apply(plugin = "kotlin")
apply(plugin = "java-gradle-plugin")

repositories {
mavenCentral()
google()
maven { setUrl("https://plugins.gradle.org/m2/") }
maven { setUrl("https://maven.google.com") }
}

dependencies {

// Dependencies used to configure the gradle plugins
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.41")
compile("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41")
compile("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.1.1")
compile("org.jlleitschuh.gradle:ktlint-gradle:9.1.0")
compile("com.android.tools.build:gradle:3.5.1")
compile("com.github.ben-manes:gradle-versions-plugin:0.27.0")

testCompile("junit:junit:4.12")
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}

tasks.named("check") {
// dependsOn("dependencyUpdates")
// dependsOn("ktlintCheck")
}
47 changes: 47 additions & 0 deletions buildSrc/src/main/kotlin/com/datadog/gradle/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.datadog.gradle

object Dependencies {

object Versions {
// Commons
const val Kotlin = "1.3.41"
const val AndroidToolsPlugin = "3.5.1"

// Tests
const val Jacoco = "0.8.4"

// Tools
const val Detekt = "1.0.1"
const val KtLint = "8.2.0"
const val DependencyVersion = "0.27.0"
}

object Libraries {

const val Kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.Kotlin}"

@JvmField
val JUnit5Extensions = arrayOf(
"org.mockito:mockito-junit-jupiter:2.23.0"
)
}

object ClassPaths {
const val AndroidTools = "com.android.tools.build:gradle:${Versions.AndroidToolsPlugin}"
const val Kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Kotlin}"
const val KtLint = "org.jlleitschuh.gradle:ktlint-gradle:${Versions.KtLint}"
}

object Repositories {
const val Gradle = "https://plugins.gradle.org/m2/"
const val Google = "https://maven.google.com"
}

object PluginNamespaces {
const val Detetk = "io.gitlab.arturbosch"
const val KtLint = "org.jlleitschuh.gradle"
const val DependencyVersion = "com.github.ben-manes"
const val Kotlin = "org.jetbrains.kotlin"
const val KotlinAndroid = "org.jetbrains.kotlin.android"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.datadog.gradle.config

import com.datadog.gradle.utils.Version

object AndroidConfig {
const val TARGET_SDK = 28
const val MIN_SDK = 16
val VERSION = Version(0, 0, 1)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.datadog.gradle.config

import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.kotlin.dsl.findByType

inline fun <reified T : Any> Project.extensionConfig(
crossinline configure: T.() -> Unit
) {

project.afterEvaluate {
val ext: T? = extensions.findByType(T::class)
ext?.configure()
}
}

inline fun <reified T : Task> Project.taskConfig(
crossinline configure: T.() -> Unit
) {
project.afterEvaluate {
tasks.withType(T::class.java) { configure() }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.datadog.gradle.config

import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.gradle.api.Project

fun Project.dependencyUpdateConfig() {

taskConfig<DependencyUpdatesTask> {
revision = "release"
}
}
24 changes: 24 additions & 0 deletions buildSrc/src/main/kotlin/com/datadog/gradle/config/DetektConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.datadog.gradle.config

import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.gradle.api.Project

fun Project.detektConfig() {

extensionConfig<DetektExtension> {
version = "1.0.1"

input = files("$projectDir/src/main/kotlin")
config = files("${project.rootDir}/detekt.yml")
reports {
xml {
enabled = true
destination = file("build/reports/detekt.xml")
}
}
}

tasks.named("check") {
dependsOn("detekt")
}
}
38 changes: 38 additions & 0 deletions buildSrc/src/main/kotlin/com/datadog/gradle/config/JacocoConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.datadog.gradle.config

import com.datadog.gradle.Dependencies
import org.gradle.api.Project
import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
import org.gradle.testing.jacoco.tasks.JacocoReport

fun Project.jacocoConfig() {

extensionConfig<JacocoPluginExtension> {
toolVersion = Dependencies.Versions.Jacoco
reportsDir = file("$buildDir/jacoco") // Jacoco's output root.
}

taskConfig<JacocoReport> {
reports {
csv.isEnabled = false
xml.isEnabled = true
html.isEnabled = true
html.destination = file("$buildDir/jacoco/html")
}
}

// tasks.withType(JacocoCoverageVerification::class.java) {
// violationRules {
// rule {
// limit {
// minimum = 0.85.toBigDecimal()
// }
// }
// }
// }

tasks.named("check") {
dependsOn("jacocoTestReport")
dependsOn("jacocoTestCoverageVerification")
}
}
14 changes: 14 additions & 0 deletions buildSrc/src/main/kotlin/com/datadog/gradle/config/KotlinConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.datadog.gradle.config

import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun Project.kotlinConfig() {

taskConfig<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
}
24 changes: 24 additions & 0 deletions buildSrc/src/main/kotlin/com/datadog/gradle/config/KtLintConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.datadog.gradle.config

import org.gradle.api.Project
import org.jlleitschuh.gradle.ktlint.KtlintExtension

fun Project.ktLintConfig() {

extensionConfig<KtlintExtension> {
debug.set(false)
android.set(true)
outputToConsole.set(true)
ignoreFailures.set(false)
enableExperimentalRules.set(false)
additionalEditorconfigFile.set(file("${project.rootDir}/script/config/.editorconfig"))
filter {
exclude("**/generated/**")
include("**/kotlin/**")
}
}

tasks.named("check") {
dependsOn("ktlintCheck")
}
}
31 changes: 31 additions & 0 deletions buildSrc/src/main/kotlin/com/datadog/gradle/utils/Version.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.datadog.gradle.utils

data class Version(
val major: Int,
val minor: Int,
val hotfix: Int
) {

init {
require(major < MAX_MAJOR) { "The minor component must be smaller than $MAX_MAJOR" }
require(minor < MAX_MINOR) { "The minor component must be smaller than $MAX_MINOR" }
require(hotfix < MAX_HOTFIX) { "The hotfix component must be smaller than $MAX_HOTFIX" }
}

val name: String
get() = "$major.$minor.$hotfix"

val code: Int
get() {
val minPart = minor * MAX_HOTFIX
val majPart = major * MAX_MINOR * MAX_HOTFIX

return hotfix + minPart + majPart
}

companion object {
internal const val MAX_HOTFIX = 10
internal const val MAX_MINOR = 100
internal const val MAX_MAJOR = 100
}
}
Loading

0 comments on commit 0db48d1

Please sign in to comment.