src/java/fr/jayasoft/ivy/Ivy.java
/**
     * Publishes a module to the repository.
     * 
     * The publish can update the ivy file to publish if update is set to true. In this case it will use
     * the given pubrevision, pubdate and status. If pudate is null it will default to the current date.
     * If status is null it will default to the current ivy file status (which itself defaults to integration if none is found).
     * If update is false, then if the revision is not the same in the ivy file than the one expected (given as parameter),
     * this method will fail with an  IllegalArgumentException.
     * pubdate and status are not used if update is false.
     * extra artifacts can be used to publish more artifacts than actually declared in the ivy file.
     * This can be useful to publish additional metadata or reports.
     * The extra artifacts array can be null (= no extra artifacts), and if non null only the name, type, ext url 
     * and extra attributes of the artifacts are really used. Other methods can return null safely. 
     * 
     * @param mrid
     * @param pubrevision
     * @param cache
     * @param srcArtifactPattern
     * @param resolverName
     * @param srcIvyPattern
     * @param status
     * @param pubdate
     * @param validate
     * @param overwrite
     * @param update
     * @return
     * @throws IOException
     */
Publishes a module to the repository.

The publish can update the ivy file to publish if update is set to true. In this case it will use
the given pubrevision, pubdate and status. If pudate is null it will default to the current date.
If status is null it will default to the current ivy file status (which itself defaults to integration if none is found).
If update is false, then if the revision is not the same in the ivy file than the one expected (given as parameter),
this method will fail with an  IllegalArgumentException.
pubdate and status are not used if update is false.
extra artifacts can be used to publish more artifacts than actually declared in the ivy file.
This can be useful to publish additional metadata or reports.
The extra artifacts array can be null (= no extra artifacts), and if non null only the name, type, ext url
and extra attributes of the artifacts are really used. Other methods can return null safely.


Publishes a module to the repository . The publish can update the ivy file to publish if update is set to true . In this case it will use the given pubrevision pubdate and status . If pudate is null it will default to the current date . If status is null it will default to the current ivy file status ( which itself defaults to integration if none is found ) . If update is false then if the revision is not the same in the ivy file than the one expected ( given as parameter ) this method will fail with an IllegalArgumentException . pubdate and status are not used if update is false . extra artifacts can be used to publish more artifacts than actually declared in the ivy file . This can be useful to publish additional metadata or reports . The extra artifacts array can be null ( = no extra artifacts ) and if non null only the name type ext url and extra attributes of the artifacts are really used . Other methods can return null safely .
public Collection publish(ModuleRevisionId mrid, String pubrevision, File cache, Collection srcArtifactPattern, String resolverName, String srcIvyPattern, String status, Date pubdate, Artifact[] extraArtifacts, boolean validate, boolean overwrite, boolean update, String conf) throws IOException {
        IvyContext.getContext().setIvy(this);
        IvyContext.getContext().setCache(cache);
        Message.info(":: publishing :: "+mrid.getModuleId());
        Message.verbose("\tvalidate = "+validate);
        long start = System.currentTimeMillis();
        srcIvyPattern = substitute(srcIvyPattern);
        ModuleRevisionId pubmrid = ModuleRevisionId.newInstance(mrid, pubrevision);
        File ivyFile;
        if (srcIvyPattern != null) {
        	ivyFile = new File(IvyPatternHelper.substitute(srcIvyPattern, DefaultArtifact.newIvyArtifact(pubmrid, new Date())));
        	if (!ivyFile.exists()) {
        		throw new IllegalArgumentException("ivy file to publish not found for "+mrid+": call deliver before ("+ivyFile+")");
        	}
        } else {
        	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, false);
        	if (srcIvyPattern != null) {
            	if (!pubrevision.equals(md.getModuleRevisionId().getRevision())) {
            		if (update) {
            			File tmp = File.createTempFile("ivy", ".xml");
            			tmp.deleteOnExit();
            			try {
							XmlModuleDescriptorUpdater.update(this, ivyFileURL, tmp, new HashMap(), status==null?md.getStatus():status, pubrevision, pubdate==null?new Date():pubdate, null, true);
							ivyFile = tmp;
							md = XmlModuleDescriptorParser.getInstance().parseDescriptor(this, ivyFile.toURL(), false);
							srcIvyPattern = ivyFile.getAbsolutePath();
						} catch (SAXException e) {
				        	throw new IllegalStateException("bad ivy file for "+mrid+": "+ivyFile+": "+e);
						}
            		} else {
            			throw new IllegalArgumentException("cannot publish "+ivyFile+" as "+pubrevision+": bad revision found in ivy file. Use deliver before.");
            		}
            	}
        	} else {
				md.setResolvedModuleRevisionId(pubmrid);
        	}
        } catch (MalformedURLException e) {
        	throw new RuntimeException("malformed url obtained for file "+ivyFile);
        } catch (ParseException e) {
        	throw new IllegalStateException("bad ivy file for "+mrid+": "+ivyFile+": "+e);
        }
        DependencyResolver resolver = getResolver(resolverName);
        if (resolver == null) {
            throw new IllegalArgumentException("unknown resolver "+resolverName);
        }
        Collection missing = publish(md, resolver, srcArtifactPattern, srcIvyPattern, extraArtifacts, overwrite, conf);
        Message.verbose("\tpublish done ("+(System.currentTimeMillis()-start)+"ms)");
        return missing;
    }
