All Downloads are FREE. Search and download functionalities are using the official Maven repository.

news.2016-05-17_24-00.html Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version

Spincast is now used to build itself!

How is this possible? Well, if you don't know yet, a Maven build process contains multiple phases, one of them is compile and this is where Spincast is actually compiled. But there are many other important phases following that one, and this is where the compiled Spincast classes can be used!

In spincast-website's pom.xml, during the prepare-package phase, we declare exec-maven-plugin plugins to dynamically call some Spincast classes. One of those classes is SpincastMavenPreparePackage, for example. Since Spincast is already compiled at this point, we can use it! In this particular case, we use Spincast to create a modified version of the Quick Start application, to zip it, and then to add it to the website's "public" folder, where it can be downloaded.

If you look at SpincastMavenPreparePackage's code, you'll see that in its main(...) method we start a Guice context using the SpincastDefaultGuiceModule Spincast's Guice module, exactly as we could do for a real Spincast application! This allows us to access all the functionalities, all the utilities provided by Spincast. For example, here we use a Spincast utility to zip the Quick Start sources. Note that we don't start a HTTP server though, since we don't need it!

In summary, instead of using a maven-antrun-plugin plugin for example, and having to deal with cumbersome XML logic when some custom steps are required during a build, we simply start a Guice context and we have full access to Spincast.

We will probably use that little trick in a reusable Maven Mojo plugin one day, but for build steps that are specific to a project, this approach works very well.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy