Netbeans+platform+maven

203
Efficient development of large NetBeans Platform applications with Maven Fabrizio Giudici, Senior Java Architect Tidalwave s.a.s - [email protected] Friday, September 24, 2010

Transcript of Netbeans+platform+maven

Page 1: Netbeans+platform+maven

Efficient developmentof large NetBeans Platform

applications with Maven

Fabrizio Giudici, Senior Java ArchitectTidalwave s.a.s - [email protected]

Friday, September 24, 2010

Page 2: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Agenda

2

Friday, September 24, 2010

Page 3: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Agenda

• Introducing the NetBeans Platform

2

Friday, September 24, 2010

Page 4: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Agenda

• Introducing the NetBeans Platform

• The NetBeans Platform Ant Build Harness

2

Friday, September 24, 2010

Page 5: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Agenda

• Introducing the NetBeans Platform

• The NetBeans Platform Ant Build Harness

• Limitations of the NetBeans Platform Ant Build Harness

2

Friday, September 24, 2010

Page 6: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Agenda

• Introducing the NetBeans Platform

• The NetBeans Platform Ant Build Harness

• Limitations of the NetBeans Platform Ant Build Harness

• Introducing Maven

2

Friday, September 24, 2010

Page 7: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Agenda

• Introducing the NetBeans Platform

• The NetBeans Platform Ant Build Harness

• Limitations of the NetBeans Platform Ant Build Harness

• Introducing Maven

• The NetBeans Platform Maven Plugin

2

Friday, September 24, 2010

Page 8: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Agenda

• Introducing the NetBeans Platform

• The NetBeans Platform Ant Build Harness

• Limitations of the NetBeans Platform Ant Build Harness

• Introducing Maven

• The NetBeans Platform Maven Plugin

• Optimizing NetBeans Platform Maven projects

2

Friday, September 24, 2010

Page 9: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Agenda

• Introducing the NetBeans Platform

• The NetBeans Platform Ant Build Harness

• Limitations of the NetBeans Platform Ant Build Harness

• Introducing Maven

• The NetBeans Platform Maven Plugin

• Optimizing NetBeans Platform Maven projects

• Reuse of third parties’ libraries (NBPWR project, optional)

2

Friday, September 24, 2010

Page 10: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Agenda

• Introducing the NetBeans Platform

• The NetBeans Platform Ant Build Harness

• Limitations of the NetBeans Platform Ant Build Harness

• Introducing Maven

• The NetBeans Platform Maven Plugin

• Optimizing NetBeans Platform Maven projects

• Reuse of third parties’ libraries (NBPWR project, optional)

• Conclusions

2

Friday, September 24, 2010

Page 11: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

About the speaker

3

Friday, September 24, 2010

Page 12: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

About the speaker

• Senior Software Architect, Mentor, Technical Writer

• Fourteen years of Java Experience (JSE, JEE, JME, etc...)

• Sun Consultant since 1998, Oracle consultant since 2010

• Author of a number of open source projects

• Speaker at JavaOne, Devoxx, Jazoon, JAX Italia and other events

• Member of the NetBeans Dream Team

• Co-leader of JUG Milano

• Java.Net blogger at http://www.java.net/blogs/fabriziogiudici

3

Friday, September 24, 2010

Page 13: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Ant vs Maven?

4

Friday, September 24, 2010

Page 14: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Ant vs Maven?

• What this presentation is not:

4

Friday, September 24, 2010

Page 15: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Ant vs Maven?

• What this presentation is not:

• A “X is better than Y” sermon

4

Friday, September 24, 2010

Page 16: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Ant vs Maven?

• What this presentation is not:

• A “X is better than Y” sermon

• What this presentation is:

4

Friday, September 24, 2010

Page 17: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Ant vs Maven?

• What this presentation is not:

• A “X is better than Y” sermon

• What this presentation is:

• An analysis of scenarios where Maven may serve better than Ant

• An analysis of Maven-based NetBeans Platform projects

4

Friday, September 24, 2010

Page 18: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Ant vs Maven?

• What this presentation is not:

• A “X is better than Y” sermon

• What this presentation is:

• An analysis of scenarios where Maven may serve better than Ant

• An analysis of Maven-based NetBeans Platform projects

• Some basics about the NetBeans Platform and Maven assumed

4

Friday, September 24, 2010

Page 19: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Ant vs Maven?

• What this presentation is not:

• A “X is better than Y” sermon

• What this presentation is:

• An analysis of scenarios where Maven may serve better than Ant

• An analysis of Maven-based NetBeans Platform projects

• Some basics about the NetBeans Platform and Maven assumed

• Based on the speaker’s experience of four years with Ant & the Platform, then replaced by Maven

4

Friday, September 24, 2010

Page 20: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Related talks at JavaOne 2010

• S314388: Maven 3.x: The Evolution of Enterprise Java Build Infrastructures

• S314711: Building Software with Rich Client Platforms

• S313667: Swing OSGi Modular Desktop Application Framework

• S314266: The Cutting Edge of Desktop Software: The NetBeans Platform in Practice

• S314141: Patterns for Modularity

• S313338 Getting More Out of Your Hudson

5

Friday, September 24, 2010

Page 21: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NetBeans Platform

6

Friday, September 24, 2010

Page 22: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NetBeans Platform

• The best framework for Swing desktop applications

6

Friday, September 24, 2010

Page 23: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NetBeans Platform

• The best framework for Swing desktop applications

• Provides “plumbing” for many common tasks

6

Friday, September 24, 2010

Page 24: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NetBeans Platform

• The best framework for Swing desktop applications

• Provides “plumbing” for many common tasks

• Modular, plugin-oriented, scalable

6

Friday, September 24, 2010

Page 25: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NetBeans Platform

• The best framework for Swing desktop applications

• Provides “plumbing” for many common tasks

• Modular, plugin-oriented, scalable

• Since 6.9 provides integration with the OSGi framework

6

Friday, September 24, 2010

Page 26: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NetBeans Platform

• The best framework for Swing desktop applications

• Provides “plumbing” for many common tasks

• Modular, plugin-oriented, scalable

• Since 6.9 provides integration with the OSGi framework

• Used also as the foundation of the Oracle NetBeans IDE

6

Friday, September 24, 2010

Page 27: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NetBeans Platform

• The best framework for Swing desktop applications

• Provides “plumbing” for many common tasks

• Modular, plugin-oriented, scalable

• Since 6.9 provides integration with the OSGi framework

• Used also as the foundation of the Oracle NetBeans IDE

• Very popular in all the industrial segments

6

Friday, September 24, 2010

Page 28: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NetBeans Platform

• The best framework for Swing desktop applications

