src/java/fr/jayasoft/ivy/Ivy.java
/**
     * delivers a resolved ivy file based upon last resolve call status and
     * the given PublishingDependencyRevisionResolver.
     * If resolve report file cannot be found in cache, then it throws 
     * an IllegalStateException (maybe resolve has not been called before ?)
     * Moreover, the given PublishingDependencyRevisionResolver is used for each 
     * dependency to get its published information. This can particularly useful
     * when the publish is made for a delivery, and when we wish to deliver each
     * dependency which is still in integration. The PublishingDependencyRevisionResolver
     * can then do the delivering work for the dependency and return the new (delivered)
     * dependency info (with the delivered revision). Note that 
     * PublishingDependencyRevisionResolver is only called for each <b>direct</b> dependency.
     * 
     * @param status the new status, null to keep the old one
     * @throws ParseException
     */
delivers a resolved ivy file based upon last resolve call status and
the given PublishingDependencyRevisionResolver.
If resolve report file cannot be found in cache, then it throws
an IllegalStateException (maybe resolve has not been called before ?)
Moreover, the given PublishingDependencyRevisionResolver is used for each
dependency to get its published information. This can particularly useful
when the publish is made for a delivery, and when we wish to deliver each
dependency which is still in integration. The PublishingDependencyRevisionResolver
can then do the delivering work for the dependency and return the new (delivered)
dependency info (with the delivered revision). Note that
PublishingDependencyRevisionResolver is only called for each direct dependency.

@param status the new status, null to keep the old one
@throws ParseException
delivers a resolved ivy file based upon last resolve call status and the given PublishingDependencyRevisionResolver . If resolve report file cannot be found in cache then it throws an IllegalStateException ( maybe resolve has not been called before ? ) Moreover the given PublishingDependencyRevisionResolver is used for each dependency to get its published information . This can particularly useful when the publish is made for a delivery and when we wish to deliver each dependency which is still in integration . The PublishingDependencyRevisionResolver can then do the delivering work for the dependency and return the new ( delivered ) dependency info ( with the delivered revision ) . Note that PublishingDependencyRevisionResolver is only called for each direct dependency . @param status the new status null to keep the old one @throws ParseException
public void deliver(ModuleRevisionId mrid,
            String revision,
            File cache, 
            String destIvyPattern, 
            String status,
            Date pubdate,
            PublishingDependencyRevisionResolver pdrResolver, 
            boolean validate,
            boolean resolveDynamicRevisions) throws IOException, ParseException {
        IvyContext.getContext().setIvy(this);
        IvyContext.getContext().setCache(cache);
        Message.info(":: delivering :: "+mrid+" :: "+revision+" :: "+status+" :: "+pubdate);
        Message.verbose("\tvalidate = "+validate);
        long start = System.currentTimeMillis();
        destIvyPattern = substitute(destIvyPattern);
        File ivyFile = getResolvedIvyFileInCache(cache, mrid);
        if (!ivyFile.exists()) {
            throw new IllegalStateException("ivy file not found in cache for "+mrid+": please resolve dependencies before publishing ("+ivyFile+")");
        }
        ModuleDescriptor md = null;
        URL ivyFileURL = null;
        try {
            ivyFileURL = ivyFile.toURL();
            md = XmlModuleDescriptorParser.getInstance().parseDescriptor(this, ivyFileURL, validate);
            md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(mrid, revision));
            md.setResolvedPublicationDate(pubdate);
        } catch (MalformedURLException e) {
            throw new RuntimeException("malformed url obtained for file "+ivyFile);
        } catch (ParseException e) {
            throw new IllegalStateException("bad ivy file in cache for "+mrid+": please clean and resolve again");
        }
        Map resolvedRevisions = new HashMap(); 
        Map dependenciesStatus = new HashMap(); 
        File ivyProperties = getResolvedIvyPropertiesInCache(cache, mrid);
        if (!ivyProperties.exists()) {
            throw new IllegalStateException("ivy properties not found in cache for "+mrid+": please resolve dependencies before publishing ("+ivyFile+")");
        }
        Properties props = new Properties();
        props.load(new FileInputStream(ivyProperties));
        for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
            String depMridStr = (String)iter.next();
            String[] parts = props.getProperty(depMridStr).split(" ");
            ModuleRevisionId decodedMrid = ModuleRevisionId.decode(depMridStr);
            if (resolveDynamicRevisions) {
                resolvedRevisions.put(decodedMrid, parts[0]);
            }
            dependenciesStatus.put(decodedMrid, parts[1]);
        }
        Map resolvedDependencies = new HashMap(); 
        DependencyDescriptor[] dependencies = md.getDependencies();
        for (int i = 0; i < dependencies.length; i++) {
            String rev = (String)resolvedRevisions.get(dependencies[i].getDependencyRevisionId());
            if (rev == null) {
                rev = dependencies[i].getDependencyRevisionId().getRevision();
            }
            String depStatus = (String)dependenciesStatus.get(dependencies[i].getDependencyRevisionId());
            resolvedDependencies.put(dependencies[i].getDependencyRevisionId(), 
                    pdrResolver.resolve(md, status, 
                            ModuleRevisionId.newInstance(dependencies[i].getDependencyRevisionId(), rev), 
                            depStatus));
        }
        String publishedIvy = IvyPatternHelper.substitute(destIvyPattern, md.getResolvedModuleRevisionId());
        Message.info("\tdelivering ivy file to "+publishedIvy);
        try {
            XmlModuleDescriptorUpdater.update(this, ivyFileURL, 
                    new File(publishedIvy),
                    resolvedDependencies, status, revision, pubdate, null, true);
        } catch (SAXException ex) {
            throw new IllegalStateException("bad ivy file in cache for "+mrid+": please clean and resolve again");
        }
        Message.verbose("\tdeliver done ("+(System.currentTimeMillis()-start)+"ms)");
    }
