1 package org.kuali.student.contract.mojo;
2
3 import java.io.File;
4 import java.net.MalformedURLException;
5 import java.net.URL;
6 import java.net.URLClassLoader;
7 import java.util.ArrayList;
8 import java.util.Collection;
9 import java.util.HashMap;
10 import java.util.List;
11 import java.util.Map;
12
13 import org.apache.maven.artifact.DependencyResolutionRequiredException;
14 import org.apache.maven.model.Dependency;
15 import org.apache.maven.plugin.AbstractMojo;
16 import org.apache.maven.plugin.MojoExecutionException;
17 import org.apache.maven.plugin.MojoFailureException;
18 import org.apache.maven.project.MavenProject;
19 import org.joda.time.DateTime;
20 import org.kuali.student.admin.ui.mojo.KSCreateAdminUiMojo;
21 import org.kuali.student.common.mojo.AbstractKSMojo;
22 import org.kuali.student.contract.model.ServiceContractModel;
23 import org.kuali.student.contract.model.impl.ServiceContractModelCache;
24 import org.kuali.student.contract.model.impl.ServiceContractModelPescXsdLoader;
25 import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader;
26 import org.kuali.student.contract.model.util.DateUtility;
27 import org.kuali.student.contract.model.util.HtmlContractWriter;
28 import org.kuali.student.contract.model.validation.ServiceContractModelValidator;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32
33
34
35
36
37
38 public class KSContractDocMojo extends AbstractKSMojo {
39
40 private static Logger log = LoggerFactory.getLogger(KSContractDocMojo.class);
41
42
43
44
45 private File htmlDirectory;
46
47 public File getHtmlDirectory() {
48 return htmlDirectory;
49 }
50
51 public void setHtmlDirectory(File htmlDirectory) {
52 this.htmlDirectory = htmlDirectory;
53 }
54
55 @Override
56 public void execute() throws MojoExecutionException, MojoFailureException {
57
58 MavenProject project = (MavenProject) getPluginContext().get("project");
59
60 String formattedDate = DateUtility.asYMDHMInEasternTimeZone(new DateTime());
61
62 ServiceContractModel model = null;
63 HtmlContractWriter writer = null;
64 getLog().info("publishing wiki contracts");
65 model = this.getModel();
66 this.validate(model);
67 getLog().info("publishing to = " + this.htmlDirectory.toString());
68 writer = new HtmlContractWriter(htmlDirectory.toString(), model);
69 writer.write(project.getVersion(), formattedDate);
70
71
72 }
73
74
75 private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main";
76
77 private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java";
78 private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java";
79 private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java";
80 private static final String KSA_DIRECTORY = "D:/svn/ks/ksa/ksa-core/src/main/java";
81 private static final String TEST_SOURCE_DIRECTORY =
82 "src/test/java/org/kuali/student/contract/model/test/source";
83 private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
84 private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main";
85
86 private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/core/api/src/main/java";
87 private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/kim/kim-api/src/main/java";
88 private static final String RICE_KRMS_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/krms/api/src/main/java";
89
90
91 private static final String TRUNK_CORE_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java";
92 private static final String TRUNK_ENROLL_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java";
93 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";
94
95
96 public static void main(String[] args) {
97 log.info("execute");
98 List<String> srcDirs = new ArrayList<String>();
99
100
101
102
103
104 srcDirs.add(KSA_DIRECTORY);
105
106
107
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 }