• Provides “plumbing” for many common tasks

• Modular, plugin-oriented, scalable

• Since 6.9 provides integration with the OSGi framework

• Used also as the foundation of the Oracle NetBeans IDE

• Very popular in all the industrial segments

6

... more success stories at http://netbeans.org/features/platform/showcase.html

Friday, September 24, 2010

Page 29: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

7

Friday, September 24, 2010

Page 30: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

• By default, the NetBeans Platform uses Ant

7

Friday, September 24, 2010

Page 31: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

• By default, the NetBeans Platform uses Ant

• for building itself (together with the IDE)

7

Friday, September 24, 2010

Page 32: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

• By default, the NetBeans Platform uses Ant

• for building itself (together with the IDE)

• for building Platform-based applications

7

Friday, September 24, 2010

Page 33: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

• By default, the NetBeans Platform uses Ant

• for building itself (together with the IDE)

• for building Platform-based applications

• NetBeans Platform Ant Build Harness

7

Friday, September 24, 2010

Page 34: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

• By default, the NetBeans Platform uses Ant

• for building itself (together with the IDE)

• for building Platform-based applications

• NetBeans Platform Ant Build Harness

• Set of standard Ant scripts, tasks and extensions

7

Friday, September 24, 2010

Page 35: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

• By default, the NetBeans Platform uses Ant

• for building itself (together with the IDE)

• for building Platform-based applications

• NetBeans Platform Ant Build Harness

• Set of standard Ant scripts, tasks and extensions

• Can be used from the IDE or by the command line

7

Friday, September 24, 2010

Page 36: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

• By default, the NetBeans Platform uses Ant

• for building itself (together with the IDE)

• for building Platform-based applications

• NetBeans Platform Ant Build Harness

• Set of standard Ant scripts, tasks and extensions

• Can be used from the IDE or by the command line

• A minimum preliminary setup is required

7

Friday, September 24, 2010

Page 37: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

• By default, the NetBeans Platform uses Ant

• for building itself (together with the IDE)

• for building Platform-based applications

• NetBeans Platform Ant Build Harness

• Set of standard Ant scripts, tasks and extensions

• Can be used from the IDE or by the command line

• A minimum preliminary setup is required

• Very good starting point for beginners

7

Friday, September 24, 2010

Page 38: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The Platform Ant Build Harness

• By default, the NetBeans Platform uses Ant

• for building itself (together with the IDE)

• for building Platform-based applications

• NetBeans Platform Ant Build Harness

• Set of standard Ant scripts, tasks and extensions

• Can be used from the IDE or by the command line

• A minimum preliminary setup is required

• Very good starting point for beginners

• Many people use it even for complex applications

7

Friday, September 24, 2010

Page 39: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Using the Ant Build Harness

8

Friday, September 24, 2010

Page 40: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Using the Ant Build Harness

• Two ways of using the harness

8

Friday, September 24, 2010

Page 41: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Using the Ant Build Harness

• Two ways of using the harness

• Supplied with the IDE and referred to by the project

8

Friday, September 24, 2010

Page 42: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Using the Ant Build Harness

• Two ways of using the harness

• Supplied with the IDE and referred to by the project

• Needs a local environment setup to “point” to the IDE installation folder

8

Friday, September 24, 2010

Page 43: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Using the Ant Build Harness

• Two ways of using the harness

• Supplied with the IDE and referred to by the project

• Needs a local environment setup to “point” to the IDE installation folder

• Embedded with the project

8

Friday, September 24, 2010

Page 44: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Using the Ant Build Harness

• Two ways of using the harness

• Supplied with the IDE and referred to by the project

• Needs a local environment setup to “point” to the IDE installation folder

• Embedded with the project

• Possible clashes if the used Platform version is different than the NetBeans IDE version

8

Friday, September 24, 2010

Page 45: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Using the Ant Build Harness

• Two ways of using the harness

• Supplied with the IDE and referred to by the project

• Needs a local environment setup to “point” to the IDE installation folder

• Embedded with the project

• Possible clashes if the used Platform version is different than the NetBeans IDE version

8

Friday, September 24, 2010

Page 46: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Using the Ant Build Harness

• Two ways of using the harness

• Supplied with the IDE and referred to by the project

• Needs a local environment setup to “point” to the IDE installation folder

• Embedded with the project

• Possible clashes if the used Platform version is different than the NetBeans IDE version

Key concept: the Ant build harness is a specific build system for the Platform projects

8

Friday, September 24, 2010

Page 47: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

9

Friday, September 24, 2010

Page 48: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

9

Friday, September 24, 2010

Page 49: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

• Good design practices lead to many small packages

9

Friday, September 24, 2010

Page 50: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

• Good design practices lead to many small packages

• With multiple projects with many inter-dependencies

9

Friday, September 24, 2010

Page 51: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

• Good design practices lead to many small packages

• With multiple projects with many inter-dependenciesIn other words: how to reuse modules?

9

Friday, September 24, 2010

Page 52: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

• Good design practices lead to many small packages

• With multiple projects with many inter-dependencies

• Might be a single project that’s worth while splittingIn other words: how to reuse modules?

9

Friday, September 24, 2010

Page 53: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

• Good design practices lead to many small packages

• With multiple projects with many inter-dependencies

• Might be a single project that’s worth while splitting

• What’s a module of the NetBeans Platform, BTW?

In other words: how to reuse modules?

9

Friday, September 24, 2010

Page 54: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

• Good design practices lead to many small packages

• With multiple projects with many inter-dependencies

• Might be a single project that’s worth while splitting

• What’s a module of the NetBeans Platform, BTW?

• A collection of cohese packages exposing an API

In other words: how to reuse modules?

9

Friday, September 24, 2010

Page 55: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

• Good design practices lead to many small packages

• With multiple projects with many inter-dependencies

• Might be a single project that’s worth while splitting

• What’s a module of the NetBeans Platform, BTW?

• A collection of cohese packages exposing an API

• Packed in .nbm files (.jar + metadata)

In other words: how to reuse modules?

9

Friday, September 24, 2010

Page 56: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

• Good design practices lead to many small packages

• With multiple projects with many inter-dependencies

• Might be a single project that’s worth while splitting

• What’s a module of the NetBeans Platform, BTW?

• A collection of cohese packages exposing an API

• Packed in .nbm files (.jar + metadata)

In other words: how to reuse modules?

9

blueMarineMetadata

blueMarineSemantic

blueMarineMedia

blueMarinePDF

blueMarineCore

blueMarineCatalog

blueMarineGallery

blueMarineLightTable

blueMarine

blueMarineGeo

OpenBlueSky

forceTen

