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.ArrayList; 008 import java.util.Collection; 009 import java.util.HashMap; 010 import java.util.List; 011 import java.util.Map; 012 013 import org.apache.maven.artifact.DependencyResolutionRequiredException; 014 import org.apache.maven.model.Dependency; 015 import org.apache.maven.plugin.AbstractMojo; 016 import org.apache.maven.plugin.MojoExecutionException; 017 import org.apache.maven.plugin.MojoFailureException; 018 import org.apache.maven.project.MavenProject; 019 import org.joda.time.DateTime; 020 import org.kuali.student.admin.ui.mojo.KSCreateAdminUiMojo; 021 import org.kuali.student.common.mojo.AbstractKSMojo; 022 import org.kuali.student.contract.model.ServiceContractModel; 023 import org.kuali.student.contract.model.impl.ServiceContractModelCache; 024 import org.kuali.student.contract.model.impl.ServiceContractModelPescXsdLoader; 025 import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader; 026 import org.kuali.student.contract.model.util.DateUtility; 027 import org.kuali.student.contract.model.util.HtmlContractWriter; 028 import org.kuali.student.contract.model.validation.ServiceContractModelValidator; 029 import org.slf4j.Logger; 030 import org.slf4j.LoggerFactory; 031 032 /** 033 * The plugin entrypoint which is used to generate the html wiki doc of the service interface. 034 * @goal kscontractdoc 035 * @phase site 036 * @requiresProject true 037 */ 038 public class KSContractDocMojo extends AbstractKSMojo { 039 040 private static Logger log = LoggerFactory.getLogger(KSContractDocMojo.class); 041 042 /** 043 * @parameter expression="${htmlDirectory}" default-value="${project.build.directory}/site/services/contractdocs" 044 */ 045 private File htmlDirectory; 046 047 public File getHtmlDirectory() { 048 return htmlDirectory; 049 } 050 051 public void setHtmlDirectory(File htmlDirectory) { 052 this.htmlDirectory = htmlDirectory; 053 } 054 055 @Override 056 public void execute() throws MojoExecutionException, MojoFailureException { 057 058 MavenProject project = (MavenProject) getPluginContext().get("project"); 059 060 String formattedDate = DateUtility.asYMDHMInEasternTimeZone(new DateTime()); 061 062 ServiceContractModel model = null; 063 HtmlContractWriter writer = null; 064 getLog().info("publishing wiki contracts"); 065 model = this.getModel(); 066 this.validate(model); 067 getLog().info("publishing to = " + this.htmlDirectory.toString()); 068 writer = new HtmlContractWriter(htmlDirectory.toString(), model); 069 writer.write(project.getVersion(), formattedDate); 070 071 072 } 073 074 075 private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main"; 076 // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core"; 077 private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java"; 078 private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java"; 079 private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java"; 080 private static final String KSA_DIRECTORY = "D:/svn/ks/ksa/ksa-core/src/main/java"; 081 private static final String TEST_SOURCE_DIRECTORY = 082 "src/test/java/org/kuali/student/contract/model/test/source"; 083 private static final String TARGET_GENERATED_SOURCES = "target/generated-sources"; 084 private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main"; 085 086 private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/core/api/src/main/java"; 087 private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/kim/kim-api/src/main/java"; 088 private static final String RICE_KRMS_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/krms/api/src/main/java"; 089 090 091 private static final String TRUNK_CORE_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java"; 092 private static final String TRUNK_ENROLL_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java"; 093 private static final String TRUNK_ENROLL_IMPL_KRMS_API = "D:/svn/ks/trunk/ks-enroll/ks-enroll-impl/src/main/java/org/kuali/rice/krms/api"; 094 095 096 public static void main(String[] args) { 097 log.info("execute"); 098 List<String> srcDirs = new ArrayList<String>(); 099 // srcDirs.add(COMMON_DIRECTORY); 100 // srcDirs.add(CORE_DIRECTORY); 101 // srcDirs.add(LUM_DIRECTORY); 102 // srcDirs.add(ENROLL_DIRECTORY); 103 // srcDirs.add(RICE_KIM_API_DIRECTORY); 104 srcDirs.add(KSA_DIRECTORY); 105 // srcDirs.add(RICE_CORE_API_DIRECTORY); 106 // srcDirs.add(RICE_KRMS_API_DIRECTORY); 107 // srcDirs.add(TRUNK_ENROLL_IMPL_KRMS_API); 108 KSContractDocMojo instance = new KSContractDocMojo(); 109 Map pluginContext = new HashMap(); 110 MavenProject project = new MavenProject(); 111 pluginContext.put("project", project); 112 instance.setPluginContext(pluginContext); 113 instance.setSourceDirs(srcDirs); 114 instance.setHtmlDirectory(new File (TARGET_GENERATED_SOURCES)); 115 try { 116 instance.execute(); 117 } catch (MojoExecutionException ex) { 118 throw new RuntimeException(ex); 119 } catch (MojoFailureException ex) { 120 throw new RuntimeException(ex); 121 } 122 } 123 124 }