Maven on le DropBox
Maven is awesome. But ... not all projects are available. You can install built jars into your local repostiory - but that's not awesome. Wouldn't it be great if you had free, and unlimited file hosting that you could tell Maven to upload to?
DropBox
DropBox offers a public folder. You can access anything copied into this folder via HTTP links using the same directory structure. So using the file wagon, you can deploy your artefacts to a personal repository on DropBox. You can include the repostiory in your other project's POMs and they'll build anywhere
Example
Before you start this, install Maven and DropBox and make sure that the later is synched and running.
Getting the URLs
Open your DropBox folder and locate the "Public" folder. Add a subfolder called "mvn-repostory" or something simmilar - it's probably best to avoid non [a-zA-Z0-9_-] characters, but I don't know. Into that folder add a file (of whatever type) and get the "public link" for the file - it should be something like this._```xml
http://dl.dropbox.com/u/3597441/mvn-repostory/New%20Text%20Document.txt
Drop the tail of the string and it becomes the URL of our furture repostiory.
xml
http://dl.dropbox.com/u/3597441/mvn-repostory/
We still need the internal URL for the File Wagon so copy the folder path ...
xml
C:\Users\g\Dropbox\Public\mvn-repostory
... and convert it to a URL
xml
file:///C:/Users/g/Dropbox/Public/mvn-repostory ``` You now have your two URLs
The Shared One
Make a project with a POM like this - it doesn't matter how you do this, that's the point of Maven. ```xml
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
Unknown end tag for </modelVersion>
foo.bar
Unknown end tag for </groupId>
lib
Unknown end tag for </artifactId>
0.0.1-SNAPSHOT
Unknown end tag for </version>
Unknown end tag for </project>
```
Ok - so far nothing surprising right?
Now add a src/main/java/foo/bar/lib
subfolder and put this Shared.java
in it.
``` package foo.bar.lib;
public class Shared { public static String goo() { return "voonderbull"; } } ```
You now have your shared project - you need to get it to deploy to your DropBox. Add a distribution management secions line this ... ```xml
dropbox
Unknown end tag for </id>
file:///C:/Users/g/Dropbox/Public/mvn-repostory
Unknown end tag for </url>
Unknown end tag for </repository>
Unknown end tag for </distributionManagement>
... so that your POM looks like this ...
xml
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
Unknown end tag for </modelVersion>
foo.bar
Unknown end tag for </groupId>
lib
Unknown end tag for </artifactId>
0.0.1-SNAPSHOT
Unknown end tag for </version>
dropbox
Unknown end tag for </id>
file:///C:/Users/g/Dropbox/Public/mvn-repostory
Unknown end tag for </url>
Unknown end tag for </repository>
Unknown end tag for </distributionManagement>
Unknown end tag for </project>
``` ... and fire off "mvn deploy"
Watch as DropBox synchronizes - you're now published.
The Main One
You can do this on any computer with Maven installed, it doesn't need DropBox. Create a POM like this, but using the URL from above.
```xml
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
Unknown end tag for </modelVersion>
foo.bar
Unknown end tag for </groupId>
app
Unknown end tag for </artifactId>
0.0.1-SNAPSHOT
Unknown end tag for </version>
dropbox
Unknown end tag for </id>
http://dl.dropbox.com/u/3597441/mvn-repostory
Unknown end tag for </url>
Unknown end tag for </repository>
Unknown end tag for </repositories>
foo.bar
Unknown end tag for </groupId>
lib
Unknown end tag for </artifactId>
0.0.1-SNAPSHOT
Unknown end tag for </version>
Unknown end tag for </dependency>
Unknown end tag for </dependencies>
Unknown end tag for </project>
```
Create a subfolder src/main/java/foo/bar/app
with the following Main.java
in it.
```
package foo.bar.app;
import foo.bar.lib.Shared;
public class Main {
public static void main(final String[] args) {
System.out.println("Shared.goo()=" + Shared.goo() + "
");
}
}
```
... and compile and run your project, possibly using Maven directly (any functioning Maven system should work)
$ mvn compile exec:java -Dexec.mainClass="foo.bar.app.Main"
Appendix
Because appendicies are so cool
Note on DropBox & Security
DropBox is like Java - it had one or two problems that don't matter for 99% of people, but everyone thinks they're in the 1%. A long time ago - a bug in DropBox let anyone read anyone else's files for like an hour. (I have no reference) They haven't had any problems since then ... but people still act like the whole system is teh haxed. Basically, if you only use it for this your security isn't risked. If strangers get write access to your DropBox - you're going to have problems since they can deploy malicous artefacts and you won't know.