001 package org.kuali.student.datadictionary.mojo; 002 003 import java.io.File; 004 import java.util.Collection; 005 import java.util.List; 006 007 import org.apache.maven.plugin.AbstractMojo; 008 import org.apache.maven.plugin.MojoExecutionException; 009 010 import org.kuali.student.common.mojo.AbstractKSMojo; 011 import org.kuali.student.contract.model.ServiceContractModel; 012 import org.kuali.student.contract.model.impl.ServiceContractModelCache; 013 import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader; 014 import org.kuali.student.contract.model.validation.ServiceContractModelValidator; 015 import org.kuali.student.contract.writer.service.EachMethodServiceWriter; 016 017 /** 018 * The plugin entrypoint which is used to generate a java interface file for each 019 * service method in the source files based on the contract definition 020 * @phase generate-sources 021 * @goal kseachmethodservicegenerator 022 */ 023 public class KSEachMethodServiceGeneratorrMojo extends AbstractKSMojo { 024 025 /** 026 * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources" 027 */ 028 private File outputDirectory; 029 030 public File getOutputDirectory() { 031 return outputDirectory; 032 } 033 034 035 public void setOutputDirectory(File htmlDirectory) { 036 this.outputDirectory = htmlDirectory; 037 } 038 039 /** 040 * @parameter expression="${rootPackage}" default-value="org.kuali.student.enrollment" 041 */ 042 private String rootPackage; 043 044 public String getRootPackage() { 045 return rootPackage; 046 } 047 048 public void setRootPackage(String rootPackage) { 049 this.rootPackage = rootPackage; 050 } 051 052 053 054 055 @Override 056 public void execute() throws MojoExecutionException { 057 getLog().info("generating separate java interface files for each method in the service contracts"); 058 ServiceContractModel model = this.getModel(); 059 this.validate(model); 060 if (!outputDirectory.exists()) { 061 if (!outputDirectory.mkdirs()) { 062 // throw new MojoExecutionException("Could not create directory " 063 throw new IllegalArgumentException("Could not create directory " 064 + this.outputDirectory.getPath()); 065 } 066 } 067 String targetDirectory = this.outputDirectory.toString(); 068 EachMethodServiceWriter instance = 069 new EachMethodServiceWriter(model, 070 targetDirectory, 071 rootPackage, 072 null); 073 instance.write(); 074 075 } 076 }