Search code examples
mavenantmaven-ant-tasks

How to install/deploy a sources jar with maven ant tasks


I had a hard time understanding how to install or deploy a jar file with its accompanying sources (or any additional classifier for that matter). The documentation wasn't clear to me and left me to do some trial and error.


Solution

  • Here is an example of how to use a classifier with maven ant run tasks:

    <target name="install-jar">
        ...
        <artifact:pom id="sharedPom" file="shared/pom.xml" />
        <artifact:install file="${classesdir}/shared.jar" >
            <pom refid="sharedPom" />
            <attach file="${builddir}/shared-sources.jar" classifier="sources" />
        </artifact:install>
    </target>
    

    The attach referenced to in the documentation is meant to be a sub-element. Hope this helps.