Apache Maven copy local file to a remote server server using SSH

I will show you in an Apache #Maven configuration file how to copy files to server each time the package phase is executed.

Solution with Ant SCP task

This snippet of code is a ready to use code that make use of Apache Ant task scp, Just put this snippet of code in your #Maven module where the assembly is executed or anywhere else to push all tar.gz files to a server just run a #maven mvn package, you can add as many ant task and push to many server the same file during the reactor build.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>server-copy</id>
            <goals>
                <goal>run</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <target>
                    <echo message="Push to server/home/"/>
                    <scp trust="yes" todir="user:password@server:/home/">
                        <fileset dir="${basedir}/target">
                            <include name="**/*.tar.gz"/>
                        </fileset>
                    </scp>
                </target>
            </configuration>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-jsch</artifactId>
            <version>1.8.2</version>
        </dependency>
    </dependencies>
</plugin>

Solution with #maven-deploy-plugin

The #maven-deploy-plugin allows you to configure the deploy phase to deploy to a server using scp. There is a page in the documentation that describes how it can be done.

Deploy #maven artifact using Maven Wagon SCP

Another alternative would be to use Maven Wagon SCP like described in this post for example

OSGi-Bundle with the Maven-Bundle-Plugin

OSGi (Open Service Gateway Initiative) is a #Java framework for developing and deploying modular software programs and libraries.OSGi has two parts. The first part is a specification for modular components called bundles, which are commonly referred to as plug-ins. The specification defines an infrastructure for a bundle’s life cycle and determines how bundles will interact.  The second part of OSGi is a #Java Virtual Machine (JVM)-level service registry that bundles can use to publish, discover and bind to services in a service-oriented architecture (SOA).

In this small post, I will show you how to make your first OSGi bundle using the Bundle Plugin for #Maven from Apache Felix

Continue reading OSGi-Bundle with the Maven-Bundle-Plugin

Plugin Freemind for Joomla! 1.6

The extension has been converted successfully to Joomla! 1.6

FreeMind is a free mind mapping application written in #Java which runs on Microsoft Windows, Mac OS and #Linux operating systems. FreeMind is licensed under the GNU General Public License

Freemind is a content plugin for #Joomla! that easily display mind map in your articles.

Mind map (*.mm) has to be on your host, you can not display currently remote mind map, aka URL starting with http://
You can put anywhere in your article the following keywords (one time or multiple times):

{freemind uri= width= height=}

All these parameters are mandatory
uri has to be a path to a local freemind map files

mymap.mm being in images/stories/maps/

{freemind uri=images/stories/maps/mymap.mm width=400 height=400} 

mymap.mm being in root folder of #Joomla!

{freemind uri=mymap.mm width=400 height=400} 

Features

  • Update manager is also supported, keep up to date this extension with only one click using #Joomla! 1.6 extensions manager
  • Freemind 1.6 is #Joomla! 1.6 native, it wont run in #Joomla! 1.5 (use Freemind 1.2.x)
  • Code produced is XHTML 1.0 Strict,
  • Tested in the following browser Firefox, Opera, Chrome, IE 8
  • License as always under GNU/GPL v3.0 or later

Download

Demo

Documentation

Visit the online WIKI

Support

Use the forum board

Behavior Driven Development with JBehave and Apache Maven

I won’t explain you how to write any JBehave tests as the online documentation is more than complete.

I prefer to show you how to make them run in eclipse, and in Apache #Maven as the example were not easy to run (scenario are wrongly in src/main/java).

JBehave is a framework for Behaviour-Driven Development
Behaviour-driven development (BDD) is an evolution of test-driven development (TDD) and acceptance-test driven design, and is intended to make these practices more accessible and intuitive to newcomers and experts alike.
It shifts the vocabulary from being test-based to behaviour-based, and positions itself as a design philosophy.
You can find out more about behaviour-driven development on the BDD wiki, or in the article Introducing BDD

Features of JBehave include:

  • Pure #Java implementation, which plays well with #Java-based enterprises.
  • Users can specify and run text-based user stories, which allows “out-in” development.
  • Annotation-based binding of textual steps to #Java methods, with auto-conversion of string arguments to any parameter type (including generic types) via custom parameter converters.
  • Annotation-based configuration and Steps class specifications
  • Dependency Injection support allowing both configuration and Steps instances composed via your favourite container (Guice, PicoContainer, Spring).
  • Extensible story reporting: outputs stories executed in different human-readable file-based formats (HTML, TXT, XML). Fully style-able view.
  • Auto-generation of pending steps so the build is not broken by a missing step, but has option to configure breaking build for pending steps.
  • Localisation of user stories, allowing them to be written in any language.
  • IDE integration: stories can be run as JUnit tests or other annotation-based unit test frameworks, providing easy integration with your favourite IDE.
  • Ant integration: allows stories to be run via Ant task
  • Maven integration: allows stories to be run via #Maven plugin at given build phase

