View Javadoc

1   /*
2    * Copyright 2009 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.osedu.org/licenses/ECL-2.0
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.mock.mojo;
17  
18  import java.util.ArrayList;
19  import java.util.HashMap;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.apache.maven.plugin.MojoExecutionException;
24  import org.apache.maven.plugin.MojoFailureException;
25  import org.apache.maven.project.MavenProject;
26  import org.kuali.student.admin.ui.mojo.KSCreateAdminUiMojo;
27  import org.kuali.student.common.mojo.AbstractKSMojo;
28  import org.kuali.student.contract.model.ServiceContractModel;
29  import org.kuali.student.contract.model.impl.ServiceContractModelPescXsdLoader;
30  import org.slf4j.Logger;
31  import org.slf4j.LoggerFactory;
32  
33  /**
34   *
35   * @author nwright
36   * 
37   *  @goal kscreatemock
38   *  @phase site
39   *  @requiresProject true
40   */
41  public class KSCreateMockImplMojo extends AbstractKSMojo {
42  
43      private static Logger log = LoggerFactory.getLogger(KSCreateMockImplMojo.class);
44      
45      public KSCreateMockImplMojo() {
46      }
47   
48      private String targetDir;
49  
50      public String getTargetDir() {
51          return targetDir;
52      }
53  
54      public void setTargetDir(String targetDir) {
55          this.targetDir = targetDir;
56      }
57      
58      
59      
60      @Override
61  	public void execute() throws MojoExecutionException, MojoFailureException {
62          ServiceContractModel model = getModel();
63          validate(model);
64          if (targetDir == null) {
65              targetDir = "target/generated-mock-impls";
66          }
67          boolean isR1 = false;
68          MockImplWriter instance =
69                  new MockImplWriter(model,
70                  targetDir,
71                  MockImplWriter.ROOT_PACKAGE,
72                  null,
73                  isR1);
74          instance.write();
75  
76      }
77      
78      
79      
80      private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main";
81      // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
82      private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java";
83      private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java";
84      private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java";
85      private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/core/api/src/main/java";
86      private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/kim/kim-api/src/main/java";
87      private static final String RICE_KRMS_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/krms/api/src/main/java";
88      private static final String TEST_SOURCE_DIRECTORY =
89              "src/test/java/org/kuali/student/contract/model/test/source";
90      private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
91      private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main";
92      private static final String SERVICES_ENROLL_IMPL = "D:/svn/ks/services/ks-enroll/ks-enroll-impl/src/main/java";
93      private static final String CM_CORE_API = "D:/svn/ks/CM-2.0/ks-api/ks-core-api/src/main/java";
94      private static final String TRUNK_CORE_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java";
95      private static final String TRUNK_ENROLL_IMPL = "D:/svn/ks/trunk/ks-enroll/ks-enroll-impl/src/main/java";
96      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";
97                                                     
98  
99      public static void main(String[] args) {
100         log.info("execute");
101         List<String> srcDirs = new ArrayList<String>();
102         srcDirs.add(COMMON_DIRECTORY);
103         srcDirs.add(CORE_DIRECTORY);
104         srcDirs.add(LUM_DIRECTORY);
105         srcDirs.add(ENROLL_DIRECTORY);
106 //        srcDirs.add(RICE_KIM_API_DIRECTORY);
107 //        srcDirs.add(RICE_CORE_API_DIRECTORY);
108 //        srcDirs.add(RICE_KRMS_API_DIRECTORY);
109 //        srcDirs.add(TRUNK_ENROLL_IMPL_KRMS_API);
110         KSCreateMockImplMojo instance = new KSCreateMockImplMojo();
111         Map pluginContext = new HashMap();
112         MavenProject project = new MavenProject();
113         pluginContext.put("project", project);
114         instance.setPluginContext(pluginContext);
115         instance.setSourceDirs(srcDirs);
116 //        instance.setTargetDir(SERVICES_ENROLL_IMPL);
117 //        instance.setTargetDir(CM_CORE_API);
118         instance.setTargetDir(TRUNK_ENROLL_IMPL);
119         try {
120             instance.execute();
121             //        assertTrue(new File(instance.getOutputDirectory() + "/" + "ks-LprInfo-dictionary.xml").exists());  
122         } catch (MojoExecutionException ex) {
123             throw new RuntimeException(ex);
124         } catch (MojoFailureException ex) {
125             throw new RuntimeException(ex);
126         }
127     }
128 }