Commande Line Interface

POMStrap can work as an application bootstrap. It just requires a pom file (Maven 2 project file) and a class/method to fetch all required dependencies and launch the application using a command line syntax such as:

java -jar pomstrap-1.0.12.jar groupId:artifact:version classname[:method] [method args]

for example:

java -jar pomstrap-1.0.12.jar pomstrap:testApp:1.0 com.prefetch.pomstrap.App:run

If no method is provided it will try to start the classical java static main method.


Properties

By default POMStrap looks into you local repository (in you [home directory]/.m2/repository) but you can also specify another repository URL using system property:

 -Dpomstrap.maven2.repository=[URL]


Dependencies are automatically grouped by Maven groupid within the same classloader. This feature can be disable using system property:

 -Dpomstrap.autogroup.dependencies=false

For specific usage, some specific dependency can be grouped under same classloader using property:

 -Dpomstrap.customgroup="groupId:artifact groupId:artifact,groupId:artifact groupId:artifact, ...

Groups are separated by a comma.

 -Dpomstrap.loadonce=
"groupId:artifact groupId:artifact,groupId:artifact groupId:artifact, ...


To avoid loading of any groupId:artifactId
 -Dpomstrap.neverload=javax.activation:activation,xalan:xalan


For repository that requires authentication you can provide username/password using properties:
 -Dpomstrap.authenticator.username=myusername
 -Dpomstrap.authenticator.password=mypassword

If you need to load dependency from larger scope that 'runtime'
 -Dpomstrap.loadscope=compile,provided

All those properties can be written in the "pomstrap.properties" file such as:

pomstrap.customgroup=javax.activation:activation javax.mail:mail
pomstrap.loadonce=commons-logging:commons-logging,org.hibernate:hibernate,org.hibernate:hibernate-annotations
pomstrap.neverload=javax.activation:activation,xalan:xalan
pomstrap.authenticator.username=myusername
pomstrap.authenticator.password=mypassword
pomstrap.loadscope=compile,provided

Resouce loading

You can now load a file in maven repository as a resource using syntax such as: /m2:groupId:artifactId:version:packaging.

For example:

InputStream is = this.getClass().getResourceAsStream( "/m2:com.pretech.pomstrap:dummy:1.2:jar" );

This instruction will load the file:
[maven repository]/com/prefetch/pomstrap/dummy/1.2/dummy-1.2.jar


Maven 2 Plugin

POMStrap can be used as Maven2 plugin.
Just configure the pom file as with appropriate groupId/artifactId/version className/methodName values (see provided testPlugin sample).

Then you can cast the plugin with command line:
mvn pomstrap:run