Skip to content

A Java ClassLoader that resolves and downloads dependencies from Maven repositories on-demand.

Notifications You must be signed in to change notification settings

kaffamobile/dropship

 
 

Repository files navigation

Dropship

Load Any Class In The (Mavenized) World

Given a Maven GAV coordinate, Dropship will resolve and download all dependencies from local and remote maven repositories.

This library utilizes Sonatype Aether, the library used by Maven to deal with repositories. Aether does all of the heavy lifting, this library aims to be a lightweight shim on top of it to help reduce the friction for a majority of potential uses.

Getting Started (Maven)

Until this is put into a maven repo, download source and build a .jar with Maven: mvn clean install

Add the following to your pom.xml:

<dependency>
    <groupId>com.github.smreed</groupId>
    <artifactId>dropship</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

You Can Create a ClassLoader:

ClassLoader classLoader = MavenClassloader.forGAV("junit:junit:4.8.1");

You're done! Assuming you wanted the classloader for a reason, such as loading a class, you just use normal reflection:

Class<?> junitAssertClass = classLoader.loadClass("org.junit.Assert");

Bootstrap Your Application

Stop pushing artifacts into production, use Dropship to pull them down from a maven repository and run your code! Dropship automatically creates a classpath containing all of your project's dependencies and will run the public static void main(String[]) method of a class you specify!

java -cp dropship-1.0-SNAPSHOT.jar com.github.smreed.dropship.Dropship mygroup:myartifact[:myversion] mygroup.myartifact.Main arg1 arg2...

If you omit the version, Dropship will automatically run the latest version of your artifact.

If you need to manage versions of multiple artifacts, then use dropship.properties to map them.

#dropship.properties
repo.remote.url = http:https://some-other-repo/
repo.local.path = /tmp

dropship.additional.paths = /tmp/resources

# You can leave older entries, they will be ignored and you can use this as a deploy log
# 2012-12-23
mygroup.myartifact = 1.0

# 2012-12-24
mygroup.myartifact = 1.1

About

A Java ClassLoader that resolves and downloads dependencies from Maven repositories on-demand.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%