You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Xasima Xirohata <xa...@gmail.com> on 2008/03/26 09:06:39 UTC

how to install a lot of plain jars into maven repo (with ant-maven tasks)

hi, Could you please point me to existent ant / maven file (or hint the
other solution), that  helps install a great amount of ordinary jar files
into local maven repository.

Basically, I'm going to reorganize my projects with maven principles and
tool, so I need to install into repository all currently used thirty-part
jars (that have the commercial  nature and have not  been exposed into
private or public repository yet). There are a lot of them  so I can't
neither to invoke the command for ones that have no dependencies
mvn deploy:deploy-file -DgroupId=FIXED_CORPORATE_ID
-DartifactId=NAMEOFJAR_VARIED -Dversion=2.6 -Dpackaging=jar
-Dfile=NAMEOFJAR_VARIED.jar -Durl=file:\\c:\usr\local\.m2\local-repository
nor to provide an POM file when some has dependencies declared  in
MANIFEST/classpath

I'd tried to write the ant script that do this (with no manifest analyzing),
but have problem, that property 'mt.filename' below has not been resolved in
runtime

<?xml version="1.0" encoding="UTF-8"?>
<project name="Migration Tool" default="install" basedir=".">
    <description>Install plain jar files into maven repository with
specified metadata</description>

    <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="/usr/share/java/lib/ant-contrib-1.0b3.jar"
/>
        </classpath>
    </taskdef>

    <!-- - - - - - - - - - - - - - - - - -
            properties: maven properties
           - - - - - - - - - - - - - - - - - -->

    <property name="mt.maven-repository.url"
value="file:\\c:\usr\local\.m2\local-repository" />
    <property name="mt.maven.home" value="/bin/build-tools/apache-
maven-2.0.8/bin" />
    <property name="mt.maven.bin" value="mvn.bat" />
    <property name="mt.groupId" value="corporategroupid" /> <!-- fixed for
all-->
    <property name="mt.version" value="3.0.1" /> <!-- fixed for all-->

    <!-- =================================
          target: install
         ================================= -->
    <target name="install"   description="install file into repository">
        <for param="file">
            <path>
                <fileset dir=".">
                    <filename name="*.jar" />
                </fileset>
            </path>
            <sequential>
                <!-- deploy -->
                <propertyregex override="yes" property="mt.filename"
input="@{file}" regexp=".*/([^\.]*)\.jar" replace="\1" />
                <echo>@{file}</echo>
                <echo>${mt.filename}</echo>
                <exec executable="${mt.maven.home}/${mt.maven.bin}">
                    <arg value="deploy:deploy-file" />
                    <arg value="-DgroupId=${mt.groupId}" />
                    <arg value="-DartifactId=${mt.filename}" />
                    <arg value="-Dversion=${mt.version}" />
                    <arg value="-Dpackaging=jar" />
                    <arg value="-Dfile=@{mt.filename}.jar" />
                    <arg value="-Durl=${mt.maven-repository.url}" />
                </exec>
                <!-- deploy:deploy-file -DgroupId=${mt.groupId}
-DartifactId=LocalNameOfFileWithNoExtension -Dversion=${mt.version}
-Dpackaging=jar -Dfile=LocalNameOfFile.jar -Durl=${mt.maven-repository.url}
-->
            </sequential>
        </for>

    </target>



</project>

so it lists the @{file} as absolute path, when ${mt.filename} remains '${
mt.filename}' (unresolved). I can't just pass @{file} to maven args, since
 it complains on the long (absolute) path into arguments (reported: Missing
group,  artifact, version or packaging information).
Probably using ant-maven task (install-file) has the same limitation, since
i need to iterate over a file list and provide short file names to maven.
The first question is if anyone know the resolution.


The next question is if anyone know the simple approach (extension) to
extract class-path entry from manifest and put them as args for on-fly
created dependencies (with no predefined pom)?

ant -version  = 1.7.0
mvn --version = 2.0.8
java -version = 1.5.0_07
OS = win xp


-- 
Best regards,
~ Xasima ~

Re: how to install a lot of plain jars into maven repo (with ant-maven tasks)

Posted by Stephen Connolly <st...@gmail.com>.
The way I did it was

dir /b *.jar >> bag_of_jars.txt

Then I used regex's to turn bag_of_jars.txt into a batch file with mvn
deploy:deploy-file -DgeneratePom=true -Dfile=...

and I ran the batch file.

