Maven 3 / Tycho

53
© itemis AG 2010 – Alle Rechte vorbehalten 1 Maven 3 / Tycho Eclipse and Maven coexisting in harmony Karsten Thoms 2010-05-10

description

The Tycho project aims to enable Maven to build Eclipse based artifacts (plugins, features, update sites, products). This presentation was held at a public event from itemis in Dortmund, showing how Tycho is used and some news to the upcoming Maven 3 release.

Transcript of Maven 3 / Tycho

Page 1: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten 1

Maven 3 / TychoEclipse and Maven coexisting in harmony

Karsten Thoms2010-05-10

Page 2: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

About me

• Working as consultant for itemis• Over 10 years experience in Enterprise Java, Model Driven Software Development

• Open Source enthusiast, MDSD evangelist• Project (co-)lead: The Fornax Platform, fit4oaw, Hybridlabs

Beautifier• Committer / Contributor: Eclipse EMFT MWE, M2T Xpand,

openArchitectureWare, Fornax Maven plugin for oAW/MWE, Fornax UML2 cartridges for oAW, AUTOSAR Tool Platform (ARTOP)

• Using Maven in my Open Source projects and some customer projects

2

Page 3: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Maven Tycho

3

Page 4: Maven 3 / Tycho

• MP3 Manager• RCP Example from Kai Tödter• http://max-server.myftp.org/trac/mp3m

© itemis AG 2010 – Alle Rechte vorbehalten

Example used for Tycho demo

4

Page 5: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Example RCP Application

• Project types in this application• Plugins• Features• Update Site• Products

• Product come with different brandings: blue, orange, german

• Build Target:• Create ZIP distributions for branded

products

5

Page 6: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Automated Build for Eclipse/OSGi

• Several frameworks serving this task• PDE Build• Buckminster• Pluginbuilder• b3• Athena Common Build Infrastructure

• Often hard to setup, maintain and debug a working headless build• P2 makes some things better and many worse

6

Page 7: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Tycho

• Maven extensions for Eclipse / OSGi• Seamless build for Eclipse artifacts

• Plugins, Plugin-Tests, Features, Update Sites, Products• Manifest-first approach• POM needed for each module, but minimal one• Tight integration with Equinox / P2• Proposed as project under the Eclipse Technology project in April 2010

7

Page 8: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Eclipse project structure

8

Page 9: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Maven project structure

9

Page 10: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Packaging extensions

• Target artifact type is specified with <packaging> element in pom.xml

• Standard packaging types:• pom - jar• war - ear• ...

• Tycho adds Eclipse specific packaging types• eclipse-plugin - eclipse-test-plugin• eclipse-feature - eclipse-update-site• eclipse-application

10

Page 11: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Target Platform

• Set of plugins and features, against which modules/projects are built

• Computed seperately for each module• Configurable via

• System property -Dtycho.targetPlatform=<eclipsehome>

• Repositories in POM with <layout>p2</layout>

• Target Platform Definition file (.target) stored in a Maven repository

11

Page 12: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Target Platform - Repositories

12

<repositories>

<repository>

<id>galileo</id>

<layout>p2</layout>

<url>http://download.eclipse.org/releases/galileo</url>

</repository>

<repository>... </repository>

</repositories>

Page 13: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Repositories

P2 Repository

13

Maven2 Repository

Page 14: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Creating a P2 Repository with Equinox FeaturesAndBundlesPublisher

14

Page 15: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Creating a P2 Repository with Equinox FeaturesAndBundlesPublisher

15

Page 16: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Getting started with Tycho

• Get Maven 3 Installation• Add a pom.xml to each project• Bootstrap pom.xml creation:

mvn \ org.sonatype.tycho:maven-tycho-plugin:generate-poms \ -DgroupId=com.siemens.ct.mp3m \ -Dversion=3.5.1-SNAPSHOT \ -Dtycho.targetPlatform=<path-to-eclipse>

16

Page 17: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

pom.xml bootstrapping

17

Page 18: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Project coordinates

OSGi Maven / TychoBundle-SymbolicName: com.siemens.ct.mp3m.model

<groupId>com.siemens.ct.mp3m</groupId><artifactId>mp3m.model</artifactId>

or...