To make the online sample run easily without having to check out the whole tree of JBehave, I will show you that by slightly altering the pom.xml of a sample (Trader), you can run them against a fix version of JBehave.

The whole pom.xml

<profiles>
    <profile>jbehave
        <activation>
            <activebydefault>false</activebydefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupid>org.apache.maven.plugins</groupid>
                    <artifactid>maven-dependency-plugin</artifactid>
                    <executions>
                        <execution>unpack-jbehave-site-resources                     
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <overwritereleases>false</overwritereleases>
                                <overwritesnapshots>true</overwritesnapshots>
                                <artifactitems>
                                    <artifactitem>
                                        <groupid>org.jbehave.site</groupid>
                                        <artifactid>jbehave-site-resources</artifactid>
                                        <version>2.0.2</version>
                                        <outputdirectory>${project.build.directory}/jbehave-reports/rendered
                                        </outputdirectory>
                                    </artifactitem>
                                </artifactitems>
                            </configuration>
                        </execution>
                        <execution>unpack-jbehave-reports-resources                     
                            <phase>generate-resources
                        </phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <overwritereleases>false</overwritereleases>
                                <overwritesnapshots>true</overwritesnapshots>
                                <artifactitems>
                                    <artifactitem>
                                        <groupid>org.jbehave</groupid>
                                        <artifactid>jbehave-core</artifactid>
                                        <version>${jbehave.version}</version>
                                        <outputdirectory>${project.build.directory}/jbehave-reports/rendered
                                        </outputdirectory>
                                        <includes>**\/*.css,**\/*.ftl,**\/*.js</includes>
                                    </artifactitem>
                                </artifactitems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupid>org.jbehave</groupid>
                    <artifactid>jbehave-maven-plugin</artifactid>
                    <version>${jbehave.version}</version>
                    <executions>
                        <execution>run-scenarios-found                     
                            <phase>integration-test</phase>
                            <configuration>
                                <scenarioincludes>
                                    <scenarioinclude>**/scenarios/*.java</scenarioinclude>
                                </scenarioincludes>
                                <scenarioexcludes>
                                    <scenarioexclude>**/i18n/scenarios/*.java</scenarioexclude>
                                </scenarioexcludes>
                                <batch>false</batch>
                                <ignorefailure>true</ignorefailure>
                                <classloaderinjected>false</classloaderinjected>
                                <scope>test</scope>
                            </configuration>
                            <goals>
                                <goal>run-scenarios</goal>
                            </goals>
                        </execution>
                        <execution>run-i18n-scenarios-found                     
                            <phase>integration-test</phase>
                            <configuration>
                                <scenarioincludes>
                                    <scenarioinclude>**/i18n/scenarios/*.java</scenarioinclude>
                                </scenarioincludes>
                                <skip>false</skip>
                                <classloaderinjected>true</classloaderinjected>
                                <scope>test</scope>
                            </configuration>
                            <goals>
                                <goal>run-scenarios</goal>
                            </goals>
                        </execution>
                        <execution>stepdoc                     
                            <phase>integration-test</phase>
                            <configuration>
                                <scenarioincludes>
                                    <scenarioinclude>**/scenarios/*.java</scenarioinclude>
                                </scenarioincludes>
                                <scenarioexcludes>
                                    <scenarioexclude>**/scenarios/None.java</scenarioexclude>
                                </scenarioexcludes>
                                <skip>false</skip>
                                <scope>test</scope>
                                <classloaderinjected>false</classloaderinjected>
                            </configuration>
                            <goals>
                                <goal>stepdoc</goal>
                            </goals>
                        </execution>
                        <execution>render-reports-generated                     
                            <phase>post-integration-test</phase>
                            <configuration>
                                <formats>
                                    <format>txt</format>
                                    <format>html</format>
                                    <format>xml</format>
                                </formats>
                                <scope>test</scope>
                                <ignorefailure>true</ignorefailure>
                            </configuration>
                            <goals>
                                <goal>render-reports</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
        <reporting>
            <excludedefaults>true</excludedefaults>
            <plugins>
                <plugin>
                    <groupid>org.jbehave</groupid>
                    <artifactid>jbehave-maven-plugin</artifactid>
                    <version>${jbehave.version}</version>
                    <configuration></configuration>
                    <reportsets>
                        <reportset>
                            <reports>
                                <report>render-reports</report>
                            </reports>
                        </reportset>
                    </reportsets>
                </plugin>
            </plugins>
        </reporting>
    </profile>
