Slide 1

Slide 1 text

Dependency Management in Gradle 5 and beyond Jendrik Johannes, Gradle

Slide 2

Slide 2 text

PRODUCER A Model of Software Reuse

Slide 3

Slide 3 text

PRODUCER CONSUMER A Model of Software Reuse

Slide 4

Slide 4 text

PRODUCER CONSUMER REPOSITORY push software component component metadata A Model of Software Reuse

Slide 5

Slide 5 text

PRODUCER CONSUMER REPOSITORY push software component component metadata pull component metadata software component A Model of Software Reuse

Slide 6

Slide 6 text

Chapter 1: Versioning of Software Components Chapter 2: Different Variants of Software Components Chapter 3: Dealing with an imperfect World

Slide 7

Slide 7 text

Chapter 1: Versioning of Software Components Chapter 2: Different Variants of Software Components Chapter 3: Dealing with an imperfect World

Slide 8

Slide 8 text

PRODUCER CONSUMER REPOSITORY push software component component metadata pull component metadata software component

Slide 9

Slide 9 text

PRODUCER CONSUMER REPOSITORY push software component component metadata pull component metadata software component NULL 8 FUFFZEHN // BANK !

Slide 10

Slide 10 text

PRODUCER CONSUMER REPOSITORY push software component component metadata pull component metadata software component NULL 8 FUFFZEHN // BANK SantaSoft " !

Slide 11

Slide 11 text

NULL 8 FUFFZEHN // BANK

Slide 12

Slide 12 text

XMasTree by SantaSoft Open-source out-of-the-box Christmas trees for Java! From Christmas tree lovers for Christmas tree lovers! Maven dependencies { // just add your tree... implementation(“com.santasoft.xmastree:tree-swing:1.0”) // ...and decorate it as you like implementation(“com.santasoft.xmastree:lights-swing:1.0”) } Gradle // inject it in your UI code com.santasoft.xmastree.Tree.compose(container)

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

NULL 8 FUFFZEHN // BANK

Slide 18

Slide 18 text

XMasTree by SantaSoft Open-source out-of-the-box Christmas trees for Java! From Christmas tree lovers for Christmas tree lovers! Maven dependencies { // just add your tree... implementation(“com.santasoft.xmastree:tree-swing:2.0”) // ...and decorate it as you like implementation(“com.santasoft.xmastree:lights-swing:2.0”) } Gradle // inject it in your UI code com.santasoft.xmastree.Tree.compose(container) 2.0 W ITH FLASHY LIGHTS!

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Why did the Christmas tree crash? tree:1.0 lights:1.0 ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0 component repository

Slide 22

Slide 22 text

component repository Why did the Christmas tree crash? tree:1.0 lights:1.0 null8fuffzehn-desktop ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0

Slide 23

Slide 23 text

component repository Why did the Christmas tree crash? tree:1.0 lights:1.0 null8fuffzehn-desktop ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0

Slide 24

Slide 24 text

component repository Why did the Christmas tree crash? tree:1.0 lights:1.0 null8fuffzehn-desktop ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0

Slide 25

Slide 25 text

component repository Why did the Christmas tree crash? tree:1.0 lights:1.0 null8fuffzehn-desktop ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0

Slide 26

Slide 26 text

component repository Why did the Christmas tree crash? tree:1.0 lights:1.0 null8fuffzehn-desktop ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0

Slide 27

Slide 27 text

component repository Why did the Christmas tree crash? tree:1.0 lights:1.0 null8fuffzehn-desktop ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0 conflict !

Slide 28

Slide 28 text

component repository Dependency Constraints tree:1.0 lights:1.0 ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0 depends-on

Slide 29

Slide 29 text

component repository Dependency Constraints tree:1.0 lights:1.0 ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0 depends-on (requires + constraints) constraints

Slide 30

Slide 30 text

component repository Dependency Constraints save Christmas tree:1.0 lights:1.0 ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0 depends-on (requires + constraints) constraints null8fuffzehn-desktop

Slide 31

Slide 31 text

component repository Dependency Constraints save Christmas tree:1.0 lights:1.0 ornaments:1.0 train:1.0 tree:2.0 lights:2.0 ornaments:2.0 train:2.0 depends-on (requires + constraints) constraints null8fuffzehn-desktop

Slide 32

Slide 32 text

com.santasoft.xmastree:tree-swing:2.0 github.com/gradle/gradle/blob/master/subprojects/docs/src/ docs/design/gradle-module-metadata-specification.md { "component": { "group": "com.santasoft.xmastree", "module": "tree-swing", "version": "2.0", }, ... "dependencyConstraints": [ { "group": "com.santasoft.xmastree", "module": "lights-swing", "version": { "requires": "2.0" } }, { "group": "com.santasoft.xmastree", "module": "ornaments-swing", "version": { "requires": "2.0" } }, { "group": "com.santasoft.xmastree", "module": "train-swing", "version": { "requires": "2.0" } } ], ... } component repository — tree-swing-2.0.jar — tree-swing-2.0.pom — tree-swing-2.0.module

Slide 33

Slide 33 text

Chapter 1: Versioning of Software Components Chapter 2: Different Variants of Software Components Chapter 3: Dealing with an imperfect World

Slide 34

Slide 34 text

NULL 8 FUFFZEHN // BANK

Slide 35

Slide 35 text

NULL 8 FUFFZEHN // BANK

Slide 36

Slide 36 text

Gradle_Android XMasTree by SantaSoft Open-source out-of-the-box Christmas trees for Java! From Christmas tree lovers for Christmas tree lovers! Maven dependencies { // just add your tree... implementation(“com.santasoft.xmastree:tree-swing:2.0”) // ...and decorate it as you like implementation(“com.santasoft.xmastree:lights-swing:2.0”) } Gradle // inject it in your UI code com.santasoft.xmastree.Tree.compose(container) NOW ALSO FOR ANDROID! 2.0 W ITH FLASHY LIGHTS!

Slide 37

Slide 37 text

Gradle XMasTree by SantaSoft Open-source out-of-the-box Christmas trees for Java! From Christmas tree lovers for Christmas tree lovers! Maven dependencies { // just add your tree... implementation(“com.santasoft.xmastree:tree-android:2.0”) // ...and decorate it as you like implementation(“com.santasoft.xmastree:lights-android:2.0”) } // inject it in your UI code com.santasoft.xmastree.Tree.compose(container) Gradle_Android NOW ALSO FOR ANDROID! 2.0 W ITH FLASHY LIGHTS!

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

component repository Modeling Platforms as Variants tree-swing lights-swing null8fuffzehn-desktop ornaments-swing train-swing tree-android lights-android null8fuffzehn-android ornaments-android train-android

Slide 42

Slide 42 text

component repository Modeling Platforms as Variants tree-swing lights-swing ornaments-swing train-swing tree-android lights-android ornaments-android train-android null8fuffzehn-shared null8fuffzehn-desktop null8fuffzehn-android

Slide 43

Slide 43 text

component repository Modeling Platforms as Variants tree-swing lights-swing ornaments-swing train-swing tree-android lights-android ornaments-android train-android null8fuffzehn-shared null8fuffzehn-desktop null8fuffzehn-android tree lights ornaments train variant ui-framework = swing variant ui-framework = android ui-framework = swing ui-framework = android

Slide 44

Slide 44 text

component repository Modeling Platforms as Variants tree-swing lights-swing ornaments-swing train-swing tree-android lights-android ornaments-android train-android null8fuffzehn-shared null8fuffzehn-desktop null8fuffzehn-android tree lights ornaments train variant ui-framework = swing variant ui-framework = android ui-framework = swing ui-framework = android

Slide 45

Slide 45 text

component repository Modeling Platforms as Variants tree-swing lights-swing ornaments-swing train-swing tree-android lights-android ornaments-android train-android null8fuffzehn-shared null8fuffzehn-desktop null8fuffzehn-android tree lights ornaments train variant ui-framework = swing variant ui-framework = android ui-framework = swing ui-framework = android

Slide 46

Slide 46 text

Gradle_Android Gradle XMasTree by SantaSoft Open-source out-of-the-box Christmas trees for Java! From Christmas tree lovers for Christmas tree lovers! Maven // configure your tree dependencies { implementation(“com.santasoft.xmastree:lights”) } // choose your variant configurations.all { attributes { attribute(“ui-framework”, “android”) } } // inject it in your UI code com.santasoft.xmastree.Tree.compose(container) NOW ALSO FOR ANDROID! 2.0 W ITH FLASHY LIGHTS! NOW W ITH VARIANT SUPPORT! Gradle_Variants

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

com.santasoft.xmastree:tree:2.0 github.com/gradle/gradle/blob/master/subprojects/docs/src/ docs/design/gradle-module-metadata-specification.md { "component": { "group": "com.santasoft.xmastree", "module": "tree", "version": "2.0", "attributes": { "org.gradle.status": "release" } }, "variants": [ { "name": "swing-api", "attributes": { "org.gradle.usage": "java-api", "ui-framework": "swing" }, "available-at": { "url": "../../tree-swing/2.0/tree-swing-2.0.module", "group": "com.santasoft.xmastree", "module": "tree-swing", "version": "2.0" } }, { "name": "android-api", "attributes": { "org.gradle.usage": "java-api", "ui-framework": "android" }, "available-at": { "url": "../../tree-swing/2.0/tree-android-2.0.module", "group": "com.santasoft.xmastree", "module": "tree-android", "version": "2.0" } } ] ... } component repository — tree-swing-2.0.module

Slide 50

Slide 50 text

Chapter 1: Versioning of Software Components Chapter 2: Different Variants of Software Components Chapter 3: Dealing with the imperfect World

Slide 51

Slide 51 text

NULL 8 FUFFZEHN // BANK

Slide 52

Slide 52 text

What if the consumer has a different opinion than the producer?

Slide 53

Slide 53 text

PRODUCER CONSUMER REPOSITORY push software component component metadata pull component metadata software component NULL 8 FUFFZEHN // BANK SantaSoft " ! What if the consumer has a different opinion than the producer?

Slide 54

Slide 54 text

component repository tree lights ornaments train What if the consumer has a different opinion than the producer? null8fuffzehn-desktop

Slide 55

Slide 55 text

component repository tree lights ornaments train What if the consumer has a different opinion than the producer? null8fuffzehn-desktop Component Metadata Rule

Slide 56

Slide 56 text

What if the producer “forgot” an important variant?

Slide 57

Slide 57 text

Gradle_Variants Gradle_Android Gradle XMasTree by SantaSoft Open-source out-of-the-box Christmas trees for Java! From Christmas tree lovers for Christmas tree lovers! Maven // configure your tree dependencies { implementation(“com.santasoft.xmastree:lights”) } // choose your variant configurations.all { attributes { attribute(“ui-framework”, “gif”) } } // inject it in your UI code com.santasoft.xmastree.Tree.compose(container) NOW ALSO FOR ANDROID! 2.0 W ITH FLASHY LIGHTS! NOW W ITH VARIANT SUPPORT! NOW ALSO AS FLASHY GIF VARIANT! GIF

Slide 58

Slide 58 text

component repository tree-swing lights-swing ornaments-swing train-swing tree-gif lights-gif null8fuffzehn-shared null8fuffzehn-gif tree lights ornaments train variant ui-framework = swing variant ui-framework = gif ui-framework = gif What if the producer “forgot” an important variant?

Slide 59

Slide 59 text

component repository tree-swing lights-swing ornaments-swing train-swing tree-gif lights-gif null8fuffzehn-shared null8fuffzehn-gif tree lights ornaments train variant ui-framework = swing variant ui-framework = gif ui-framework = gif X What if the producer “forgot” an important variant?

Slide 60

Slide 60 text

What if the producer “forgot” an important variant?

Slide 61

Slide 61 text

What if the producer “forgot” an important variant? Artifact Transform

Slide 62

Slide 62 text

component repository tree-swing lights-swing ornaments-swing train-swing tree-gif lights-gif null8fuffzehn-shared null8fuffzehn-gif tree lights ornaments train variant ui-framework = swing variant ui-framework = gif ui-framework = gif What if the producer “forgot” an important variant? train-gif transformed into

Slide 63

Slide 63 text

Chapter 1: Versioning of Software Components Chapter 2: Different Variants of Software Components Chapter 3: Dealing with the imperfect World …and in the real world?

Slide 64

Slide 64 text

https://docs.google.com/document/d/ 1NYGbfz56C0Oh4IGymXjeQUVK4FcRiqDbpc4vGLnDMrY

Slide 65

Slide 65 text

https://docs.google.com/document/d/ 1NYGbfz56C0Oh4IGymXjeQUVK4FcRiqDbpc4vGLnDMrY

Slide 66

Slide 66 text

https://github.com/gradle/gradle/blob/master/buildSrc/subprojects/configuration/src/main/kotlin/ org/gradle/gradlebuild/dependencies/DependenciesMetadataRulesPlugin.kt

Slide 67

Slide 67 text

https://github.com/gradle/gradle/blob/master/buildSrc/subprojects/packaging/src/main/kotlin/ org/gradle/gradlebuild/packaging/MinifyTransform.kt

Slide 68

Slide 68 text

Gradle Summit 2017
 Dependencies, distributed code and engineering velocity
 - Mike McGarr, Netflix https://www.youtube.com/watch?v=k_mPS_1JpXM

Slide 69

Slide 69 text

Dependency Management in Gradle 5 and beyond Jendrik Johannes, Gradle

Slide 70

Slide 70 text

Dependency Constraints dependencies { implementation("org.apache.httpcomponents:httpclient") constraints { implementation("org.apache.httpcomponents:httpclient:4.5.3") { because("previous versions have a bug impacting this application") } implementation("commons-codec:commons-codec:1.11") { because("version 1.9 pulled from httpclient has bugs affecting this application") } } }

Slide 71

Slide 71 text

BOM/Platform support dependencies { // import a BOM implementation(platform( “org.springframework.boot:spring-boot-dependencies:1.5.8.RELEASE")) // define dependencies without versions implementation("com.google.code.gson:gson") implementation("dom4j:dom4j") }

Slide 72

Slide 72 text

dependencies { // get recommended versions from the platform project api(platform(project(":platform"))) // no version required api("commons-httpclient:commons-httpclient") } Java Platform Plugin consumer plugins { `java-platform` } dependencies { constraints { // Platform declares some versions of libraries used in subprojects api("commons-httpclient:commons-httpclient:3.1") api("org.apache.commons:commons-lang3:3.8.1") } } producer

Slide 73

Slide 73 text

(New) Maven Publish Plugin publishing { publications { create("maven") { groupId = "org.gradle.sample" artifactId = "project1-sample" version = "1.1" from(components["java"]) } } } enableFeaturePreview("GRADLE_METADATA") settings.gradle.kts

Slide 74

Slide 74 text

Dependency Locking configurations.compileClasspath { resolutionStrategy.activateDependencyLocking() }

Slide 75

Slide 75 text

Repository to dependency matching repositories { maven { url "https://repo.mycompany.com" content { includeGroupByRegex "com\\.mycompany.*" } } }

Slide 76

Slide 76 text

Christmas Tree by Jordan Irwin – https://opengameart.org/content/christmas-tree-0 Compose your own Christmas trees: https://github.com/jjohannes/xmas-tree-reuse