View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.student.contract.mojo;
17  
18  import java.io.File;
19  import java.util.ArrayList;
20  import java.util.HashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.apache.maven.plugin.MojoExecutionException;
25  import org.apache.maven.plugin.MojoFailureException;
26  import org.apache.maven.project.MavenProject;
27  import org.joda.time.DateTime;
28  import org.kuali.student.common.mojo.AbstractKSMojo;
29  import org.kuali.student.contract.model.ServiceContractModel;
30  import org.kuali.student.contract.model.util.DateUtility;
31  import org.kuali.student.contract.model.util.HtmlContractWriter;
32  import org.slf4j.Logger;
33  import org.slf4j.LoggerFactory;
34  
35  /**
36   * The plugin entrypoint which is used to generate the html wiki doc of the service interface.
37   * @goal kscontractdoc
38   * @phase site
39   * @requiresProject true
40   */
41  public class KSContractDocMojo extends AbstractKSMojo {
42      
43      private static Logger log = LoggerFactory.getLogger(KSContractDocMojo.class);
44  
45      /**
46       * @parameter property="htmlDirectory" default-value="${project.build.directory}/site/services/contractdocs"
47       */
48      private File htmlDirectory;
49  
50      public File getHtmlDirectory() {
51          return htmlDirectory;
52      }
53    
54      public void setHtmlDirectory(File htmlDirectory) {
55          this.htmlDirectory = htmlDirectory;
56      }
57  
58      @Override
59      public void execute() throws MojoExecutionException, MojoFailureException {
60      	
61      	MavenProject project = (MavenProject) getPluginContext().get("project");
62      	
63      	String formattedDate = DateUtility.asYMDHMInEasternTimeZone(new DateTime());
64      	
65          ServiceContractModel model = null;
66          HtmlContractWriter writer = null;
67          getLog().info("publishing wiki contracts");
68          model = this.getModel();
69          this.validate(model);
70          getLog().info("publishing to = " + this.htmlDirectory.toString());
71          writer = new HtmlContractWriter(htmlDirectory.toString(), model);
72          writer.write(project.getVersion(), formattedDate);
73  
74  
75      }
76      
77      
78      private static final String CORE_DIRECTORY = "D:/svn/ks/ks-api/ks-core-api/src/main";
79      // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
80      private static final String COMMON_DIRECTORY = "D:/svn/ks/ks-api/ks-common-api/src/main/java";
81      private static final String ENROLL_DIRECTORY = "D:/svn/ks/ks-api/ks-enroll-api/src/main/java";
82      private static final String LUM_DIRECTORY = "D:/svn/ks/ks-api/ks-lum-api/src/main/java";
83      private static final String KSAP_API_DIRECTORY = "D:\\svn\\ks\\trunk\\ks-api\\ks-ap-api\\src\\main\\java";
84      private static final String KME_API_DIRECTORY = "D:\\svn\\kplus2\\kme\\bulletin\\api\\src\\main\\java\\org\\kuali\\mobility\\bulletin";
85      private static final String KSA_DIRECTORY = "D:/svn/ks/ksa/ksa-core/src/main/java";
86      private static final String TEST_SOURCE_DIRECTORY =
87              "src/test/java/org/kuali/student/contract/model/test/source";
88      private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
89      private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main";
90  
91      private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/core/api/src/main/java";
92      private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/kim/kim-api/src/main/java";
93      private static final String RICE_KRMS_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/krms/api/src/main/java";
94      
95      
96      private static final String TRUNK_CORE_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java";
97      private static final String TRUNK_ENROLL_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java";
98      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";
99                                                     
100     
101     public static void main(String[] args) {
102         log.info("execute");
103         List<String> srcDirs = new ArrayList<String>();
104         srcDirs.add(COMMON_DIRECTORY);
105         srcDirs.add(CORE_DIRECTORY);
106         srcDirs.add(LUM_DIRECTORY);
107         srcDirs.add(ENROLL_DIRECTORY);        
108 //        srcDirs.add(RICE_KIM_API_DIRECTORY);     
109         srcDirs.add(KSAP_API_DIRECTORY);    
110 //        srcDirs.add(KME_API_DIRECTORY);
111         srcDirs.add(RICE_CORE_API_DIRECTORY);
112         srcDirs.add(RICE_KRMS_API_DIRECTORY);
113 //        srcDirs.add(TRUNK_ENROLL_IMPL_KRMS_API);
114         KSContractDocMojo instance = new KSContractDocMojo();
115         Map pluginContext = new HashMap();
116         MavenProject project = new MavenProject();
117         pluginContext.put("project", project);
118         instance.setPluginContext(pluginContext);
119         instance.setSourceDirs(srcDirs);
120         instance.setHtmlDirectory(new File (TARGET_GENERATED_SOURCES));
121         try {
122             instance.execute();
123         } catch (MojoExecutionException ex) {
124             throw new RuntimeException(ex);
125         } catch (MojoFailureException ex) {
126             throw new RuntimeException(ex);
127         }
128     }
129     
130 }