Wednesday, November 12, 2008

Idea for simple-jar-lib plugin

Often, when one looks at someone elses project, the artifact dependencies are a mess! The jars litter a lib/ folder, and often have no version or groupId, and it would be beneficial to structure them into a local repository. Another case is when you wish to supply an artifact which is not located in any external repository, but wish to have it close to your project in the VCS, for convenience. And the artifact has no pom. I believe the maven-dependency-plugin has a similar functionality which can be used with legacy maven1 projects, which do not require the advanced folder structure, but still requires a pom present.

Layout


lib/some-artifact.jar

com.some-company
some-artifact
1.0.3-SNAPSHOT


Implementation details


The pom.xml contains all the necessary information needed to create the folder structure and pom for the artifact. In fact, if you run Maven in a case where you have specified an artifact which it cannot find in any repositories, you will recieve instructions on how to use the maven-install plugin to add the project.

[INFO] Failed to resolve artifact.

Missing:
----------
1) com.some-application:some-artifact:jar:1.0.3-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=com.some-company -DartifactId=some-artifact \
-Dversion=1.0.3-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file


Today, the process is not automatic. However, all the semantics are already made in the pom.xml. All you require is that lib/some-artifact has the same identifier as in the dependency.

No comments:

Post a Comment

Spam will be pruned