blueOcean blueBill ServerblueBill for Android

Only a subset of dependencies shown

Friday, September 24, 2010

Page 57: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

When Ant might not scale

• With a large number of modules

• Good design practices lead to many small packages

• With multiple projects with many inter-dependencies

• Might be a single project that’s worth while splitting

• What’s a module of the NetBeans Platform, BTW?

• A collection of cohese packages exposing an API

• Packed in .nbm files (.jar + metadata)

In other words: how to reuse modules?

9

Friday, September 24, 2010

Page 58: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Pushing the Ant Build: Suite Chaining

Slide in a graph showing a dependency graph: Suite --> Platform

10

Friday, September 24, 2010

Page 59: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Pushing the Ant Build: Suite Chaining

• Platform: a self-contained set of .nbm modules

Slide in a graph showing a dependency graph: Suite --> Platform

10

Friday, September 24, 2010

Page 60: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Pushing the Ant Build: Suite Chaining

• Platform: a self-contained set of .nbm modules

• The NetBeans Platform is obviously one example of a platform

Slide in a graph showing a dependency graph: Suite --> Platform

10

Friday, September 24, 2010

Page 61: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Pushing the Ant Build: Suite Chaining

• Platform: a self-contained set of .nbm modules

• The NetBeans Platform is obviously one example of a platform

• Module Suite: a set of .nbm modules depending on a Platform

Slide in a graph showing a dependency graph: Suite --> Platform

10

Friday, September 24, 2010

Page 62: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Pushing the Ant Build: Suite Chaining

• Platform: a self-contained set of .nbm modules

• The NetBeans Platform is obviously one example of a platform

• Module Suite: a set of .nbm modules depending on a Platform

• Any NetBeans Platform-based project is a suite

Slide in a graph showing a dependency graph: Suite --> Platform

10

Friday, September 24, 2010

Page 63: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Pushing the Ant Build: Suite Chaining

• Platform: a self-contained set of .nbm modules

• The NetBeans Platform is obviously one example of a platform

• Module Suite: a set of .nbm modules depending on a Platform

• Any NetBeans Platform-based project is a suite

• It is possible to have a Suite depending on a Platform + another Suite (“Suite Chaining”) Slide in a graph showing a

dependency graph: Suite --> Platform

10

Friday, September 24, 2010

Page 64: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Pushing the Ant Build: Suite Chaining

• Platform: a self-contained set of .nbm modules

• The NetBeans Platform is obviously one example of a platform

• Module Suite: a set of .nbm modules depending on a Platform

• Any NetBeans Platform-based project is a suite

• It is possible to have a Suite depending on a Platform + another Suite (“Suite Chaining”)

• Doable, but cumbersome

Slide in a graph showing a dependency graph: Suite --> Platform

10

Friday, September 24, 2010

Page 65: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Pushing the Ant Build: Suite Chaining

• Platform: a self-contained set of .nbm modules

• The NetBeans Platform is obviously one example of a platform

• Module Suite: a set of .nbm modules depending on a Platform

• Any NetBeans Platform-based project is a suite

• It is possible to have a Suite depending on a Platform + another Suite (“Suite Chaining”)

• Doable, but cumbersome

• Doesn’t scale well with multiple suite levels

Slide in a graph showing a dependency graph: Suite --> Platform

10

Friday, September 24, 2010

Page 66: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

11

Friday, September 24, 2010

Page 67: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

• It’s possible to create a custom platform, assembling arbitrary .nbm modules

11

Friday, September 24, 2010

Page 68: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

• It’s possible to create a custom platform, assembling arbitrary .nbm modules

• Of course, dependencies must be satisfied

11

Friday, September 24, 2010

Page 69: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

• It’s possible to create a custom platform, assembling arbitrary .nbm modules

• Of course, dependencies must be satisfied

• You can assemble a Platform feeding the .nbm artifacts from a project to another project

11

Friday, September 24, 2010

Page 70: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

• It’s possible to create a custom platform, assembling arbitrary .nbm modules

• Of course, dependencies must be satisfied

• You can assemble a Platform feeding the .nbm artifacts from a project to another project

• This approach (apparently) scales well beyond the first level

11

Friday, September 24, 2010

Page 71: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

• It’s possible to create a custom platform, assembling arbitrary .nbm modules

• Of course, dependencies must be satisfied

• You can assemble a Platform feeding the .nbm artifacts from a project to another project

• This approach (apparently) scales well beyond the first level

• http://weblogs.java.net/blog/2007/11/03/netbeans-rcp-beyond-suite-chaining

11

Friday, September 24, 2010

Page 72: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

• It’s possible to create a custom platform, assembling arbitrary .nbm modules

• Of course, dependencies must be satisfied

• You can assemble a Platform feeding the .nbm artifacts from a project to another project

• This approach (apparently) scales well beyond the first level

• http://weblogs.java.net/blog/2007/11/03/netbeans-rcp-beyond-suite-chaining

• NetBeans 6.7 introduced support for reusing modules

11

Friday, September 24, 2010

Page 73: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

• It’s possible to create a custom platform, assembling arbitrary .nbm modules

• Of course, dependencies must be satisfied

• You can assemble a Platform feeding the .nbm artifacts from a project to another project

• This approach (apparently) scales well beyond the first level

• http://weblogs.java.net/blog/2007/11/03/netbeans-rcp-beyond-suite-chaining

• NetBeans 6.7 introduced support for reusing modules

• http://wiki.netbeans.org/DevFaqHowToReuseModules

11

Friday, September 24, 2010

Page 74: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

• It’s possible to create a custom platform, assembling arbitrary .nbm modules

• Of course, dependencies must be satisfied

• You can assemble a Platform feeding the .nbm artifacts from a project to another project

• This approach (apparently) scales well beyond the first level

• http://weblogs.java.net/blog/2007/11/03/netbeans-rcp-beyond-suite-chaining

• NetBeans 6.7 introduced support for reusing modules

• http://wiki.netbeans.org/DevFaqHowToReuseModules

11

Friday, September 24, 2010

Page 75: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reusing modules with the Ant build harness

• It’s possible to create a custom platform, assembling arbitrary .nbm modules

• Of course, dependencies must be satisfied

• You can assemble a Platform feeding the .nbm artifacts from a project to another project

• This approach (apparently) scales well beyond the first level

• http://weblogs.java.net/blog/2007/11/03/netbeans-rcp-beyond-suite-chaining

• NetBeans 6.7 introduced support for reusing modules

• http://wiki.netbeans.org/DevFaqHowToReuseModules

11

Friday, September 24, 2010

Page 76: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Limits of Custom Platforms with Ant

12

Friday, September 24, 2010

