001    package org.kuali.student.contract.mojo;
002    
003    import java.io.File;
004    import java.net.MalformedURLException;
005    import java.net.URL;
006    import java.net.URLClassLoader;
007    import java.util.Collection;
008    import java.util.List;
009    
010    import org.apache.maven.artifact.DependencyResolutionRequiredException;
011    import org.apache.maven.model.Dependency;
012    import org.apache.maven.plugin.AbstractMojo;
013    import org.apache.maven.plugin.MojoExecutionException;
014    import org.apache.maven.project.MavenProject;
015    import org.joda.time.DateTime;
016    import org.kuali.student.common.mojo.AbstractKSMojo;
017    import org.kuali.student.contract.model.ServiceContractModel;
018    import org.kuali.student.contract.model.impl.ServiceContractModelCache;
019    import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader;
020    import org.kuali.student.contract.model.util.DateUtility;
021    import org.kuali.student.contract.model.util.HtmlContractWriter;
022    import org.kuali.student.contract.model.validation.ServiceContractModelValidator;
023    
024    /**
025     * The plugin entrypoint which is used to generate the html wiki doc of the service interface.
026     * @goal kscontractdoc
027     * @phase site
028     * @requiresProject true
029     */
030    public class KSContractDocMojo extends AbstractKSMojo {
031    
032        /**
033         * @parameter expression="${htmlDirectory}" default-value="${project.build.directory}/site/services/contractdocs"
034         */
035        private File htmlDirectory;
036    
037        public File getHtmlDirectory() {
038            return htmlDirectory;
039        }
040      
041        public void setHtmlDirectory(File htmlDirectory) {
042            this.htmlDirectory = htmlDirectory;
043        }
044    
045        @Override
046        public void execute() throws MojoExecutionException {
047            
048            MavenProject project = (MavenProject) getPluginContext().get("project");
049            
050            String formattedDate = DateUtility.asYMDHMInEasternTimeZone(new DateTime());
051            
052            ServiceContractModel model = null;
053            HtmlContractWriter writer = null;
054            getLog().info("publishing wiki contracts");
055            model = this.getModel();
056            this.validate(model);
057            getLog().info("publishing to = " + this.htmlDirectory.toString());
058            writer = new HtmlContractWriter(htmlDirectory.toString(), model);
059            writer.write(project.getVersion(), formattedDate);
060    
061    
062        }
063    }