</profiles> 

When using Maven jetty:run, CSS and JavaScript files are never updated

I was getting mad because jetty was refusing to redeploy my static files (xhtml, css) in #Eclipse until I find the reason

The Jetty Web Server provides a HTTP server and Servlet container capable of serving static and dynamic contend either from a standalone or embedded instantiations.

Jetty buffers static content for webapps such as html files, css files, images etc and uses memory mapped files to do this if the NIO connectors are being used. The problem is that on Windows, memory mapping a file causes the file to be locked, so that the file cannot be updated or replaced. This means that effectively you have to stop Jetty in order to update a file.

To fix this, add a line with to your #maven-jetty-plugin configuration:

org.mortbay.jetty  maven-jetty-plugin  6.1.5       ...    src/main/resources/webdefault.xml     

The default webdefault.xml file is found in the lib/jetty.jar at org/mortbay/jetty/webapp/webdefault.xml. Extract it to a convenient disk location and edit it to change useFileMappedBuffer to false:

      useFileMappedBuffer       false     

Copy the changed file into src/main/resources/ of your project.

The problem is explained more in Jetty’s documentation.

I was fighting today against Apache Maven release plugin with multi modules projects

I was fighting today against the maven-release-plugin of #maven, solving complicated  errors in a row. As I am convince I made all possible errors,   I think it is worse to compile my findings here to help others 🙂

Maven Release Plugin

This plugin is used to release a project with #Maven, saving a lot of repetitive, manual work. Releasing a project is made in two steps: prepare and perform.

My approach to speed up things is always to define a small project (in a sandbox SVN root) that is compiling and running in 10 seconds to make some test before trying to make it run on our bigger Innoveo Skye(tm) product (35 modules)

I always have 2 projects prepared:

  • One TestSimpleProject: one #Maven project with no code
  • One TestComplexProject: one #maven project and 2 #Maven sub modules

For the reader that can not wait here is the running command line from TeamCity to be put in Build Runner Goals

release:clean release:prepare release:perform -Dusername=xxxxxxx -Dpassword=yyyyyy

Continue reading I was fighting today against Apache Maven release plugin with multi modules projects

Tux Droid Plugin for Jet Brains TeamCity 4.0

tux-droid-linux-companionTux Droid is a #Linux wireless Tux mascot (210mm x 180mm x 140mm – with lowered wings) with a programmable interface, allowing it to announce events by its gestures and by ALSA driven sound. The events are detected by specific gadgets, which are handled by the Tux Gadget Manager. The Tux Droid supports #Linux kernel 2.4 or later and needs a 800 MHz CPU and 128 MB RAM. It communicates by infrared to the USB port (1.1 or 2.0) and for media detection it needs an internet connection. The mascot is driven by Atmel AVR RISC microcontrollers. From http://en.wikipedia.org/wiki/Tux_Droid

TeamCity is a #Java-based build management and continuous integration server from JetBrains, creators of IntelliJ IDEA and ReSharper.

 

 

 

 

Continue reading Tux Droid Plugin for Jet Brains TeamCity 4.0

Setting up your workstation for Joomla! development

Joomla! Doc has a great documentation online that explains how to set up your development environment

This article provides detailed instructions for setting up your workstation for #Joomla! development. Note that there are many possible configurations for doing #Joomla! development. Any environment that supports Apache, MySql, PHP, and Subversion should work for writing #Joomla! code and extensions.

This document provides step-by-step instructions for setting up and working with the #Eclipse IDE. The example used and screen shots are for Windows XP, but the basic steps are the same for #Linux.

The part 1 mainly explains how to install technical components

The part 2 is even better as it explains how to create patches for #Joomla! along with some eclipse tips and tricks.

A strategy for Integrations versions with maven…

