You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "M. Sean Gilligan" <se...@msgilligan.com> on 2004/11/23 04:02:13 UTC

Solution: Deploying legacy jar to maven repository

We seem to have solved the problem.  We created an XML file
that lists the jars to upload, and then use xml/xpath to parse it
and build a POM file for each JAR with a jelly POM template (stolen from
maven-repository-plugin-1.2)  We then use the maven:pom tag to create a
POM in memory and the artifact:deploy tag  to upload each JAR and it's POM
to our Maven repository.  The code could easily be adapted to install
to the "local" repository as well.

The list of jars is in a file called jar-list.xml, that looks like this:

<?xml version="1.0"?>
<jarlist groupId="cat-legacy-jars">
	<jar path="../libexec/castor-0.8.2.jar" artifactId="castor" version="0.8.2" />
</jarlist>

The relevant bits of maven.xml are here:

<j:set var="jar.list.pathname" value="jar-list.xml" />
<util:file var="jar.list.file" name="${jar.list.pathname}"/>
<j:set var="dummy.proj.url" value="http://maverick.in.osd/eng/" />
<x:parse var="doc" xml="${jar.list.file}"/>
<j:set var="groupId">
    <x:expr select="$doc/jarlist/@groupId"/>
</j:set>


<goal name="make-poms">
<ant:mkdir dir="${maven.build.dir}" /> 
<x:forEach select="$doc/jarlist/jar">
    <j:set var="path"><x:expr select="./@path"/></j:set>
    <j:set var="artifact"><x:expr select="./@artifactId"/></j:set>
    <j:set var="version"><x:expr select="./@version"/></j:set>
    <j:file name="${maven.build.dir}/${artifact}.pom" prettyPrint="yes">
        <j:import file="${basedir}/pom-template.jelly" inherit="true" />
    </j:file>
</x:forEach>
</goal>

<goal name="deploy-legacy" prereqs="make-poms">
<x:forEach select="$doc/jarlist/jar">
    <j:set var="path"><x:expr select="./@path"/></j:set>
    <j:set var="artifact"><x:expr select="./@artifactId"/></j:set>

    <maven:pom var="lpom" 
         projectDescriptor="${maven.build.dir}/${artifact}.pom" />
    <artifact:deploy
          artifact="${basedir}/${path}"
          type="jar"
          project="${lpom}" />
</x:forEach>
</goal>

If anyone has a better solution, please let me know.

Cheers,

Sean
-- 
---------------------------------------------------------------------------
M. Sean Gilligan                    : 831-466-9788 x11
vBlog Central			    : http://www.vblogcentral.com
---------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org