An individual solution for use with Artifactory + Ivy + ant is to scan each module for license information. If a license is found, fill out this license file in Artifactory and update it ivy.xml so that it is available as a published artifact. Then call <ivy:retrieve/> to get a license along with its jar file.
The license can be specified in the ivy.xml module as a URL. In this case, use the ant get task to download the license and write it to a text file.
[inside log4j ivy.xml as an example] <ivy-module xmlns:m="http://ant.apache.org/ivy/maven" version="2.0"> <info organisation="log4j" module="log4j" revision="1.2.16" status="integration" publication="20120620150430"> <license name="The Apache Software License, Version 2.0" url="http://www.apache.org/licenses/LICENSE-2.0.txt"/> ... </info> </ivy-module>
Alternatively, the license may be included as a text file in a .jar file. In this case, use the ant unjar task to extract the license and write it to a text file.
[inside junit .jar file as an example] junit-4.8.2.jar/LICENSE.txt
Once the license has been written out as a text file, use the ant xmltask task to add the license as an artifact.
[inside log4j ivy.xml as an example] <publications> <artifact conf="master" ext="jar" name="log4j" type="bundle"/> <artifact conf="sources" ext="jar" m:classifier="sources" name="log4j" type="source"/> <artifact conf="javadoc" ext="jar" m:classifier="javadoc" name="log4j" type="javadoc"/> <artifact conf="master" ext="txt" name="log4j" type="license"/> </publications>
Post the modified ivy.xml and license back to Artifactory.
<ivy:resolve file="${ivy.xml}" /> <ivy:publish resolver="${resolver}" pubrevision="@{rev}" status="integration" overwrite="true" forcedeliver="true" haltonmissing="false" srcivypattern="${ivy.local}/[organisation]/[module]/ivy-[revision].xml" > <artifacts pattern="${ivy.local}/[organisation]/[module]/ivys/ivy-[revision].[ext]" /> <artifacts pattern="${ivy.cache.dir}/[organisation]/[module]/licenses/[module]-[revision].[ext]" /> </ivy:publish>
Use <ivy:retrieve/> to obtain a license along with your jar file when typing with your assembly.
<ivy:retrieve pattern="${ivy.local}/[artifact].[ext]" conf="compile, runtime" type="jar, license" />
nohup
source share