Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gradle, je t'aime, moi non plus…

Gradle, je t'aime, moi non plus…

Slides de notre talk avec @dwursteisen à Devoxx FR 2019.

Jeremie Martinez

April 19, 2019
Tweet

More Decks by Jeremie Martinez

Other Decks in Programming

Transcript

  1. Data Payments Backend Core Created Deposited Withdraw Withdraw Closed WRITE

    Event store Reporting Accounting Regulators Data sciences GDPR Users Transfers Customers Collections Cards KYC Limit controller
  2. Un outil de build est comme une banque. On ne

    choisit pas le meilleur mais le moins pire. Un outil de build est comme une banque. On ne choisit pas le meilleur mais le moins pire.
  3. dependencies { compile("io.swagger:swagger-annotations:1.5.0") compile(group = "io.swagger", name = "swagger-annotations", version

    = "1.5.0") compile(project(":otherProject")) testCompile("io.mockk:mockk:1.9.3") customCompile("org.codehaus.janino:janino:2.5.16") }
  4. repositories { mavenCentral() jcenter() google() maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/")

    } maven { url = uri("https://internal") content { includeGroupByRegex("com\\.mycompany.*") } } } Selection des dépendances
  5. repositories { mavenCentral() jcenter() google() maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/")

    } maven { url = uri("https://internal") content { includeGroupByRegex("com\\.mycompany.*") } } ivy { url = uri("https://oss.sonatype.org/content/repositories/releases/") } flatDir { dirs("libs") } }
  6. repositories { mavenCentral() jcenter() google() maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/")

    } maven { url = uri("https://internal") content { includeGroupByRegex("com\\.mycompany.*") } } ivy { url = uri("https://oss.sonatype.org/content/repositories/releases/") } flatDir { dirs("libs") } mavenLocal() } Devrait être inutile
  7. mailer 1.0.0 master dev/feature superProject OK OK KO otherProject OK

    OK OK projectZ OK KO OK Dependency sources Dependency sources
  8. org.gradle.caching=true org.gradle.configureondemand=true org.gradle.jvmargs=-Xmx2048M -Xms2048M org.gradle.parallel=true Réutilisation des résultats de build

    Execution des tâches en parallèle Utilisation d’un maximum de mémoire Configuration uniquement des tâches nécessaires
  9. Data Payments Backend Core Created Deposited Withdraw Withdraw Closed WRITE

    Event store Reporting Accounting Regulators Data sciences GDPR Users Transfers Customers Collections Cards KYC Limit controller
  10. Data Payments Backend Reporting Accounting Regulators Data sciences GDPR Users

    Transfers Customers Collections Cards KYC Limit controller
  11. open class MyExtension(var yourName: String = "not defined!") class MyPlugin

    : Plugin<Project> { override fun apply(project: Project) { } }
  12. open class MyExtension(var yourName: String = "not defined!") class MyPlugin

    : Plugin<Project> { override fun apply(project: Project) { val exts = project.extensions.create("myPlugin", MyExtension::class) } }
  13. open class MyExtension(var yourName: String = "not defined!") class MyPlugin

    : Plugin<Project> { override fun apply(project: Project) { val exts = project.extensions.create("myPlugin", MyExtension::class) project.task("myTask") { doLast { println("hello ${exts.yourName}") } } } }
  14. idea { project { this as ExtensionAware configure<ProjectSettings> { this

    as ExtensionAware configure<NamedDomainObjectContainer<RunConfiguration>> { // cast to PolymorphicDomainObjectContainer to access the create method used bellow. @Suppress("UnstableApiUsage") this as PolymorphicDomainObjectContainer<RunConfiguration> create("Start Application", Application::class) { // … } } } } } Kotlin
  15. object Versions { val assertj = "3.10.0" val junit =

    "4.12" val mockito = "2.19.1" val mockito_kotlin = "1.6.0" val postgres = "42.2.4" val prometheus = "0.6.0" val springboot = "2.1.3.RELEASE" val swagger = "1.5.20" }
  16. object TestDeps { val assertj = "org.assertj:assertj-core:${Versions.assertj}" val junit =

    "junit:junit:${Versions.junit}" val mockito = "org.mockito:mockito-core:${Versions.mockito}" }
  17. object Git { fun commit() = Runtime.getRuntime() .exec("git rev-parse --short

    HEAD") .inputStream.bufferedReader() .readText() } buildSrc