Page 77: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Limits of Custom Platforms with Ant

• Conceptually simple, the cumbersome part is automating the “feed” of NBM artifacts from a project to another

12

Friday, September 24, 2010

Page 78: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Limits of Custom Platforms with Ant

• Conceptually simple, the cumbersome part is automating the “feed” of NBM artifacts from a project to another

• Personal experience

12

Friday, September 24, 2010

Page 79: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Limits of Custom Platforms with Ant

• Conceptually simple, the cumbersome part is automating the “feed” of NBM artifacts from a project to another

• Personal experience

• Wrote a couple of custom Ant tasks to enhance the original harness with artifact management facilities

12

Friday, September 24, 2010

Page 80: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Limits of Custom Platforms with Ant

• Conceptually simple, the cumbersome part is automating the “feed” of NBM artifacts from a project to another

• Personal experience

• Wrote a couple of custom Ant tasks to enhance the original harness with artifact management facilities

• Reached some high complexity when trying to share javadocs and sources too

12

Friday, September 24, 2010

Page 81: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Limits of Custom Platforms with Ant

• Conceptually simple, the cumbersome part is automating the “feed” of NBM artifacts from a project to another

• Personal experience

• Wrote a couple of custom Ant tasks to enhance the original harness with artifact management facilities

• Reached some high complexity when trying to share javadocs and sources too

• Sources in particular are important, e.g. for profiling etc...

12

Friday, September 24, 2010

Page 82: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Limits of Custom Platforms with Ant

• Conceptually simple, the cumbersome part is automating the “feed” of NBM artifacts from a project to another

• Personal experience

• Wrote a couple of custom Ant tasks to enhance the original harness with artifact management facilities

• Reached some high complexity when trying to share javadocs and sources too

• Sources in particular are important, e.g. for profiling etc...

• At this point I moved to Maven...

12

Friday, September 24, 2010

Page 83: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Limits of Custom Platforms with Ant

• Conceptually simple, the cumbersome part is automating the “feed” of NBM artifacts from a project to another

• Personal experience

• Wrote a couple of custom Ant tasks to enhance the original harness with artifact management facilities

• Reached some high complexity when trying to share javadocs and sources too

• Sources in particular are important, e.g. for profiling etc...

• At this point I moved to Maven...

• I’m recommending to customers - of course your mileage may vary

12

Friday, September 24, 2010

Page 84: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

13

Friday, September 24, 2010

Page 85: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

13

Friday, September 24, 2010

Page 86: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

• Standard lifecycle (= sequence of phases) applied to projects

13

Friday, September 24, 2010

Page 87: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

• Standard lifecycle (= sequence of phases) applied to projects

• Projects are described by a POM (Project Object Model)

13

Friday, September 24, 2010

Page 88: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

• Standard lifecycle (= sequence of phases) applied to projects

• Projects are described by a POM (Project Object Model)

• Composed of plugins attaching goals to phases

13

Friday, September 24, 2010

Page 89: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

• Standard lifecycle (= sequence of phases) applied to projects

• Projects are described by a POM (Project Object Model)

• Composed of plugins attaching goals to phases

• Provides efficient artifact management with repositories

13

Friday, September 24, 2010

Page 90: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

• Standard lifecycle (= sequence of phases) applied to projects

• Projects are described by a POM (Project Object Model)

• Composed of plugins attaching goals to phases

• Provides efficient artifact management with repositories

• more info later

13

Friday, September 24, 2010

Page 91: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

• Standard lifecycle (= sequence of phases) applied to projects

• Projects are described by a POM (Project Object Model)

• Composed of plugins attaching goals to phases

• Provides efficient artifact management with repositories

• more info later

Ant: interpreter to create build scripts

13

Friday, September 24, 2010

Page 92: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

• Standard lifecycle (= sequence of phases) applied to projects

• Projects are described by a POM (Project Object Model)

• Composed of plugins attaching goals to phases

• Provides efficient artifact management with repositories

• more info later

Ant: interpreter to create build scripts

Maven: standard, well defined build system that can be customized

13

Friday, September 24, 2010

Page 93: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

• Standard lifecycle (= sequence of phases) applied to projects

• Projects are described by a POM (Project Object Model)

• Composed of plugins attaching goals to phases

• Provides efficient artifact management with repositories

• more info later

Ant: interpreter to create build scripts

Maven: standard, well defined build system that can be customized

Programmatic13

Friday, September 24, 2010

Page 94: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Introducing Maven

• A different building tool than Ant

• Standard lifecycle (= sequence of phases) applied to projects

• Projects are described by a POM (Project Object Model)

• Composed of plugins attaching goals to phases

• Provides efficient artifact management with repositories

• more info later

Ant: interpreter to create build scripts

Maven: standard, well defined build system that can be customized

Programmatic Declarative13

Friday, September 24, 2010

Page 95: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Inheritance and composition

14

Friday, September 24, 2010

Page 96: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Inheritance and composition

• “Object model” means it implies some typical OO practices

14

Friday, September 24, 2010

Page 97: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Inheritance and composition

• “Object model” means it implies some typical OO practices

• Inheritance

14

Friday, September 24, 2010

Page 98: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Inheritance and composition

• “Object model” means it implies some typical OO practices

• Inheritance

• A module POM can inherit from a parent POM

14

Friday, September 24, 2010

Page 99: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Inheritance and composition

• “Object model” means it implies some typical OO practices

• Inheritance

• A module POM can inherit from a parent POM

• Composition

14

Friday, September 24, 2010

Page 100: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Inheritance and composition

• “Object model” means it implies some typical OO practices

• Inheritance

• A module POM can inherit from a parent POM

• Composition

• A module POM can import parts of other modules POM

14

Friday, September 24, 2010

Page 101: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Inheritance and composition

• “Object model” means it implies some typical OO practices

• Inheritance

• A module POM can inherit from a parent POM

• Composition

• A module POM can import parts of other modules POM

• Both practices reduces entropy (DRY)

14

Friday, September 24, 2010

Page 102: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Inheritance and composition

• “Object model” means it implies some typical OO practices

• Inheritance

• A module POM can inherit from a parent POM

• Composition

• A module POM can import parts of other modules POM

• Both practices reduces entropy (DRY)

• Still verbose because of XML (but it’s syntax, not semantics)

14

Friday, September 24, 2010

Page 103: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Inheritance and composition

• “Object model” means it implies some typical OO practices

• Inheritance

• A module POM can inherit from a parent POM

• Composition

• A module POM can import parts of other modules POM

• Both practices reduces entropy (DRY)

• Still verbose because of XML (but it’s syntax, not semantics)

• Maven 3 allows for more compact syntaxes (e.g. Groovy)

