001 /** 002 * Copyright 2004-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.student.mock.mojo; 017 018 import java.util.ArrayList; 019 import java.util.HashMap; 020 import java.util.List; 021 import java.util.Map; 022 023 import org.apache.maven.plugin.MojoExecutionException; 024 import org.apache.maven.plugin.MojoFailureException; 025 import org.apache.maven.project.MavenProject; 026 import org.kuali.student.admin.ui.mojo.KSCreateAdminUiMojo; 027 import org.kuali.student.common.mojo.AbstractKSMojo; 028 import org.kuali.student.contract.model.ServiceContractModel; 029 import org.kuali.student.contract.model.impl.ServiceContractModelPescXsdLoader; 030 import org.slf4j.Logger; 031 import org.slf4j.LoggerFactory; 032 033 /** 034 * 035 * @author nwright 036 * 037 * @goal kscreatemock 038 * @phase site 039 * @requiresProject true 040 */ 041 public class KSCreateMockImplMojo extends AbstractKSMojo { 042 043 private static Logger log = LoggerFactory.getLogger(KSCreateMockImplMojo.class); 044 045 public KSCreateMockImplMojo() { 046 } 047 048 private String targetDir; 049 050 public String getTargetDir() { 051 return targetDir; 052 } 053 054 public void setTargetDir(String targetDir) { 055 this.targetDir = targetDir; 056 } 057 058 059 060 @Override 061 public void execute() throws MojoExecutionException, MojoFailureException { 062 ServiceContractModel model = getModel(); 063 validate(model); 064 if (targetDir == null) { 065 targetDir = "target/generated-mock-impls"; 066 } 067 boolean isR1 = false; 068 MockImplWriter instance = 069 new MockImplWriter(model, 070 targetDir, 071 MockImplWriter.ROOT_PACKAGE, 072 null, 073 isR1); 074 instance.write(); 075 076 } 077 078 079 080 private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main"; 081 // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core"; 082 private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java"; 083 private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java"; 084 private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java"; 085 private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/core/api/src/main/java"; 086 private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/kim/kim-api/src/main/java"; 087 private static final String RICE_KRMS_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/krms/api/src/main/java"; 088 private static final String TEST_SOURCE_DIRECTORY = 089 "src/test/java/org/kuali/student/contract/model/test/source"; 090 private static final String TARGET_GENERATED_SOURCES = "target/generated-sources"; 091 private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main"; 092 private static final String SERVICES_ENROLL_IMPL = "D:/svn/ks/services/ks-enroll/ks-enroll-impl/src/main/java"; 093 private static final String CM_CORE_API = "D:/svn/ks/CM-2.0/ks-api/ks-core-api/src/main/java"; 094 private static final String TRUNK_CORE_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java"; 095 private static final String TRUNK_ENROLL_IMPL = "D:/svn/ks/trunk/ks-enroll/ks-enroll-impl/src/main/java"; 096 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"; 097 098 099 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 }