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.remote.impl.mojo;
17  
18  import java.util.ArrayList;
19  import java.util.HashMap;
20  import java.util.List;
21  import java.util.Map;
22  import org.apache.maven.plugin.MojoExecutionException;
23  import org.apache.maven.plugin.MojoFailureException;
24  import org.apache.maven.project.MavenProject;
25  import org.kuali.student.common.mojo.AbstractKSMojo;
26  import org.kuali.student.contract.model.ServiceContractModel;
27  import org.kuali.student.contract.model.util.ServicesFilterByKeys;
28  
29  /**
30   *
31   * @author nwright
32   *
33   * @goal kscreateremoteimpl
34   * @phase none
35   * @requiresProject true
36   */
37  public class KSCreateRemoteImplMojo extends AbstractKSMojo {
38  
39      public KSCreateRemoteImplMojo() {
40      }
41      public String targetDir;
42  
43      public String getTargetDir() {
44          return targetDir;
45      }
46  
47      public void setTargetDir(String targetDir) {
48          this.targetDir = targetDir;
49      }
50  
51      @Override
52      public void execute() throws MojoExecutionException, MojoFailureException {
53  
54          ServiceContractModel model = getModel();
55          validate(model);
56          if (targetDir == null) {
57              String targetDir = "target/generated-sources/remote-impl";
58          }
59          List<String> servKeys = new ArrayList<String>();
60          servKeys.add("Atp");
61          servKeys.add("Type");
62          servKeys.add("State");
63          servKeys.add("LRC");
64          ServicesFilterByKeys filter = new ServicesFilterByKeys(servKeys);
65          RemoteImplWriter instance =
66                  new RemoteImplWriter(model,
67                  targetDir,
68                  RemoteImplWriter.DEFAULT_ROOT_PACKAGE,
69                  // TODO: inject filters as part of the Mojo parameters
70                  filter);
71          instance.write();
72  
73      }
74      private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main";
75      // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
76      private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java";
77      private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java";
78      private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java";
79      private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/core/api/src/main/java";
80      private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/kim/kim-api/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_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src";
85  
86      public static void main(String[] args) {
87          System.out.println("execute");
88          List<String> srcDirs = new ArrayList<String>();
89          srcDirs.add(COMMON_DIRECTORY);
90          srcDirs.add(CORE_DIRECTORY);
91          srcDirs.add(LUM_DIRECTORY);
92          srcDirs.add(ENROLL_DIRECTORY);
93          srcDirs.add(RICE_KIM_API_DIRECTORY);
94  //        srcDirs.add(RICE_CORE_API_DIRECTORY);
95          KSCreateRemoteImplMojo instance = new KSCreateRemoteImplMojo();
96          Map pluginContext = new HashMap();
97          MavenProject project = new MavenProject();
98          pluginContext.put("project", project);
99          instance.setPluginContext(pluginContext);
100         instance.setSourceDirs(srcDirs);
101         instance.setTargetDir(STANDALONE_DIRECTORY);
102         try {
103             instance.execute();
104         } catch (MojoExecutionException ex) {
105             throw new RuntimeException(ex);
106         } catch (MojoFailureException ex) {
107             throw new RuntimeException(ex);
108         }
109     }
110 }