14

Friday, September 24, 2010

Page 104: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Artifacts, dependencies, repositories

15

Friday, September 24, 2010

Page 105: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Artifacts, dependencies, repositories

• Each module

15

Friday, September 24, 2010

Page 106: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Artifacts, dependencies, repositories

• Each module

• Possibly depends on other modules artifacts

15

Friday, September 24, 2010

Page 107: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Artifacts, dependencies, repositories

• Each module

• Possibly depends on other modules artifacts

• Produces a single artifact (which might consist in multiple files)

15

Friday, September 24, 2010

Page 108: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Artifacts, dependencies, repositories

• Each module

• Possibly depends on other modules artifacts

• Produces a single artifact (which might consist in multiple files)

• Each artifact

15

Friday, September 24, 2010

Page 109: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Artifacts, dependencies, repositories

• Each module

• Possibly depends on other modules artifacts

• Produces a single artifact (which might consist in multiple files)

• Each artifact

• Has got unique coordinates: groupId, artifactId, version, packaging, classifier

15

Friday, September 24, 2010

Page 110: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Artifacts, dependencies, repositories

• Each module

• Possibly depends on other modules artifacts

• Produces a single artifact (which might consist in multiple files)

• Each artifact

• Has got unique coordinates: groupId, artifactId, version, packaging, classifier

• Can be retrieved from a local / remote repository

15

Friday, September 24, 2010

Page 111: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Artifacts, dependencies, repositories

• Each module

• Possibly depends on other modules artifacts

• Produces a single artifact (which might consist in multiple files)

• Each artifact

• Has got unique coordinates: groupId, artifactId, version, packaging, classifier

• Can be retrieved from a local / remote repository

• Can be published to a local / remote repository

15

Friday, September 24, 2010

Page 112: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBM Maven Plugin

16

Friday, September 24, 2010

Page 113: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBM Maven Plugin

• A specific Maven plugin for the NetBeans Platform

16

Friday, September 24, 2010

Page 114: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBM Maven Plugin

• A specific Maven plugin for the NetBeans Platform

• Defines the ‘nbm’ packaging

16

Friday, September 24, 2010

Page 115: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBM Maven Plugin

• A specific Maven plugin for the NetBeans Platform

• Defines the ‘nbm’ packaging

• Creates nbm artifacts

16

Friday, September 24, 2010

Page 116: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBM Maven Plugin

• A specific Maven plugin for the NetBeans Platform

• Defines the ‘nbm’ packaging

• Creates nbm artifacts

• Manages branding

16

Friday, September 24, 2010

Page 117: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBM Maven Plugin

• A specific Maven plugin for the NetBeans Platform

• Defines the ‘nbm’ packaging

• Creates nbm artifacts

• Manages branding

• Creates .zip and JNLP distributions

16

Friday, September 24, 2010

Page 118: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBM Maven Plugin

• A specific Maven plugin for the NetBeans Platform

• Defines the ‘nbm’ packaging

• Creates nbm artifacts

• Manages branding

• Creates .zip and JNLP distributions

• Properly runs the project being developed

16

Friday, September 24, 2010

Page 119: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBM Maven Plugin

• A specific Maven plugin for the NetBeans Platform

• Defines the ‘nbm’ packaging

• Creates nbm artifacts

• Manages branding

• Creates .zip and JNLP distributions

• Properly runs the project being developed

• Out-of-the-box support by the IDE, better integration with 6.9

16

Friday, September 24, 2010

Page 120: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Further benefitsIf you have time, demonstrate e.g. FindBugs integration. In any case, connect to the Tidalwave Hudson instance and show some stuff

17

Friday, September 24, 2010

Page 121: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Further benefits

• Your project becomes just a standard Maven project

If you have time, demonstrate e.g. FindBugs integration. In any case, connect to the Tidalwave Hudson instance and show some stuff

17

Friday, September 24, 2010

Page 122: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Further benefits

• Your project becomes just a standard Maven project

If you have time, demonstrate e.g. FindBugs integration. In any case, connect to the Tidalwave Hudson instance and show some stuff

No more NetBeans specific “build harness”

17

Friday, September 24, 2010

Page 123: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Further benefits

• Your project becomes just a standard Maven project

• No special build instructions: mvn clean install

If you have time, demonstrate e.g. FindBugs integration. In any case, connect to the Tidalwave Hudson instance and show some stuff

No more NetBeans specific “build harness”

17

Friday, September 24, 2010

Page 124: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Further benefits

• Your project becomes just a standard Maven project

• No special build instructions: mvn clean install

• IDE - neutral (IDEA, Eclipse)

If you have time, demonstrate e.g. FindBugs integration. In any case, connect to the Tidalwave Hudson instance and show some stuff

No more NetBeans specific “build harness”

17

Friday, September 24, 2010

Page 125: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Further benefits

• Your project becomes just a standard Maven project

• No special build instructions: mvn clean install

• IDE - neutral (IDEA, Eclipse)

• Immediately available for CI without any specific setup

If you have time, demonstrate e.g. FindBugs integration. In any case, connect to the Tidalwave Hudson instance and show some stuff

No more NetBeans specific “build harness”

17

Friday, September 24, 2010

Page 126: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Further benefits

• Your project becomes just a standard Maven project

• No special build instructions: mvn clean install

• IDE - neutral (IDEA, Eclipse)

• Immediately available for CI without any specific setup

• Easy to augment with QA plugins (e.g. Cobertura, FindBugs)

If you have time, demonstrate e.g. FindBugs integration. In any case, connect to the Tidalwave Hudson instance and show some stuff

No more NetBeans specific “build harness”

17

Friday, September 24, 2010

Page 127: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Further benefits

• Your project becomes just a standard Maven project

• No special build instructions: mvn clean install

• IDE - neutral (IDEA, Eclipse)

• Immediately available for CI without any specific setup

• Easy to augment with QA plugins (e.g. Cobertura, FindBugs)

• Just configure the plugin in the Master POM

If you have time, demonstrate e.g. FindBugs integration. In any case, connect to the Tidalwave Hudson instance and show some stuff

No more NetBeans specific “build harness”

17

Friday, September 24, 2010

Page 128: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Further benefits

• Your project becomes just a standard Maven project

• No special build instructions: mvn clean install

• IDE - neutral (IDEA, Eclipse)

• Immediately available for CI without any specific setup

• Easy to augment with QA plugins (e.g. Cobertura, FindBugs)

• Just configure the plugin in the Master POM

• Run it (e.g. mvn findbugs:findbugs)

If you have time, demonstrate e.g. FindBugs integration. In any case, connect to the Tidalwave Hudson instance and show some stuff

