26
© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0 | 21 March 2011 Building Eclipse plugins and RCP applications with Tycho, Nexus & Hudson Igor Fedorenko, Sonatype Pascal Rapicault, Sonatype Jan Sievers, SAP

Building Eclipse Plugins with Tycho

Embed Size (px)

DESCRIPTION

EclipseCon 2011 slides for talk

Citation preview

Page 1: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0 | 21 March 2011

Building Eclipse plugins and RCP applications

with Tycho, Nexus & Hudson

Igor Fedorenko, Sonatype

Pascal Rapicault, Sonatype

Jan Sievers, SAP

Page 2: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Contents of this session

Part I: Introduction to Maven Tycho

• What is Tycho?

• What can it do?

• How does it relate to Maven, p2, PDE?

• Who is using it?

• Real-life Build Demo

• Q&A

Part II: Hands-on exercises. Learn how to build

• Plugins/OSGi bundles

• Tests

• Features

• p2 repositories

• RCP applications/products

Page 3: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

What is Tycho?

• A way to build, test, release and publish

Eclipse/OSGi artifacts with maven

It can build

• Eclipse Plugins/OSGi bundles

• Execute tests within the OSGi runtime

• Features

• p2 repositories

• RCP applications a.k.a. Products

Page 4: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Who is working on tycho?

• Tycho started a couple of years ago from the need to have the

ability to build eclipse plugins using Maven

• The initial work has been started by Tom Huybrechts

• Sonatype joined the forces shortly after that

• Nowadays, the main contributors are SAP, Sonatype and Intalio

Page 5: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Who is using it?

• Tycho is used in production by Intalio

SAP

Sonatype

• Open source projects of different size and complexity EGit

Eclipse Memory Analyzer

RT Jetty

Equinox p2

Tigerstripe

JBoss Tools

Page 6: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

How does it relate to maven?

• Tycho is a set of maven 3 plugins which hooks into the build

lifecycle at a low level

• As such, it opens up eclipse/OSGi builds to the rich Maven

ecosystem of plugins for code generators, quality analysis

tools, code coverage, etc.

• How is it different from other maven plugins? It introduces support for resolving dependencies against p2

repositories

It resolves dependencies based on MANIFEST.MF/feature.xml etc.

and tries to reuse other PDE metadata like build.properties

(„MANIFEST-first“ as opposed to „POM-first“)

Page 7: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

How does it relate to p2?

• Tycho produces p2 repositories as part of a build

• Tycho downloads the dependencies of the entities being built

from p2 repositories. By default, Tycho does not resolve its

dependencies from Maven repositories because the Maven

dependency and repository models can not accommodate the

expression of OSGi dependencies like Import-Package

• Tycho embeds parts of p2 in order to perform the dependency

resolution and a few other key operations like publishing

Page 8: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

How does it relate to PDE?

• Tycho reuses some of the files that are being used by PDE Build

such as

MANIFEST.MF, build.properties, feature.xml, site.xml, .product

where it makes sense

• This allows to reuse PDE UI infrastructure like classpath

management, launching capabilities, editors for OSGi

manifest, features, product files, target platforms etc.

• Tycho being a headless build mechanism, it "competes" with PDE

build only in the sense that it provides an alternative way to do a

headless build of plugins and other eclipse artifacts

Page 9: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Where is Tycho?

• Tycho is an open source project run by Sonatype

• It has recently been given to the Eclipse Foundation

and is currently incubating

• We are in the process of contributing the code to Eclipse

Foundation but it‘s not done yet. Getting Tycho and its

dependencies through Eclipse legal process is a lot of work

• Project homepage http://eclipse.org/tycho

• Currently the codebase is still on github

• Users and development mailing lists:

[email protected]

• Bugs filed at https://issues.sonatype.org/browse/TYCHO

Page 10: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Build Demo

Page 11: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Questions?

Page 12: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Coffee break

Page 13: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Part II: Hands-On Exercises

Page 14: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Setting up the environment

• Unzip theinternet.zip Windows

To C:\eclipsecon2011

Linux and Mac OSX

To /var/tmp/eclipsecon2011

• Setup your Maven local repository Windows

