Creating source distribution in a componentized project

In a componentized project, functionality comes from different components. A full source distribution for such project needs to contain sources from each of these components. Hence it's somewhat challenging when it comes to creating a source distribution. Read on to find out one possible solution.

Let me give you a generic overview of the project structure first.

  1. Our project is Java based & we use maven as our build tool
  2. We have a core platform, pretty much similar to linux kernel.
  3. We have components - Each of these components contain different functionality & are self sustainable. Each of these components contain documentation of its own. These documentation become automatically available when a UI page from a component is in use. (we call this context sensitive help/documentation)
  4. When we want to build a product, we pack together,
  • core platform
  • selection of components
  • Customized UI theming for the product
  • Samples related to product
  • Specific documentation related to product

Due to this nature of dynamism in a given product, it becomes challenging when creating source & documentation distributions to such products. Simple, yet ugly alternative is to have someone dedicated to create these distributions manually & keep an ever changing script to perform it.But its not a sustainable/cost effective work flow to a small team like ours. Hence we automated it. Rest of this blog post is on how to automate creation of source distribution. I will talk about the docs distro on some other post. We have included Maven source plugin as described here to root pom.xml of our projects. When a component is built, this plugin will pack the source of the component & upload it to maven repository.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.0.4-wso2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>  
In our product build script(done using maven assembly plugin), we download these source artifacts(of which the product is consisted of),
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.0-alpha-4</version>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>unpack-foo</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.foo.bar</groupId>
                                    <artifactId>foo</artifactId>
                                    <version>SNAPSHOT</version>
                                    <type>zip</type>
                                    <overWrite>true</overWrite>
                                    <classifier>sources</classifier>
                                    <outputDirectory>target/sources</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
unpack them to a folder structure of our choice, zip it back as our source distribution for a given product. This sure is a lengthy process, but has made it hell of lot easier when it comes to release times. When it comes to day-to-day building which does not require source/docs distributions, there are several tweaks to stop creation of these.

library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)