No more NetBeans specific “build harness”

17

Friday, September 24, 2010

Page 129: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Project structure

18

Friday, September 24, 2010

Page 130: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Project structure

• Modules

• Master POM

• Application module

• What and how to assemble as final app

• Branding module

• e.g. i18n resources, customization of existing platform resources

• One or more .nbm modules

18

Master POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

*

1

1

Friday, September 24, 2010

Page 131: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Demo

19

Friday, September 24, 2010

Page 132: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Demo

• Show forceTen Example 1

19

Friday, September 24, 2010

Page 133: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Dependency caveat!

20

Friday, September 24, 2010

Page 134: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Dependency caveat!

• Maven dependencies are transitive

20

Friday, September 24, 2010

Page 135: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Dependency caveat!

• Maven dependencies are transitive

• NetBeans Platform dependencies are not transitive

20

Friday, September 24, 2010

Page 136: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Dependency caveat!

• Maven dependencies are transitive

• NetBeans Platform dependencies are not transitive

• The Maven plugin:

20

Friday, September 24, 2010

Page 137: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Dependency caveat!

• Maven dependencies are transitive

• NetBeans Platform dependencies are not transitive

• The Maven plugin:

• automatically translates direct Maven dependencies on NBM modules to Platform dependencies

20

Friday, September 24, 2010

Page 138: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Dependency caveat!

• Maven dependencies are transitive

• NetBeans Platform dependencies are not transitive

• The Maven plugin:

• automatically translates direct Maven dependencies on NBM modules to Platform dependencies

• performs a consistency check about missing transitive dependencies and dependencies on non-public classes

20

Friday, September 24, 2010

Page 139: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Dependency caveat!

• Maven dependencies are transitive

• NetBeans Platform dependencies are not transitive

• The Maven plugin:

• automatically translates direct Maven dependencies on NBM modules to Platform dependencies

• performs a consistency check about missing transitive dependencies and dependencies on non-public classes

• OSGi bundles allowed as dependencies since IDE 6.9 + NBM plugin 3.2

20

Friday, September 24, 2010

Page 140: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Dependency caveat!

• Maven dependencies are transitive

• NetBeans Platform dependencies are not transitive

• The Maven plugin:

• automatically translates direct Maven dependencies on NBM modules to Platform dependencies

• performs a consistency check about missing transitive dependencies and dependencies on non-public classes

• OSGi bundles allowed as dependencies since IDE 6.9 + NBM plugin 3.2

• Old versions of the plugin behaved in a different way

20

Friday, September 24, 2010

Page 141: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Dependency caveat!

• Maven dependencies are transitive

• NetBeans Platform dependencies are not transitive

• The Maven plugin:

• automatically translates direct Maven dependencies on NBM modules to Platform dependencies

• performs a consistency check about missing transitive dependencies and dependencies on non-public classes

• OSGi bundles allowed as dependencies since IDE 6.9 + NBM plugin 3.2

• Old versions of the plugin behaved in a different way

• Not mentioning some deprecated practices still available in 3.x

20

Friday, September 24, 2010

Page 142: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reuse of NBM modules in non-platform projects

21

Friday, September 24, 2010

Page 143: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reuse of NBM modules in non-platform projects

• The NBM Maven plugin produces both a .nbm and a .jar artifacts (different packagings)

21

Friday, September 24, 2010

Page 144: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reuse of NBM modules in non-platform projects

• The NBM Maven plugin produces both a .nbm and a .jar artifacts (different packagings)

• This means that a non-platform project can reuse a NBM module

21

Friday, September 24, 2010

Page 145: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reuse of NBM modules in non-platform projects

• The NBM Maven plugin produces both a .nbm and a .jar artifacts (different packagings)

• This means that a non-platform project can reuse a NBM module

• E.g. Java SE, Android, etc...

21

Friday, September 24, 2010

Page 146: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reuse of NBM modules in non-platform projects

• The NBM Maven plugin produces both a .nbm and a .jar artifacts (different packagings)

• This means that a non-platform project can reuse a NBM module

• E.g. Java SE, Android, etc...

• Just declare a dependency as usual

21

Friday, September 24, 2010

Page 147: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reuse of NBM modules in non-platform projects

• The NBM Maven plugin produces both a .nbm and a .jar artifacts (different packagings)

• This means that a non-platform project can reuse a NBM module

• E.g. Java SE, Android, etc...

• Just declare a dependency as usual

• Projects whose packaging is nbm automatically depend on nbm artifacts

21

Friday, September 24, 2010

Page 148: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Reuse of NBM modules in non-platform projects

• The NBM Maven plugin produces both a .nbm and a .jar artifacts (different packagings)

• This means that a non-platform project can reuse a NBM module

• E.g. Java SE, Android, etc...

• Just declare a dependency as usual

• Projects whose packaging is nbm automatically depend on nbm artifacts

• Projects whose packaging is jar automatically depend on jar artifacts

21

Friday, September 24, 2010

Page 149: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Demo

• Show forceTen Example 2

22

Friday, September 24, 2010

Page 150: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Module versioning strategies

23

Friday, September 24, 2010

Page 151: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Module versioning strategies

• Every module artifact shares the same version of the project

23

Friday, September 24, 2010

Page 152: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Module versioning strategies

• Every module artifact shares the same version of the project

• Simpler to manage

23

Friday, September 24, 2010

Page 153: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Module versioning strategies

• Every module artifact shares the same version of the project

• Simpler to manage

• Used by NetBeans for publishing Maven artifacts (e.g. NETBEANS691)

23

Friday, September 24, 2010

Page 154: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Module versioning strategies

• Every module artifact shares the same version of the project

• Simpler to manage

• Used by NetBeans for publishing Maven artifacts (e.g. NETBEANS691)

• Trick - indeed every NetBeans module has got its own version

23

Friday, September 24, 2010

Page 155: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Module versioning strategies

• Every module artifact shares the same version of the project

• Simpler to manage

• Used by NetBeans for publishing Maven artifacts (e.g. NETBEANS691)

• Trick - indeed every NetBeans module has got its own version

• Every module artifact has got its own version number

23

Friday, September 24, 2010

Page 156: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Module versioning strategies

• Every module artifact shares the same version of the project

• Simpler to manage

• Used by NetBeans for publishing Maven artifacts (e.g. NETBEANS691)

• Trick - indeed every NetBeans module has got its own version

• Every module artifact has got its own version number

• Slightly more complex to manage

23

Friday, September 24, 2010

Page 157: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Module versioning strategies

• Every module artifact shares the same version of the project

• Simpler to manage

• Used by NetBeans for publishing Maven artifacts (e.g. NETBEANS691)

