Release management with Gradle #JokerConf2016

  • View
    312

  • Download
    2

Embed Size (px)

Text of Release management with Gradle #JokerConf2016

  • WITH GRADLE

    RELEASE MANAGEMENT

  • @tolkv

    2

    @lavcraft

  • 3

  • !

    4

  • !

    5

  • !

    6

  • !

    7

  • 8

  • 9

  • 10

  • 11

  • vs Gradle

    12

  • vs Gradle

    13

  • Bin

    GIT CI Dev

    Prod14

  • Bin

    GIT CI Dev

    Prod15

  • Bin

    GIT CI Dev

    Prod16

  • 17

  • 18

  • 19

  • 20

  • 21

  • 22

  • 23

  • 24

  • 25

  • ?

    26

    ?

  • ?

    27

    ?

  • ? ?

    28

    ?

  • ? ? ?

    29

    ?

  • ? ? ? -

    30

    ?

  • build.gradle

    31

  • build.gradle settings.gradle

    32

  • build.gradle settings.gradle ./gradlew

    33

  • $ gradle wrapper --gradle-version 3.1

    34

  • $ gradle wrapper --gradle-version 3.1

    :wrapperBUILD SUCCESSFUL

    Total time: 1.835 secs

    35

  • $ ./gradlew init

    36

  • $ ./gradlew init:wrapper:init

    BUILD SUCCESSFUL

    Total time: 0.772 secs

    37

  • $ lsbuild.gradlegradlegradlewgradlew.batsettings.gradle

    38

  • $ lsbuild.gradlegradle/gradlewgradlew.batsettings.gradle

    39

  • $ lsbuild.gradlegradle/gradlewgradlew.batsettings.gradle

    40

  • $ lsbuild.gradlegradle/gradlewgradlew.batsettings.gradle

    41

  • $ lsbuild.gradlegradle/gradlewgradlew.batsettings.gradle

    42

  • ./gradlew build

    43

  • ./gradlew build

    ls ./build/libs/project_name.jar

    44

  • ./gradlew build

    ls ./build/libs/project_name.jar

    ?45

  • , ?

    $ cat build.gradle | grep version

    46

  • , ?

    $ cat build.gradle | grep version

    !

    47

  • , ?

    $ cat build.gradle | grep version

    !

    $ echo "version = '1.0.1'" >> build.gradle

    48

  • , ?

    $ cat build.gradle | grep version

    !

    $ echo "version = '1.0.1'" >> build.gradle

    $ ./gradlew clean build$ ls build/libs/

    project_name-1.0.1.jar

    49

  • ./gradlew -Pversion=1.3.4-SNAPSHOT./gradlew -Pversion=1.3.4-

    50

  • version = file("version.prop").text

    51

  • ?

    Git/Metadataversion = new CustomVersion()

    .loadFrom(file("version.prop"))

    .appVersion()

    52

  • 53

    - git

    ?

  • 54

    - git- -

    ?

  • - git- - -

    55

    ?

  • Zerg Rush?

    56

  • Zerg Rush? google.com: gradle problem_name solution

    57

  • Zerg Rush? google.com: gradle problem_name solution Copy/Past into build.gradle

    58

  • Zerg Rush? google.com: gradle problem_name solution Copy/Paste into build.gradle

    59

  • GrGitversion = GrGit.open(file("."))

    .head()

    .abbreviatedId

    60

  • GrGitversion = GrGit.open(file("."))

    .head()

    .abbreviatedId

    61

  • 1: task release {2: doFirst {3: grgit.tag.add {4: name = version5: message = "Release of ${version}"6: }7: }8: }

    Git?

    62

  • 63

    1. Task definition

  • 64

    1. Task definition

    1: task release(type: Copy) {2: from(file('srcDir'))3: into(buildDir)4: }

  • 65

    1. Task definition

    Task doFirstTask doFirst2. Task doFirst

    1: task release(type: Copy) {2: from(file('srcDir'))3: into(buildDir)4: doFirst {//doing sth #1}5: doFirst {//doing sth #2}

  • 66

    1. Task definition

    Task doFirstTask doFirst2. Task doFirst

    Task doFirstTask doFirst3. Task doLast

    1: task release(type: Copy) {2: from(file('srcDir'))3: into(buildDir)4: doFirst {//doing sth #1}5: doFirst {//doing sth #2}7: doLast {//doing sth #3}8: doLast {//doing sth #4}9: }

  • 67

    1. Task definition

    Task doFirstTask doFirst2. Task doFirst

    Task doFirstTask doFirst3. Task doLast

    1: task release(type: Copy) {2: from(file('srcDir'))3: into(buildDir)4: doFirst {//doing sth #1}5: doFirst {//doing sth #2}7: doLast {//doing sth #3}8: doLast {//doing sth #4}9: }9: release.doLast {//do...#5}

  • 68

    1. Task definition

    Task doFirstTask doFirst2. Task doFirst

    Task doFirstTask doFirst3. Task doLast

    1: task release(type: Copy) {2: from(file('srcDir'))3: into(buildDir)4: doFirst {//doing sth #1}5: doFirst {//doing sth #2}7: doLast {//doing sth #3}8: doLast {//doing sth #4}9: }9: release.doLast {//do...#5}10:release

  • 1: task preRelease {2: ...

    Gradle

    69

  • 1: task preRelease {2: doFirst {4: def br = file(".git/HEAD").text - "ref: refs/head/"

    70

    Gradle

  • 1: println "ref: refs/head/master" - "ref: refs/head/"

    71

    Groovy...

  • 1: println "ref: refs/head/master" - "ref: refs/head/" > "master "

    72

    Groovy...

  • 1: task preRelease {2: doFirst {4: def br = file(".git/HEAD").text - "ref: refs/head/"

    73

    Gradle

  • 1: task preRelease {2: doFirst {4: def br = file(".git/HEAD").text - "ref: refs/head/" 5: def cid = file(".git/refs/heads/$br").text"

    74

    Gradle

  • 1: task preRelease {2: doFirst {4: def br = file(".git/HEAD").text - "ref: refs/head/" 5: def cid = file(".git/refs/heads/$br").text" 6: def tag = grgit.tag.list()7: .first()8: .getName()

    75

    Gradle

  • 1: task preRelease {2: doFirst {4: def br = file(".git/HEAD").text - "ref: refs/head/" 5: def cid = file(".git/refs/heads/$br").text" 6: def tag = grgit.tag.list()7: .first()8: .getName()9: version = tag + br && cid ? "-$br-$cid":"" 10:}11:tasks.release.dependsOn preRelease

    76

    Gradle

  • v1.0.1-master-a6f5ac0677421f486bd273ba4016e51b7634afa9

    77

  • v1.0.1-master-a6f5ac0677421f486bd273ba4016e51b7634afa9

    uncommitted

    78

  • v1.0.1-master-a6f5ac0677421f486bd273ba4016e51b7634afa9

    uncommitted release

    79

  • v1.0.1-master-a6f5ac0677421f486bd273ba4016e51b7634afa9

    uncommitted release dependencies

    80

  • jar {

    manifest { attributes(

    "Manifest-Version" : "1.0","Implementation-Version": version,

    ) }

    }

    81

  • jar { manifest {

    attributes(["Manifest-Version" :"1.0", "Implementation-Version":version,]

  • Manifest-Version: 1.0Implementation-Title: ru.joker.demo#app;0.3.0-rc.2Module-Origin: ssh://git@git/joker/demo-app.gitBuild-Date: 2016-08-11_07:09:52Build-Id: LOCALImplementation-Version: 0.3.0-rc.2Build-Number: LOCALBuilt-By: tolkvChange: 18d2261Module-Source: /appBranch: masterSpring-Boot-Version: 1.3.6.RELEASEBuilt-Status: integrationGradle-Version: 2.13Build-Job: LOCALBuilt-OS: Mac OS XX-Compile-Target-JDK: 1.8Build-Host: tolkv-workStart-Class: ru.sense.user.UserApplicationX-Compile-Source-JDK: 1.8Created-By: 1.8.0_60-b27 (Oracle Corporation)Build-Java-Version: 1.8.0_60

    Manifest.mf

    83

  • Manifest-Version: 1.0Implementation-Title: ru.joker.demo#app;0.3.0-rc.2Module-Origin: ssh://git@git/joker/demo-app.gitBuild-Date: 2016-08-11_07:09:52Build-Id: LOCALImplementation-Version: 0.3.0-rc.2Build-Number: LOCALBuilt-By: tolkvChange: 18d2261Module-Source: /appBranch: masterSpring-Boot-Version: 1.3.6.RELEASEBuilt-Status: integrationGradle-Version: 2.13Build-Job: LOCALBuilt-OS: Mac OS XX-Compile-Target-JDK: 1.8Build-Host: tolkv-workStart-Class: ru.sense.user.UserApplicationX-Compile-Source-JDK: 1.8Created-By: 1.8.0_60-b27 (Oracle Corporation)Build-Java-Version: 1.8.0_60

    Manifest.mf

    84

  • 85

    +X LOC

  • +X LOC +Y LOC

    86

  • +X LOC +Y LOC git manifest +Z LOC publish* +M LOC

    87

  • +X LOC +Y LOC git manifest +Z LOC publish* +M LOC

    build.gradle88

  • 3

    build.gradle

    89

  • 3 2000

    90

    build.gradle

  • 3 2000 30

    91

    build.gradle

  • 3 2000 30

    92

    build.gradle

  • ?

    93

  • 94

    ?

  • 95

    ?

  • !

    96

  • build.gradle:apply from: "http://someorg.com/version.gradle"

    Copy apply

    97

  • build.gradle:apply from: "http://someorg.com/version.gradle"apply from: "http://someorg.com/maven.gradle"

    98

    Copy apply

    http://someorg.com/version.gradlehttp://someorg.com/version.gradlehttp://someorg.com/version.gradle

  • build.gradle:apply from: "http://someorg.com/version.gradle"apply from: "http://someorg.com/maven.gradle"apply from: "http://someorg.com/check.gradle"

    99

    Copy apply

    http://someorg.com/version.gradlehttp://someorg.com/maven.gradle

  • build.gradle:apply from: "http://someorg.com/version.gradle"apply from: "http://someorg.com/maven.gradle"apply from: "http://someorg.com/check.gradle"apply from: "http://someorg.com/findbugs.gradle"apply from: "http://someorg.com/verify.gradle"apply from: "http://someorg.com/publish.gradle"apply from: "http://someorg.com/awesome!.gradle"

    100

    Copy apply

    http://someorg.