(from home folder) ren .m2 .m2-backup

cd .m2

copy c:\eclipsecon2011\settings.xml

Linux and Mac OSX

mv ~/.m2 ~/.m2-backup; mkdir ~/.m2

cp /var/tmp/eclipsecon2011/settings.xml ~/.m2

Page 15: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Setting up the environment (cont’ed)

• Make sure JAVA_HOME is set; JAVA_HOME/bin is on PATH

• Start Nexus Windows

C:\eclipsecon2011\nexus\bin\jsw\windows-x86-32\nexus.bat

Linux x86 /var/tmp/eclipsecon2011/nexus/bin/jsw/linux-x86-32/nexus start

Linux x86_64 /var/tmp/eclipsecon2011/nexus/bin/jsw/linux-x86-64/nexus start

Mac OSX /var/tmp/eclipsecon2011/nexus/bin/jsw/macosx-universal-64/nexus start

Page 16: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Setting up the environment (cont’ed)

• Make sure Nexus has started successfully

In sonatype-work/nexus/logs/nexus.log

...

com.sonatype.nexus.pgp.DefaultPGPKeyManager - Creating PGP Key Collection for

the first time.

org.mortbay.log - Started [email protected]:8081

...

• Access Nexus Web GUI• http://localhost:8081/nexus

• Administrator credentials: admin/admin123

• Developer credentials: eclipsecon/eclipsecon

Page 17: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Setting up the environment (cont’ed)

• Unzip Eclipse IDE to eclipsecon2011 Windows

ide\eclipsecon2011.tycho.tutorial.ide-win32.win32.x86.zip

Linux x86

ide/eclipsecon2011.tycho.tutorial.ide-linux.gtk.x86.zip

Linux x86_64

ide/eclipsecon2011.tycho.tutorial.ide-linux.gtk.x86_64.zip

Max OSX

ide/eclipsecon2011.tycho.tutorial.ide-win32.win32.x86.zip

• Start Eclipse IDE by running eclipsecon2011/eclipse/eclipse

Page 18: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

settings.xml

• http://www.sonatype.com/books/mvnref-book/reference/appendix-settings.html

• <servers> id: This is the id of the server (not of the user to login as) that matches

the <repository/>, <pluginRepository> and <mirror/> element's id.

username/password: credentials to access matching repositories, plugin

repositories and mirrors.

• <mirrors> id, name: The unique identifier of this mirror. The id is used to differentiate

between mirror elements.

url: The base URL of this mirror. The build system will use prepend

this URL to connect to a repository rather than the default serverURL.

mirrorOfThe id of the server that this is a mirror of. For example, to point to a

mirror of the Maven central server (http://repo1.maven.org/maven2), set this

element to central. This must not match the mirror id.

• <repositories> blocks accidental access to Maven Central repository

Page 19: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Building an RCP app in 5 step-by-step exercises

1. Build a simple RCP plugin

2. Build and execute a simple test

3. Add a feature

4. Add a repository

5. Add a product

• Each step has a folder with stub content as a starting point

• README.txt gives detailed step-by-step instructions

• The folder for an exercise is at the same time starting point for

the current exercise and solution of the previous one

Page 20: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Exercise 1: Create and build a hello world RCP

plugin using tycho

• Detailed instructions in

Exercise_01_Create_RCP_Bundle/README.txt

Page 21: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Exercise 2: Add a test fragment with a simple

JUnit test

• Detailed instructions in

Exercise_02_Add_Test_Fragment/README.txt

Page 22: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Exercise 3: Add a feature

• Detailed instructions in Exercise_03_Add_Feature/README.txt

Page 23: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Exercise 4: Add a p2 repository

• Detailed instructions in

Exercise_04_Add_P2_Repository/README.txt

Page 24: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Exercise 5: Add a product

• Detailed instructions in Exercise_05_Add_Product /README.txt

Page 25: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Thanks for attending this session!

Page 26: Building Eclipse Plugins with Tycho

© 2011 by Sonatype Inc. and SAP AG; made available under the EPL v1.0

Backup Slides

• JBoss Tools build

• Tycho builds on hudson.eclipse.org

• VEX build on eclipse.org