• Trick - indeed every NetBeans module has got its own version

• Every module artifact has got its own version number

• Slightly more complex to manage

• Required if your modules might move from a project to another

23

Friday, September 24, 2010

Page 158: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Smart dependency convergence

24

Friday, September 24, 2010

Page 159: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Smart dependency convergence

• The <dependencyManagement> section

24

Friday, September 24, 2010

Page 160: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Smart dependency convergence

• The <dependencyManagement> section

• Declare all the versions of the dependencies used in a project just once, in a parent POM (DRY)

24

Friday, September 24, 2010

Page 161: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Smart dependency convergence

• The <dependencyManagement> section

• Declare all the versions of the dependencies used in a project just once, in a parent POM (DRY)

• Children POMs won’t need to declare the version again

24

Friday, September 24, 2010

Page 162: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Smart dependency convergence

• The <dependencyManagement> section

• Declare all the versions of the dependencies used in a project just once, in a parent POM (DRY)

• Children POMs won’t need to declare the version again

24

<dependencyManagement> <dependencies> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-capabilitiesprovider</artifactId> <version>1.1.26</version> </dependency> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-docking</artifactId> <version>1.1.14</version> </dependency> ... </dependencies> </dependencyManagement>

Friday, September 24, 2010

Page 163: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Smart dependency convergence

• The <dependencyManagement> section

• Declare all the versions of the dependencies used in a project just once, in a parent POM (DRY)

• Children POMs won’t need to declare the version again

• The <dependencyManagement> section can be imported

24

<dependencyManagement> <dependencies> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-capabilitiesprovider</artifactId> <version>1.1.26</version> </dependency> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-docking</artifactId> <version>1.1.14</version> </dependency> ... </dependencies> </dependencyManagement>

Friday, September 24, 2010

Page 164: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Smart dependency convergence

• The <dependencyManagement> section

• Declare all the versions of the dependencies used in a project just once, in a parent POM (DRY)

• Children POMs won’t need to declare the version again

• The <dependencyManagement> section can be imported

• Import a single POM specifying its single version

24

<dependencyManagement> <dependencies> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-capabilitiesprovider</artifactId> <version>1.1.26</version> </dependency> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-docking</artifactId> <version>1.1.14</version> </dependency> ... </dependencies> </dependencyManagement>

Friday, September 24, 2010

Page 165: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Smart dependency convergence

• The <dependencyManagement> section

• Declare all the versions of the dependencies used in a project just once, in a parent POM (DRY)

• Children POMs won’t need to declare the version again

• The <dependencyManagement> section can be imported

• Import a single POM specifying its single version

• Maven will “unpack” from it all the declared versions at once

24

<dependencyManagement> <dependencies> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-capabilitiesprovider</artifactId> <version>1.1.26</version> </dependency> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-docking</artifactId> <version>1.1.14</version> </dependency> ... </dependencies> </dependencyManagement>

Friday, September 24, 2010

Page 166: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Smart dependency convergence

• The <dependencyManagement> section

• Declare all the versions of the dependencies used in a project just once, in a parent POM (DRY)

• Children POMs won’t need to declare the version again

• The <dependencyManagement> section can be imported

• Import a single POM specifying its single version

• Maven will “unpack” from it all the declared versions at once

24

<dependencyManagement> <dependencies> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-capabilitiesprovider</artifactId> <version>1.1.26</version> </dependency> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>it-tidalwave-netbeans-docking</artifactId> <version>1.1.14</version> </dependency> ... </dependencies> </dependencyManagement>

<dependencyManagement> <dependencies> <dependency> <groupId>it.tidalwave.semantic</groupId> <artifactId>semantic</artifactId> <version>0.10.19</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>it.tidalwave.netbeans</groupId> <artifactId>openbluesky</artifactId> <version>0.8.4</version> <type>pom</type> <scope>import</scope> </dependency> ... </dependencies> </dependencyManagement>

Friday, September 24, 2010

Page 167: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Optimizing a Maven Platform project

25

Friday, September 24, 2010

Page 168: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Optimizing a Maven Platform project

25

Master POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

*

1

1

Friday, September 24, 2010

Page 169: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Optimizing a Maven Platform project

25

Master POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

*

1

1

Modules POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

Master POM

1

1

1

*

Friday, September 24, 2010

Page 170: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Optimizing a Maven Platform project

25

Contains dependencyManagement of modules imported by this

project

Master POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

*

1

1

Modules POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

Master POM

1

1

1

*

Friday, September 24, 2010

Page 171: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Optimizing a Maven Platform project

25

Contains dependencyManagement of modules imported by this

project

Contains dependencyManagement of modules exported by this

project

Master POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

*

1

1

Modules POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

Master POM

1

1

1

*

Friday, September 24, 2010

Page 172: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Optimizing a Maven Platform project

25

Contains dependencyManagement of modules imported by this

project

Contains dependencyManagement of modules exported by this

project

Other projectPOM

<<imports>>

A single POM import retrieves all the correct modules versions in a

consistent way

Master POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

*

1

1

Modules POM

BrandingModule POM

ApplicationModule POM

Other NBM POM

Master POM

1

1

1

*

Friday, September 24, 2010

Page 173: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBPWR projectFrom there, it’s optional. If you ran out of time, just mention the project

26

Friday, September 24, 2010

Page 174: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBPWR project

• The NetBeans Platform needs to “wrap” non-platform jar libraries

From there, it’s optional. If you ran out of time, just mention the project

26

Friday, September 24, 2010

Page 175: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBPWR project

• The NetBeans Platform needs to “wrap” non-platform jar libraries

• Declare public API, dependencies, other platform properties, ...

From there, it’s optional. If you ran out of time, just mention the project

26

Friday, September 24, 2010

Page 176: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBPWR project

• The NetBeans Platform needs to “wrap” non-platform jar libraries

• Declare public API, dependencies, other platform properties, ...

• Not hard, but it’s a waste to redo the same thing over and over for multiple projects

From there, it’s optional. If you ran out of time, just mention the project

26

Friday, September 24, 2010

Page 177: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

The NBPWR project

• The NetBeans Platform needs to “wrap” non-platform jar libraries

• Declare public API, dependencies, other platform properties, ...

• Not hard, but it’s a waste to redo the same thing over and over for multiple projects

• The “NetBeans Platform Wrapper Repository” project provides reusable wrappers for some common FLOSS libraries

From there, it’s optional. If you ran out of time, just mention the project

26

Friday, September 24, 2010

Page 178: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR issues

27

Friday, September 24, 2010

Page 179: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR issues

• Needs an alternate coordinate schema

27

Friday, September 24, 2010