It's a once off, and since you have to tweak the groupId's to match what's
in the global repos anyway, automation is less useful

-Stephen

On Wed, Mar 26, 2008 at 8:06 AM, Xasima Xirohata <xa...@gmail.com> wrote:

> hi, Could you please point me to existent ant / maven file (or hint the
> other solution), that  helps install a great amount of ordinary jar files
> into local maven repository.
>
> Basically, I'm going to reorganize my projects with maven principles and
> tool, so I need to install into repository all currently used thirty-part
> jars (that have the commercial  nature and have not  been exposed into
> private or public repository yet). There are a lot of them  so I can't
> neither to invoke the command for ones that have no dependencies
> mvn deploy:deploy-file -DgroupId=FIXED_CORPORATE_ID
> -DartifactId=NAMEOFJAR_VARIED -Dversion=2.6 -Dpackaging=jar
> -Dfile=NAMEOFJAR_VARIED.jar -Durl=file:\\c:\usr\local\.m2\local-repository
> nor to provide an POM file when some has dependencies declared  in
> MANIFEST/classpath
>
> I'd tried to write the ant script that do this (with no manifest
> analyzing),
> but have problem, that property 'mt.filename' below has not been resolved
> in
> runtime
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project name="Migration Tool" default="install" basedir=".">
>    <description>Install plain jar files into maven repository with
> specified metadata</description>
>
>    <taskdef resource="net/sf/antcontrib/antlib.xml">
>        <classpath>
>            <pathelement location="/usr/share/java/lib/ant-
> contrib-1.0b3.jar"
> />
>        </classpath>
>    </taskdef>
>
>    <!-- - - - - - - - - - - - - - - - - -
>            properties: maven properties
>           - - - - - - - - - - - - - - - - - -->
>
>    <property name="mt.maven-repository.url"
> value="file:\\c:\usr\local\.m2\local-repository" />
>    <property name="mt.maven.home" value="/bin/build-tools/apache-
> maven-2.0.8/bin" />
>    <property name="mt.maven.bin" value="mvn.bat" />
>    <property name="mt.groupId" value="corporategroupid" /> <!-- fixed for
> all-->
>    <property name="mt.version" value="3.0.1" /> <!-- fixed for all-->
>
>    <!-- =================================
>          target: install
>         ================================= -->
>    <target name="install"   description="install file into repository">
>        <for param="file">
>            <path>
>                <fileset dir=".">
>                    <filename name="*.jar" />
>                </fileset>
>            </path>
>            <sequential>
>                <!-- deploy -->
>                <propertyregex override="yes" property="mt.filename"
> input="@{file}" regexp=".*/([^\.]*)\.jar" replace="\1" />
>                <echo>@{file}</echo>
>                <echo>${mt.filename}</echo>
>                <exec executable="${mt.maven.home}/${mt.maven.bin}">
>                    <arg value="deploy:deploy-file" />
>                    <arg value="-DgroupId=${mt.groupId}" />
>                    <arg value="-DartifactId=${mt.filename}" />
>                    <arg value="-Dversion=${mt.version}" />
>                    <arg value="-Dpackaging=jar" />
>                    <arg value="-Dfile=@{mt.filename}.jar" />
>                    <arg value="-Durl=${mt.maven-repository.url}" />
>                </exec>
>                <!-- deploy:deploy-file -DgroupId=${mt.groupId}
> -DartifactId=LocalNameOfFileWithNoExtension -Dversion=${mt.version}
> -Dpackaging=jar -Dfile=LocalNameOfFile.jar -Durl=${mt.maven-repository.url
> }
> -->
>            </sequential>
>        </for>
>
>    </target>
>
>
>
> </project>
>
> so it lists the @{file} as absolute path, when ${mt.filename} remains '${
> mt.filename}' (unresolved). I can't just pass @{file} to maven args, since
>  it complains on the long (absolute) path into arguments (reported:
> Missing
> group,  artifact, version or packaging information).
> Probably using ant-maven task (install-file) has the same limitation,
> since
> i need to iterate over a file list and provide short file names to maven.
> The first question is if anyone know the resolution.
>
>
> The next question is if anyone know the simple approach (extension) to
> extract class-path entry from manifest and put them as args for on-fly
> created dependencies (with no predefined pom)?
>
> ant -version  = 1.7.0
> mvn --version = 2.0.8
> java -version = 1.5.0_07
> OS = win xp
>
>
> --
> Best regards,
> ~ Xasima ~
>