public Collection publish ( ModuleRevisionId mrid , String pubrevision , File cache , Collection srcArtifactPattern , String resolverName , String srcIvyPattern , String status , Date pubdate , Artifact [ ] extraArtifacts , boolean validate , boolean overwrite , boolean update , String conf ) throws IOException { IvyContext . getContext ( ) . setIvy ( this ) ; IvyContext . getContext ( ) . setCache ( cache ) ; Message . info ( ":: publishing :: " + mrid . getModuleId ( ) ) ; Message . verbose ( "\tvalidate = " + validate ) ; long start = System . currentTimeMillis ( ) ; srcIvyPattern = substitute ( srcIvyPattern ) ; ModuleRevisionId pubmrid = ModuleRevisionId . newInstance ( mrid , pubrevision ) ; File ivyFile ; if ( srcIvyPattern != null ) { ivyFile = new File ( IvyPatternHelper . substitute ( srcIvyPattern , DefaultArtifact . newIvyArtifact ( pubmrid , new Date ( ) ) ) ) ; if ( ! ivyFile . exists ( ) ) { throw new IllegalArgumentException ( "ivy file to publish not found for " + mrid + ": call deliver before (" + ivyFile + ")" ) ; } } else { 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 , false ) ; if ( srcIvyPattern != null ) { if ( ! pubrevision . equals ( md . getModuleRevisionId ( ) . getRevision ( ) ) ) { if ( update ) { File tmp = File . createTempFile ( "ivy" , ".xml" ) ; tmp . deleteOnExit ( ) ; try { XmlModuleDescriptorUpdater . update ( this , ivyFileURL , tmp , new HashMap ( ) , status == null ? md . getStatus ( ) : status , pubrevision , pubdate == null ? new Date ( ) : pubdate , null , true ) ; ivyFile = tmp ; md = XmlModuleDescriptorParser . getInstance ( ) . parseDescriptor ( this , ivyFile . toURL ( ) , false ) ; srcIvyPattern = ivyFile . getAbsolutePath ( ) ; } catch ( SAXException e ) { throw new IllegalStateException ( "bad ivy file for " + mrid + ": " + ivyFile + ": " + e ) ; } } else { throw new IllegalArgumentException ( "cannot publish " + ivyFile + " as " + pubrevision + ": bad revision found in ivy file. Use deliver before." ) ; } } } else { md . setResolvedModuleRevisionId ( pubmrid ) ; } } catch ( MalformedURLException e ) { throw new RuntimeException ( "malformed url obtained for file " + ivyFile ) ; } catch ( ParseException e ) { throw new IllegalStateException ( "bad ivy file for " + mrid + ": " + ivyFile + ": " + e ) ; } DependencyResolver resolver = getResolver ( resolverName ) ; if ( resolver == null ) { throw new IllegalArgumentException ( "unknown resolver " + resolverName ) ; } Collection missing = publish ( md , resolver , srcArtifactPattern , srcIvyPattern , extraArtifacts , overwrite , conf ) ; Message . verbose ( "\tpublish done (" + ( System . currentTimeMillis ( ) - start ) + "ms)" ) ; return missing ; }
Publishes a module to the repository.
Publishes a module to the repository .
// 1) find the resolved module descriptor
 // we parse the new file to get updated module descriptor
 // collect all declared artifacts of this module
