I spent the whole day working with Apache Struts 2 Maven archetypes – it’s an open source project hosted at struts.apache.org – basically Action Base Java Web framework.

During that I discovered strange Maven behaviour – when I lunched it with -o option (work in offline mode) it wasn’t be able to find installed archetypes. To clarify – I prepared a script that will build up the archetype from source code, install it in my local Maven repository, then create basic application base on that archetype and lunch them, the source is below:download movie Collateral Beauty

if [ -e demo ] ; then
    rm -R demo
cd $1
mvn clean install
cd ..
mvn -o archetype:generate -DgroupId=org.demo
    -DartifactId=demo -Dversion=1.0-SNAPSHOT
    -DarchetypeGroupId=org.apache.struts -DarchetypeVersion=2.1.8
cd demo
mvn jetty:run
cd ..

$1 – it’s a command line parameter specifying archetype folder which is also archetype name

So it shouldn’t be needed to access remote archetype repository to download archetype – it’s already in local repository! I tried that with different Maven versions – the latest 2.2.1 and with 2.0.10 – with both was the same.

After some time and many experiments I found the solution – do not use -o option used -B instead! And that I was able to test one archetype – another 3 are waiting!