We are currently asking ourselves at INNOVEO, if we need to keep a version of integration versions.
Integration versions main objective is to be integrated with other modules to make and test an
application or a framework. This question is quickly becoming essential when working with several
modules, where you will have to to rely on intermediate, non finalized versions of modules.

Since we are also following  the continuous integration paradigm for all our modules, Thanks to
Apache MAVEN, these integration versions are produced by a continuous integration server
(Team City from JetBrain), very frequently.

So, how can you deal with these, possibly numerous, integration versions? The response is coming
from this extract from IVY documentation

There are basically two ways to deal with them,

Use a naming convention
The idea is pretty simple, each time you publish a new integration of your module you give the same
name to the version (in #maven world this is for example 1.0-SNAPSHOT). The dependency manager
should then be aware that this version is special because it changes over time, so that it does not
trust its local cache if it already has the version, but check the date of the version on the repository
and see if it has changed.


Create automatically a new version for each
in this case you use either a build number or a timestamp to publish each new integration version
with a new version name. Then you can use one of the numerous ways in Ivy to express a version
constraint. Usually selecting the very latest one (using ‘latest.integration’ as version constraint) is
enough.

But usually we recommend to use the second one, because using a new version each time you publish
a new version better fits the version identity paradigm, and can make all your builds reproducible,
even integration one. And this is interesting because it enables, with some work in your build system,
to introduce a mechanism to promote an integration build to a more stable status, like a milestone
or a release.

The example given is very interesting…

Imagine you have a customer which comes on a Monday morning and asks your latest version of your
software, for testing or demonstration purpose. Obviously he needs it for the afternoon 🙂 Now if
you have a continuous integration process and a good tracking of your changes and your artifacts, it
may occur that you are actually able to fulfill his request without needing the use of a dolorean to
give you some more time 🙂 But it may occur also that your latest version stable enough to be used
for the purpose of the customer was actually built a few days ago, because the very latest just break
a feature or introduce a new one you don’t want to deliver. In this case, you can deliver this ‘stable’
integration build if you want, but be sure that a few days, or weeks, or even months later, the
customer will ask for a bug fix on this demo only version. Why? Because it’s a customer, and we
all know how they are 🙂

So, with a build promotion feature of any build in your repository, the solution would be pretty easy:
when the customer ask for the version, you not only deliver the integration build, but you also
promote it to a milestone status, for example. this promotion indicates that you should keep track of
this version in a long period, to be able to come back to it and create a branch if needed.

Note this is the strategy at #Eclipse.org, where a nightly build (N20080420) can be promoted to an Maintenance
release if quality is good enough. Below I’ve put an extract of a presentation document from © 2006 by Alex Blewitt;
made available under the EPL v1.0 |  2006-03-20  |  http://www.rcpapps.org/

We are now using the same naming convention at INNOVEO for our product

Eclipse builds are of different type:

(N) Nightly
  • Built every night (whether successful or not)
  • Used to run quality metrics and whether tests have passed
(I) Integration
  • Used to ensure that code works together
  • Used to run quality metrics
(M) Maintenance
  • Released at the end of each build cycle
(R) Release
  • Released at the end of each release cycle

Each product is given a build id,

  • Build Type (N, I, M or R)
  • Build ID (M20060118)
  • Build Label (M20060118-1600)
  • Timestamp of build (16:00 on the 18th Jan, 2006)
  • Each release corresponds to a specific build label
  • May also be known as other aliases in CVS
  • R3_1_2, vI20060118-1000, R3_1_Maintenance

To keep the #Eclipse ecosystem in step, everything is tagged

  • Part of the build process tags the current code with vI20060320
  • A build is only promoted from N->I if there are no build failures
  • A build is promoted from I->M if there are no failures and all the
    functionality works to a satisfactory level
  • A build is promoted from M->R at the end of a release cycle and
    the quality is suitably high

On the other hand, the main drawback of this solution is that it can produce a lot of intermediate
versions, and you will have to run some cleaning scripts in your repository…

I will present You later how you can achieve this goal with MAVEN and Team City

Installing Subversion on OpenSuse and Plesk 9

subversion_logo-384x332 geeko plesk.logo Subversion (SVN) is an open source version control system. It allows users to keep track of changes made over time to any type of electronic data. Typical uses are versioning source code, web pages or design documents.

I now host my own private subversion at http://svn.waltercedric.com

A required step to be able to build some small project and finish the prototype of Continuous build for Joomla!

Continue reading Installing Subversion on OpenSuse and Plesk 9