Page 180: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR issues

• Needs an alternate coordinate schema

• Can’t use the original artifact coordinates + changing the packaging

27

Friday, September 24, 2010

Page 181: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR issues

• Needs an alternate coordinate schema

• Can’t use the original artifact coordinates + changing the packaging

• Also for having dependencies on a wrapped NBM, not the original JAR

27

Friday, September 24, 2010

Page 182: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR issues

• Needs an alternate coordinate schema

• Can’t use the original artifact coordinates + changing the packaging

• Also for having dependencies on a wrapped NBM, not the original JAR

27

org.swinglabs:swingx:1.6becomes

com.kenai.nbpwr:org-jdesktop-swingx:1.6-201002261215

Friday, September 24, 2010

Page 183: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR issues

• Needs an alternate coordinate schema

• Can’t use the original artifact coordinates + changing the packaging

• Also for having dependencies on a wrapped NBM, not the original JAR

• Needs a further versioning qualifier

27

org.swinglabs:swingx:1.6becomes

com.kenai.nbpwr:org-jdesktop-swingx:1.6-201002261215

Friday, September 24, 2010

Page 184: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR issues

• Needs an alternate coordinate schema

• Can’t use the original artifact coordinates + changing the packaging

• Also for having dependencies on a wrapped NBM, not the original JAR

• Needs a further versioning qualifier

• Errors might be done e.g. in declaring the public API, thus needing a fix release targeting the same original library version

27

org.swinglabs:swingx:1.6becomes

com.kenai.nbpwr:org-jdesktop-swingx:1.6-201002261215

Friday, September 24, 2010

Page 185: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR issues

• Needs an alternate coordinate schema

• Can’t use the original artifact coordinates + changing the packaging

• Also for having dependencies on a wrapped NBM, not the original JAR

• Needs a further versioning qualifier

• Errors might be done e.g. in declaring the public API, thus needing a fix release targeting the same original library version

• It’s possible to attach original sources and javadocs

27

org.swinglabs:swingx:1.6becomes

com.kenai.nbpwr:org-jdesktop-swingx:1.6-201002261215

Friday, September 24, 2010

Page 186: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR issues

• Needs an alternate coordinate schema

• Can’t use the original artifact coordinates + changing the packaging

• Also for having dependencies on a wrapped NBM, not the original JAR

• Needs a further versioning qualifier

• Errors might be done e.g. in declaring the public API, thus needing a fix release targeting the same original library version

• It’s possible to attach original sources and javadocs

• Granularity: one .nbm per .jar or aggregates?

27

org.swinglabs:swingx:1.6becomes

com.kenai.nbpwr:org-jdesktop-swingx:1.6-201002261215

Friday, September 24, 2010

Page 187: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR usage

28

Friday, September 24, 2010

Page 188: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR usage

• You might not like some NBPWR decisions

28

Friday, September 24, 2010

Page 189: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR usage

• You might not like some NBPWR decisions

• Interested in feedback about this!

28

Friday, September 24, 2010

Page 190: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR usage

• You might not like some NBPWR decisions

• Interested in feedback about this!

• Still, a NBPWR-like approach is time-saving inside a given corporate / workgroup

28

Friday, September 24, 2010

Page 191: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

NBPWR usage

• You might not like some NBPWR decisions

• Interested in feedback about this!

• Still, a NBPWR-like approach is time-saving inside a given corporate / workgroup

• Cooperating, it could become a standard way of doing things

28

Friday, September 24, 2010

Page 192: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

29

Friday, September 24, 2010

Page 193: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

• The NB Platform is a highly modular and scalable framework

29

Friday, September 24, 2010

Page 194: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

• The NB Platform is a highly modular and scalable framework

• The And Build Harness might not scale with your needs

29

Friday, September 24, 2010

Page 195: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

• The NB Platform is a highly modular and scalable framework

• The And Build Harness might not scale with your needs

• Cross-dependencies in large projects might be a problem

29

Friday, September 24, 2010

Page 196: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

• The NB Platform is a highly modular and scalable framework

• The And Build Harness might not scale with your needs

• Cross-dependencies in large projects might be a problem

• Maven is a valuable and effective alternative

29

Friday, September 24, 2010

Page 197: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

• The NB Platform is a highly modular and scalable framework

• The And Build Harness might not scale with your needs

• Cross-dependencies in large projects might be a problem

• Maven is a valuable and effective alternative

• Intuitive artifact management and cross-dependency management

29

Friday, September 24, 2010

Page 198: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

• The NB Platform is a highly modular and scalable framework

• The And Build Harness might not scale with your needs

• Cross-dependencies in large projects might be a problem

• Maven is a valuable and effective alternative

• Intuitive artifact management and cross-dependency management

• Your Platform project just becomes a standard Maven project

29

Friday, September 24, 2010

Page 199: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

• The NB Platform is a highly modular and scalable framework

• The And Build Harness might not scale with your needs

• Cross-dependencies in large projects might be a problem

• Maven is a valuable and effective alternative

• Intuitive artifact management and cross-dependency management

• Your Platform project just becomes a standard Maven project

• Can be used with other IDEs - easy QA & Continuous Integration

29

Friday, September 24, 2010

Page 200: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

• The NB Platform is a highly modular and scalable framework

• The And Build Harness might not scale with your needs

• Cross-dependencies in large projects might be a problem

• Maven is a valuable and effective alternative

• Intuitive artifact management and cross-dependency management

• Your Platform project just becomes a standard Maven project

• Can be used with other IDEs - easy QA & Continuous Integration

• Beware: to be effective, Maven needs some pieces of infrastructure!

29

Friday, September 24, 2010

Page 201: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Conclusion

• The NB Platform is a highly modular and scalable framework

• The And Build Harness might not scale with your needs

• Cross-dependencies in large projects might be a problem

• Maven is a valuable and effective alternative

• Intuitive artifact management and cross-dependency management

• Your Platform project just becomes a standard Maven project

• Can be used with other IDEs - easy QA & Continuous Integration

• Beware: to be effective, Maven needs some pieces of infrastructure!

• Ant vs Maven is partly subjective

29

Friday, September 24, 2010

Page 202: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Question time

30

Friday, September 24, 2010

Page 203: Netbeans+platform+maven

Efficient development of large NetBeans Platform applications with Maven

Question time

• Follow me

• at my Java.Net blog

• at DZone

• Useful links

• http://platform.netbeans.org

• http://wiki.netbeans.org/MavenBestPractices

• http://forceten.tidalwave.it/development/tutorials/using-the-geoexplorer-and-the-geoviewer/

• http://bluemarine.tidalwave.it

30

Friday, September 24, 2010