001 /* 002 * Copyright 2009 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.osedu.org/licenses/ECL-2.0 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.remote.impl.mojo; 017 018 import java.util.ArrayList; 019 import java.util.HashMap; 020 import java.util.List; 021 import java.util.Map; 022 import org.apache.maven.plugin.MojoExecutionException; 023 import org.apache.maven.plugin.MojoFailureException; 024 import org.apache.maven.project.MavenProject; 025 import org.kuali.student.common.mojo.AbstractKSMojo; 026 import org.kuali.student.contract.model.ServiceContractModel; 027 import org.kuali.student.contract.model.util.ServicesFilterByKeys; 028 029 /** 030 * 031 * @author nwright 032 * 033 * @goal kscreateremoteimpl 034 * @phase none 035 * @requiresProject true 036 */ 037 public class KSCreateRemoteImplMojo extends AbstractKSMojo { 038 039 public KSCreateRemoteImplMojo() { 040 } 041 public String targetDir; 042 043 public String getTargetDir() { 044 return targetDir; 045 } 046 047 public void setTargetDir(String targetDir) { 048 this.targetDir = targetDir; 049 } 050 051 @Override 052 public void execute() throws MojoExecutionException, MojoFailureException { 053 054 ServiceContractModel model = getModel(); 055 validate(model); 056 if (targetDir == null) { 057 String targetDir = "target/generated-sources/remote-impl"; 058 } 059 List<String> servKeys = new ArrayList<String>(); 060 servKeys.add("Atp"); 061 servKeys.add("Type"); 062 servKeys.add("State"); 063 servKeys.add("LRC"); 064 servKeys.add("RICE.Permission"); 065 servKeys.add("RICE.Role"); 066 ServicesFilterByKeys filter = new ServicesFilterByKeys(servKeys); 067 RemoteImplWriter instance = 068 new RemoteImplWriter(model, 069 targetDir, 070 RemoteImplWriter.DEFAULT_ROOT_PACKAGE, 071 // TODO: inject filters as part of the Mojo parameters 072 filter); 073 instance.write(); 074 075 } 076 private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main"; 077 // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core"; 078 private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java"; 079 private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java"; 080 private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java"; 081 private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/core/api/src/main/java"; 082 private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/kim/kim-api/src/main/java"; 083 private static final String TEST_SOURCE_DIRECTORY = 084 "src/test/java/org/kuali/student/contract/model/test/source"; 085 private static final String TARGET_GENERATED_SOURCES = "target/generated-sources"; 086 private static final String STANDALONE_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src"; 087 088 public static void main(String[] args) { 089 System.out.println("execute"); 090 List<String> srcDirs = new ArrayList<String>(); 091 srcDirs.add(COMMON_DIRECTORY); 092 srcDirs.add(CORE_DIRECTORY); 093 srcDirs.add(LUM_DIRECTORY); 094 srcDirs.add(ENROLL_DIRECTORY); 095 srcDirs.add(RICE_KIM_API_DIRECTORY); 096 // srcDirs.add(RICE_CORE_API_DIRECTORY); 097 KSCreateRemoteImplMojo instance = new KSCreateRemoteImplMojo(); 098 Map pluginContext = new HashMap(); 099 MavenProject project = new MavenProject(); 100 pluginContext.put("project", project); 101 instance.setPluginContext(pluginContext); 102 instance.setSourceDirs(srcDirs); 103 instance.setTargetDir(STANDALONE_DIRECTORY); 104 try { 105 instance.execute(); 106 } catch (MojoExecutionException ex) { 107 throw new RuntimeException(ex); 108 } catch (MojoFailureException ex) { 109 throw new RuntimeException(ex); 110 } 111 } 112 }