<groupId>com.siemens.ct.mp3m</groupId><artifactId>com.siemens.ct.mp3m.model</artifactId>

Bundle-Version: 3.5.1.qualifier

<version>3.5.1-SNAPSHOT</version>

Bundle-Version: 3.5.1.qualifier

<version>3.5.1</version>

18

Page 19: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Packaging: eclipse-plugin

19

Page 20: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Packaging: eclipse-plugin

19

Page 21: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Packaging: eclipse-feature

20

Page 22: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Packaging: eclipse-feature

20

Page 23: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Packaging: eclipse-update-site

21

Page 24: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Packaging: eclipse-application

22

Page 25: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Packaging: eclipse-application

22

Page 26: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Parent POM

• Aggregates all projects as modules• Common build settings

• Tycho plugins• Other Maven plugins• Repositories• Target platform• Target environments

• Usually in the directory „above“ the projects• This would be the workspace root in Eclipse!

23

Page 27: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Parent POM

24

Page 28: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Parent POM

24

Page 29: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Integration of Tycho builds into Hudson

25

Page 30: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Add Maven 3 Installation

26

Page 31: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Create Free-Style Job

27

Page 32: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Create Free-Style Job

28

Page 33: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Create Free-Style Job

29

Page 34: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Test drive!

30

Page 35: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Test drive!

31

Page 36: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Test drive!

32

Page 37: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Test drive!

33

Page 38: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Maven 3

34

Page 39: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Maven 3

• Complete rework of Maven 2• Current version 3.0-beta-1

• Really stable already• Mostly backward compatible• Important projects developed for Maven 3

• m2eclipse• Tycho• Maven Shell• Polyglot Maven

35

Page 40: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Maven Shell

• CLI interface, Wrapper for normal shell• Faster turn-around

• project information always in-memory• plugins loaded only once

36

Page 41: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Maven Shell - Execution Time

• Apache Commons Lang 2.5• Goals: clean package

37

mvn mvnsh

Page 42: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Polyglot Maven

• Multilanguage support for definition of POMs• Alternative to XML POM definition• Supported languages

• Groovy• Scala• JRuby• Clojure

• Xtext external DSL coming up

38

Page 43: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Polyglot Maven - Original POM

39

Page 44: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Polyglot Maven - Groovy

40

Page 45: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Polyglot Maven - Groovy

40

Page 46: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Polyglot Maven - Scala

41

Page 47: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Polyglot Maven - Scala

41

Page 48: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Polyglot Maven - Ruby

42

Page 49: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Polyglot Maven - Ruby

42

Page 50: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

• Maven Tycho can make headless Eclipse Builds easy• Still under development

• Expect some bugs • Report them!• Rapid improvement through developers• Documentation needs to be improved

• Tycho is likely to be the next generation build framework for Eclipse!

• Don‘t fear upgrading to Maven 3

Conclusion

43

Page 51: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Resources

• Tycho Homepage• http://tycho.sonatype.org/

• Tycho Eclipse Project Proposal• http://www.eclipse.org/proposals/tycho/

• Tycho Tutorials• http://www.sonatype.com/people/2008/11/building-eclipse-plugins-with-

maven-tycho/• http://mattiasholmqvist.se/2010/02/building-with-tycho-part-1-osgi-

bundles/• http://eclipse.dzone.com/news/how-build-xulrunner-1912

• MP3 Manager Example, customized for Tycho• git://github.com/kthoms/mp3m.git

44

Page 52: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

Resources

• Maven 3 compatibility noteshttps://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html

• Maven Shellhttp://shell.sonatype.org/

• Polyglot Mavenhttp://polyglot.sonatype.orghttps://docs.sonatype.org/display/PMAVEN/Home

45

Page 53: Maven 3 / Tycho

© itemis AG 2010 – Alle Rechte vorbehalten

KANBAN-Compact with Matthias Bohlen

Further Informations and Registration:

www.itemis.de/Veranstaltungen

Topics covered:

- Introduction to Lean, Pull-Systems and Kanban- Examples and Casestudies- Kanban recipe for success: The ingredients- How to start with Kanban- How to be more productive with Kanban- How Kanban and Scrum fit together

Location: Top of Cologne, CologneDate: September 13thTime: 14:00 - 18:00 Price : 99 €

46