public void deliver ( ModuleRevisionId mrid , String revision , File cache , String destIvyPattern , String status , Date pubdate , PublishingDependencyRevisionResolver pdrResolver , boolean validate , boolean resolveDynamicRevisions ) throws IOException , ParseException { IvyContext . getContext ( ) . setIvy ( this ) ; IvyContext . getContext ( ) . setCache ( cache ) ; Message . info ( ":: delivering :: " + mrid + " :: " + revision + " :: " + status + " :: " + pubdate ) ; Message . verbose ( "\tvalidate = " + validate ) ; long start = System . currentTimeMillis ( ) ; destIvyPattern = substitute ( destIvyPattern ) ; File ivyFile = getResolvedIvyFileInCache ( cache , mrid ) ; if ( ! ivyFile . exists ( ) ) { throw new IllegalStateException ( "ivy file not found in cache for " + mrid + ": please resolve dependencies before publishing (" + ivyFile + ")" ) ; } ModuleDescriptor md = null ; URL ivyFileURL = null ; try { ivyFileURL = ivyFile . toURL ( ) ; md = XmlModuleDescriptorParser . getInstance ( ) . parseDescriptor ( this , ivyFileURL , validate ) ; md . setResolvedModuleRevisionId ( ModuleRevisionId . newInstance ( mrid , revision ) ) ; md . setResolvedPublicationDate ( pubdate ) ; } catch ( MalformedURLException e ) { throw new RuntimeException ( "malformed url obtained for file " + ivyFile ) ; } catch ( ParseException e ) { throw new IllegalStateException ( "bad ivy file in cache for " + mrid + ": please clean and resolve again" ) ; } Map resolvedRevisions = new HashMap ( ) ; Map dependenciesStatus = new HashMap ( ) ; File ivyProperties = getResolvedIvyPropertiesInCache ( cache , mrid ) ; if ( ! ivyProperties . exists ( ) ) { throw new IllegalStateException ( "ivy properties not found in cache for " + mrid + ": please resolve dependencies before publishing (" + ivyFile + ")" ) ; } Properties props = new Properties ( ) ; props . load ( new FileInputStream ( ivyProperties ) ) ; for ( Iterator iter = props . keySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { String depMridStr = ( String ) iter . next ( ) ; String [ ] parts = props . getProperty ( depMridStr ) . split ( " " ) ; ModuleRevisionId decodedMrid = ModuleRevisionId . decode ( depMridStr ) ; if ( resolveDynamicRevisions ) { resolvedRevisions . put ( decodedMrid , parts [ 0 ] ) ; } dependenciesStatus . put ( decodedMrid , parts [ 1 ] ) ; } Map resolvedDependencies = new HashMap ( ) ; DependencyDescriptor [ ] dependencies = md . getDependencies ( ) ; for ( int i = 0 ; i < dependencies . length ; i ++ ) { String rev = ( String ) resolvedRevisions . get ( dependencies [ i ] . getDependencyRevisionId ( ) ) ; if ( rev == null ) { rev = dependencies [ i ] . getDependencyRevisionId ( ) . getRevision ( ) ; } String depStatus = ( String ) dependenciesStatus . get ( dependencies [ i ] . getDependencyRevisionId ( ) ) ; resolvedDependencies . put ( dependencies [ i ] . getDependencyRevisionId ( ) , pdrResolver . resolve ( md , status , ModuleRevisionId . newInstance ( dependencies [ i ] . getDependencyRevisionId ( ) , rev ) , depStatus ) ) ; } String publishedIvy = IvyPatternHelper . substitute ( destIvyPattern , md . getResolvedModuleRevisionId ( ) ) ; Message . info ( "\tdelivering ivy file to " + publishedIvy ) ; try { XmlModuleDescriptorUpdater . update ( this , ivyFileURL , new File ( publishedIvy ) , resolvedDependencies , status , revision , pubdate , null , true ) ; } catch ( SAXException ex ) { throw new IllegalStateException ( "bad ivy file in cache for " + mrid + ": please clean and resolve again" ) ; } Message . verbose ( "\tdeliver done (" + ( System . currentTimeMillis ( ) - start ) + "ms)" ) ; }
delivers a resolved ivy file based upon last resolve call status and
 the given PublishingDependencyRevisionResolver.
delivers a resolved ivy file based upon last resolve call status and the given PublishingDependencyRevisionResolver .
// 1) find the resolved module descriptor in cache
 // 2) parse resolvedRevisions From properties file
 // Map (ModuleId -> String revision)
 // Map (ModuleId -> String status)
 // 3) use pdrResolver to resolve dependencies info
 // Map (ModuleRevisionId -> String revision)
 // 4) copy the source resolved ivy to the destination specified, 
 //    updating status, revision and dependency revisions obtained by
 //    PublishingDependencyRevisionResolver
