sander soo - ut · pdf fileproject object model - pom.xml ... 19. 20 „a wiki is a

25
Sander Soo

Upload: letu

Post on 08-Mar-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

Sander Soo

2

Manual tasks of repetitive nature are very tiresome

Not really headline news

Noone really wants to do them

Manual work is error prone

Manual work is slow

E.g. Alan Turing and Enigma

Actual and very real time bounded calculation

Today’s world this is called project deadline

If only there was a way to improve this...

3

Developers are people too

We also hate menial repetitive tasks

Why not „program“ the steps for repetitive actions

Faster project setup

Consistency and repeatability of tasks

Scalability

Find and download 1000 dependencies (with also their own dependencies)

Parallel tasks

More efficient

Less chance for human error

...

Continuous integration

E.g. Bamboo4

EVERYTHING ...within reason

Documentation Single source of truth for process workflow

Packaging & setup Keeps environments as similar as possible

Eliminates mistakes (oops, I forgot to do X before Y, now „live“ environment is ruined)

Deployment E.g. Test environment uses one port, Live uses different port

Testing Automated tests – 1st barrier for silly mistakes

E.g. Test Driven Development – suite of tests to trust your life to

5

Makefile Old as dirt (initial release 1977)

Still used in C/C++ world

not covered here

Ant + Ivy

Maven

Gradle

6

Before:

Want to use a library in a project (specific version of a library)

Google – download – copy paste to project

Then find that library needs some other specific version of a dependency

Repeat

Not scalable

After

Define what dependency is needed (with a version)

Build project

All dependencies downloaded automatically

e.g. from Maven central, mvnrepository.com

7

Two distinct tools

Ant – for building

Key file: build.xml

Complex

Custom for every project

Verbose

Ivy – dependency management

8

<target name="compile">

<mkdir dir="build/classes"/>

<javac srcdir="src" destdir="build/classes"/>

</target>

<target name="A"/>

<target name="B" depends="A"/>

<ivy-module version="2.0">

<info organisation="org.apache" module="hello-ivy"/>

<dependencies>

<dependency org="commons-lang"

name="commons-lang" rev="2.0"/>

<dependency org="commons-cli"

name="commons-cli" rev="1.0"/>

</dependencies>

</ivy-module>

Describes how software is built

Describes the dependencies Transitive dependency management

Standardized All maven projects are similar

Predefined tasks

e.g. cleaning, compilation, packaging, etc.

Convention over configuration Only exceptions need to be written

e.g. Convention that „src/test/java“ contains Java tests

Project Object Model - pom.xml provides all configuration for a project

9

<project>

<modelVersion>4.0.0</modelVersion>

<!-- project coordinates, i.e. a group of values which uniquely identify this project -->

<groupId>com.mycompany.app</groupId>

<artifactId>my-app</artifactId>

<version>1.0</version>

<!-- library dependencies -->

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>3.8.1</version>

<scope>test</scope> <!-- this dependency is only used for running and compiling tests -->

</dependency>

</dependencies>

</project> 10

Common layout across all projects

Different projects still follow same conventions

e.g. main source code separate from test source code

e.g. resources separate from source code

main and test resources separated

...

Surprise user as little as possible

e.g. Find location of code written in Erlang (src/main/erlang)

Archetype (project template)

generate project based on a template, e.g. webapp

11

Simple Maven project

structure

Best parts of the previous tools Flexible

Dependency management Can resolve both Ivy and Maven dependencies

Migration of old systems should be easier

Convention over configuration

...

Heart of gradle project – build.gradle No XML

Build scripts are code Written in Groovy

Use variables, print statements, for loops, etc.

Gradle wrapper Automatically download correct version of Gradle for the job

Execute tasks

12

group 'com.example.concurrentchat'

version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {

mavenCentral()

}

dependencies {

compile 'commons-io:commons-io:2.5'

compile 'org.apache.commons:commons-lang3:3.4'

testCompile group: 'junit', name: 'junit', version: '4.+'

}

13

Main unit of work in gradle script

Tasks and build phases

Initialization

Configuration

Execution

Task dependencies task other (dependsOn: 'compile')

Dependencies are run before the other tasks

Default tasks

Tasks that are run when tasks are not specified

defaultTasks ‘hello’

14

task hello {doLast {

println 'Hello world!'

}

}

> gradle –q hello

Hello world!

15

A set of tasks to expand the project features

Modularization of build script

Easy to write and maintain

It is just code

(It is not XML)

Many predefined plugins exist

Google first, write later

16

17

apply plugin: GreetingPlugin

class GreetingPlugin implements Plugin<Project> {

void apply(Project project) {

project.task('hello') << {

println "Hello from the GreetingPlugin"

}

}

}

There exist many of these plugins

apply plugin: 'java'

Uses maven structure

Defines tasks for cleaning, packaging, generation of javadoc, etc.

apply plugin: 'com.android.application'

Defines specific tasks for Android projects

apply plugin: 'net.researchgate.release'

Provides tasks for releasing a version (release automation)

Automatically creates a tag, fails if something is wrong, etc.

...

18

Depending on your IDE and version, may be built-in/preincluded

Eclipse

Maven plugin: http://marketplace.eclipse.org/content/maven-integration-eclipse-luna-and-newer

Gradle plugin: http://marketplace.eclipse.org/content/buildship-gradle-integration

IntelliJ IDEA

Has a lot of plugins preenabled

Maven and Gradle should already be there

19

20

„A wiki is a website that provides collaborative modification of its content and structure directly from the web browser“

Several environments to choose from

GitHub

Bitbucket

....

Usually some simple markup to write the docs (not HTML)

Quick with visually appealing result

e.g. Markdown

21

Track feature request, bug reports, etc.

(Non-)programmers can actively participate in development

Issue lifecycle (depends on project and environment)

Open

Resolved

Duplicate

Wontfix

Closed

...

Smart commit comments Include keyword and issue id in commit message

Keyword defines an action

e.g „fixes issue #2“

22

Systematic examination of computer source code

a.k.a „Maybe what you wrote wasn’t gold after all“

Improve overall quality of software

Probability that you missed a bug

Probability that 3 of your co-workers miss it as well

Maybe your whole approach is over-engineered

Others will also be acquainted with the code

23

Jira

Issue tracking and project management

Confluence

Knowledge organization (e.g. specifications, etc.)

Bamboo

Continuous integration

Fisheye

Crucible

Code review tool

...

24

25