building eclipse plugins with tycho

Post on 07-Jul-2015

7.598 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

EclipseCon 2011 slides for talk

TRANSCRIPT

© 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

© 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

© 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

© 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

© 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

© 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“)

© 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

© 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

© 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:

tycho-users@lists.sonatype.com

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

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

Build Demo

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

Questions?

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

Coffee break

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

Part II: Hands-On Exercises

© 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

© 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

© 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 SelectChannelConnector@0.0.0.0:8081

...

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

• Administrator credentials: admin/admin123

• Developer credentials: eclipsecon/eclipsecon

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

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

Thanks for attending this session!

© 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

top related