Eclipse Yoxos Services Downloads Blogs About
Home > Blogs >

Posts Tagged ‘build’

on Jan 17th, 2011How to build a RAP application with Tycho

Recently I played around a little with Tycho because we evaluated it for the use in the RTP project. As a test case, I decided to try to build a RAP application with Tycho. With building I mean compiling and packaging the artifacts into a WAR file in order to deploy them on a Tomcat or another Servlet Container.

I have to say that I’m really impressed with Tycho. Before this experience, Maven was the “bad thing that downloads the internet” to me. Okay, it still downloads the internet but in this case it’s very useful. You can add p2 repositories to resolve dependencies and it automatically downloads the right bundles. You can define the dependencies in your MANIFEST.MF and use the pom.xml to describe what kind of package it is, e.g. a feature or bundle. For building the RAP application, I just had to add the Helios p2 repository to solve all my feature’s dependencies.

RAP Logo How to build a RAP application with Tycho tycho logo How to build a RAP application with Tycho

Now, you might want to know how to build the application with Tycho yourself. I published the code on github [1]. It’s just the example Mail application and a sample feature that can be built with Tycho. Follow the README instructions to run the build. Here are a few notes you might need if you want to use this configuration as a template for your own build:

  1. Edit the feature.xml from com.eclipsesource.maildemo.tycho.feature, adding your dependencies.
  2. The build uses a static configuration.ini. As a result, you have to edit the configuration manually and add your own bundles. You will find the configuration.ini in the com.eclipsesource.maildemo.tycho.feature feature in the templates/WEB-INF/eclipse/configuration folder.
  3. Create a pom.xml for every bundle you created with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>maildemo</artifactId>
        <groupId>com.eclipsesource</groupId>
        <version>0.0.1-SNAPSHOT</version>
      </parent>
      <groupId>com.eclipsesource</groupId>
      <artifactId>com.eclipsesource.maildemo.tycho</artifactId>
      <version>1.0.0-SNAPSHOT</version>
      <packaging>eclipse-plugin</packaging>
    </project>
  4. Change the artifactId from com.eclipsesource.maildemo.tycho to your own Id.  You’ll also need to change the parentId when you use your own Id.
  5. Edit the pom.xml in the parent folder and add your modules. To add modules you just need to add the folder names from the different bundles to the file.
  6. In the pom.xml of the feature, change the naming of the “maildemo” to create a .war file with the name of your choice.
  7. Of course you can use your own groupIds and artifactIds. But, you have to reference the parent pom.xml artifactId in every bundle’s pom.xml

I hope these steps and the example build will help you to create your own Tycho based builds for RAP applications. Maybe you have some experiences or ideas you’d like to share?  Please feel free to post comments.

[1] https://github.com/hstaudacher/org.eclipse.rap.build.examples

on Sep 22nd, 2009The Future of Eclipse PDE builds

Eclipse has earned a reputation of being one of the best IDEs in existence. While it has become a lot more than that in many ways, its roots and its focus have always been the user facing aspects. That is probably the reasons why certain other aspects like the PDE build have been a bit neglected for quite a while. Between the ugly map files, the dependence on a target platform and its disability to run JUnit 4 tests it feels like there is quite some room for improvement.
I appreciate all the effort that went into the current state of the PDE Build, and there is quite a lot that it offers: Checking of OSGI access rules, validation of extension and extensions points, multi-platform builds, generation of p2 metadata for update sites among other things. I want to take a look at some of the recent and ongoing developments that build upon that legacy.

b3

The b3 project is currently in incubation at eclipse.org. Its goal is basically to be to the PDE build what p2 was to the update manager: A revised, more powerful version of one of the main components of the Eclipse Platform. But while p2 was more or less a complete rewrite, the key with b3 idea is to build upon the exisiting technologies like the PDE build core, Buckminster, EMF and P2. Important key aspects are extensibility and customizability. as well as interoperability with other build tools such as ant and maven.

It is refreshing to see the build process getting more attention as of late, and that the Eclipse community itself is stepping up to the task of making sure that Eclipse based applications are built in a simple, repeatable and reproducible manner.

Tycho

While Eclipse is certainly one of the defacto industry standards, another one is maven. Just as Eclipse is more than an IDE, maven is more than a build tool. The Tycho project is the maven implementation for building Eclipse plugins. While there are currently maven plugins out there capable of building “plain” OSGi bundles, Eclipse plugins are quite a lot more involved. Since both the maven pom.xml and the OSGi manifest include dependency information, there is a bit of redundancy here. The idea is here to have one of these be the “master” version, and then synthesize the other one from that. This means that projects can either be “pom-first” or “manifest-first” depending on the sepcific requirements and project setup.

There a certainly some roadblocks in the way. For example, both OSGi and maven have a concept of versions that is important for resolving dependencies. And while their format is superficially the same, their notion of version ordering is subtly but definitely incompatible. This can lead to all kinds of havoc.

Hopefully issues like these will be resolved sooner rather than later. Eclipse is not an island. Many applications based on Eclipse RCP are actual rich clients, which means they are connected to a server. These server components are usually more traditional “read: non-OSGI” Java applications, and thus tend to be built by a maven setup. In cases like these it would be desirable to have client and server share the same build infrastructure. This would be a huge boon to many real-life projects out there.

