1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.jpa.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.common.mojo.AbstractKSMojo;
27 import org.kuali.student.contract.model.ServiceContractModel;
28 import org.kuali.student.contract.model.util.ServicesFilter;
29 import org.kuali.student.contract.model.util.ServicesFilterByKeys;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33
34
35
36
37
38
39
40
41 public class KSCreateJpaImplMojo extends AbstractKSMojo {
42
43 private static Logger log = LoggerFactory.getLogger(KSCreateJpaImplMojo.class);
44
45 public KSCreateJpaImplMojo() {
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-jpa-impls";
66 }
67 List<String> servKeys = new ArrayList<String>();
68
69
70 ServicesFilter filter = null;
71 boolean isR1 = false;
72 JpaImplWriter instance =
73 new JpaImplWriter(model,
74 targetDir,
75 JpaImplWriter.ROOT_PACKAGE,
76 filter,
77 isR1);
78 instance.write();
79
80 }
81
82
83
84 private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main";
85
86 private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java";
87 private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java";
88 private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java";
89 private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/core/api/src/main/java";
90 private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/kim/kim-api/src/main/java";
91 private static final String RICE_KRMS_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/krms/api/src/main/java";
92 private static final String TEST_SOURCE_DIRECTORY =
93 "src/test/java/org/kuali/student/contract/model/test/source";
94 private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
95 private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main";
96 private static final String SERVICES_ENROLL_IMPL = "D:/svn/ks/services/ks-enroll/ks-enroll-impl/src/main/java";
97 private static final String CM_CORE_API = "D:/svn/ks/CM-2.0/ks-api/ks-core-api/src/main/java";
98 private static final String TRUNK_CORE_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java";
99 private static final String TRUNK_ENROLL_IMPL = "D:/svn/ks/trunk/ks-enroll/ks-enroll-impl/src/main/java";
100 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";
101
102
103 public static void main(String[] args) {
104 log.info("execute");
105 List<String> srcDirs = new ArrayList<String>();
106 srcDirs.add(COMMON_DIRECTORY);
107 srcDirs.add(CORE_DIRECTORY);
108 srcDirs.add(LUM_DIRECTORY);
109 srcDirs.add(ENROLL_DIRECTORY);
110
111
112
113
114 KSCreateJpaImplMojo instance = new KSCreateJpaImplMojo();
115 Map pluginContext = new HashMap();
116 MavenProject project = new MavenProject();
117 pluginContext.put("project", project);
118 instance.setPluginContext(pluginContext);
119 instance.setSourceDirs(srcDirs);
120
121
122 instance.setTargetDir(TRUNK_ENROLL_IMPL);
123 try {
124 instance.execute();
125
126 } catch (MojoExecutionException ex) {
127 throw new RuntimeException(ex);
128 } catch (MojoFailureException ex) {
129 throw new RuntimeException(ex);
130 }
131 }
132 }