Better builds

Both these projects show an encouraging amount of progress, and I am convinced that these efforts will go a long way in making the Eclipse and the Java Platform an even better combination. While I think friendly competition is a good thing, competitive cooperation can be even better. Maybe these two projects have slightly different goals and will fill slightly different niches in the future. But I believe there is a lot of common ground, and I hope there is some healthy cross-pollination between these two projects, if not more. Both teams have a quite a background in their respective areas, and thus could bring a lot to the table.

I for one am looking forward to see these two project bear fruit, making the Eclipse build process a lot less painful and a lot more powerful.

on Sep 17th, 2009Maven in Eclipse

In the past I have said some unkind words about about maven’s pom.xml format. My aversion to xml heavy configuration has drawn me to more lightweight approaches to build systems, like gradle for example. At the same I was intrigued: If a tool like maven is seeing such a widespread use despite its cumbersome format, there must something to make up for it. My curiosity finally got the better of me and I decided to give it a shot. I figured there might be some tooling available to help ease the pain.

And lo and behold, there’s not one but two eclipse projects for integrating maven. One is the IAM project (formerly known as Q4E) and the second is m2eclipse. In that regard it’s a bit like subversive/subclipse but hopefully without all that licensing nonsense. But it is usually  good to have some choice – and competition of course. To get a clearer picture I decided to give both plugins a try.

IAM

I started with IAM. Setting up my sample project was a snap, and the maven integration immediately started downloading dependencies and adding them to the project classpath. Maven repositories can also hold source jars, making development and debugging much easier. The pom editor seems to cover all options and is looking quite solid. I was more interested in the core feature set, so I didn’t check out any advanced options.

m2eclipse

Next up I tested m2eclipse, which offers basically the same core feature set. Dependencies are automatically downloaded and added to the project classpath. The pom editor covered the same functionality as IAM’s, but I personally liked the the looks and layout better in m2eclipse. One really nice feature is code completion for dependencies.

maven Maven in Eclipse

Code completion - rocks!

I know I am spoiled eclipse developer, and I expect my IDE to finish my thoughts for me. But it gets even better: There is also a quickfix (Ctrl+1) for unresolved imports. Talk about convenience!

maven2 Maven in Eclipse

Quickfix to the rescue!

It’s good to see that there at least two very viable options when it comes to developing maven  projects in eclipse. Kudos to both the IAM and the m2eclipse team for the fantastic work.

The Price of Modularity

To me, one of the greatest strengths of the Java Platform has been its rich ecosystem. There are so many java libraries and frameworks out there, that when developing for the Java platform you almost never have to start from scratch. Most of the time it’s finding the right libraries, writing a little adapter code and the core business logic. No need for reinventing wheels. This truly is modular and reusable software development, and one of the main reasons why the Java platform is so competitive.

But this modularity does come at a price known as dependency hell. Any non-trivial project has a dozens of dependencies. Even your basic run-of-the mill webapp requires a web framework, logging, OR mapper, JDBC drivers, etc. Add in all the indirect dependencies and you are looking at quite a lot of libraries. This is why strong dependency management is such a compelling argument for build systems like maven.

But there is another issue apart from painfully assembled builds: Jumpstarting new developers. Especially for open source projects it is quite a turnoff for a potential contributor to look at the long list of requirements and dependencies needed to get to the point where the code even compiles cleanly. This is where strong dependency management comes to the rescue. Sure, maven may download two and a half internets on the first compile, but when its done you have everything ready to start working.

“apt-get for Java”

Due to popularity and pervasiveness of maven, there are plugins for integrating almost all imaginable build tools. For most of projects maven provides everything needed right out of the box: unni testing, coverage, javadoc, pmd, you name it. Combined with hudson this makes it ridiculously easy to get a continuous integration server running literally within minutes.

It is good to see that automatic dependency management is making such inroads in different areas of computing. Apt-get and maven, and even p2 have helped a lot to make the dependency hell a little more bearable.

on Oct 28th, 2008Tip: PDE Build and Binary Cycles

I recently spent some time with a client removing some cycles in bundles and discussing why cycles are evil in the first place. The problem is that even if you remove cycles from your own code, the code you depend on may not be cycle-free. This could be for many reasons, most of the time it’s due to legacy. So after some bundle cleansing, we setup an automated build… and had this dreaded error message come up in the logs:

“A cycle was detected when generating the classpath…”

I was sure this time that the fault didn’t lie with my client’s code, but someone else. I was right… the messy world of third-party dependencies can bring in some interesting baggage. This error was caused by a few third-party libraries that participated in a cycle, which is OK during runtime, even though poor architecture in my opinion. So how do you get around this? In the past, it was difficult in the Eclipse-world, but since 3.4, PDE Build was enhanced to allow binary cycles (cycles in the target you’re building against). To enable support for this, you simply have to specify the ‘allowBinaryCycles=true‘ in your top level build configuration properties, similar to where you specify properties like baseLocation. As of 3.5M3, PDE UI will automatically enable binary cycles support and this option can be toggled via the UI:

pdecycles 258x300 Tip: PDE Build and Binary Cycles

Hope this helps! Happy building and avoid cycles when you can!

© EclipseSource 2008 - 2011